ASH: why ash_ptr_to_globals_misc is declared as const pointer
Yunlian Jiang
yunlian at google.com
Thu Jan 18 21:48:34 UTC 2018
Hi,
I tried to build busybox with clang and use it to create recovery image
for ChromeOS.
It fails to recover an arm based ChromeBook.
I digged a little bit.
Below patch makes it work. My question is.
the ash_ptr_to_globals_misc, ash_ptr_to_globals_memstack
and ash_ptr_to_globals_var
are defined in ash_ptr_hack.c as normal pointers. But in ash.c, they are
declared as const
pointers. What is the benefit of doing that?
Thanks
--- busybox-1.27.2/shell/ash.c
+++ busybox-1.27.2/shell/ash.c
@@ -378,7 +378,11 @@ struct globals_misc {
#endif
pid_t backgndpid; /* pid of last background process */
};
+#ifndef GCC_COMBINE
+extern struct globals_misc * ash_ptr_to_globals_misc;
+#else
extern struct globals_misc *const ash_ptr_to_globals_misc;
+#endif
#define G_misc (*ash_ptr_to_globals_misc)
#define exitstatus (G_misc.exitstatus )
#define back_exitstatus (G_misc.back_exitstatus )
@@ -1431,7 +1435,11 @@ struct globals_memstack {
size_t g_stacknleft; // = MINSIZE;
struct stack_block stackbase;
};
+#ifndef GCC_COMBINE
+extern struct globals_memstack * ash_ptr_to_globals_memstack;
+#else
extern struct globals_memstack *const ash_ptr_to_globals_memstack;
+#endif
#define G_memstack (*ash_ptr_to_globals_memstack)
#define g_stackp (G_memstack.g_stackp )
#define g_stacknxt (G_memstack.g_stacknxt )
@@ -1983,7 +1991,11 @@ struct globals_var {
struct var *vartab[VTABSIZE];
struct var varinit[ARRAY_SIZE(varinit_data)];
};
+#ifndef GCC_COMBINE
+extern struct globals_var * ash_ptr_to_globals_var;
+#else
extern struct globals_var *const ash_ptr_to_globals_var;
+#endif
#define G_var (*ash_ptr_to_globals_var)
#define shellparam (G_var.shellparam )
//#define redirlist (G_var.redirlist )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20180118/c318c9ff/attachment.html>
More information about the busybox
mailing list