[PATCH] ash: fix a crash on arm when building with clang.
Yunlian Jiang
yunlian at google.com
Fri Dec 29 00:22:47 UTC 2017
Sorry about the confusion. My build system changed the compiler back to gcc
when I try to apply the patch and the patch does not help.
However, the patch below helps
@@ -173,7 +173,11 @@ struct lineedit_statics {
};
/* See lineedit_ptr_hack.c */
-extern struct lineedit_statics *const lineedit_ptr_to_statics;
+#ifndef GCC_COMBINE
+extern struct lineedit_statics *lineedit_ptr_to_statics;
+#else
+extern struct lineedit_statics *const lineedit_ptr_to_statics
__attribute__ ((section (".data")));
+#endif
#define S (*lineedit_ptr_to_statics)
#define state (S.state )
On Wed, Dec 20, 2017 at 7:44 PM, Kang-Che Sung <explorer09 at gmail.com> wrote:
> On Thu, Dec 21, 2017 at 5:32 AM, Yunlian Jiang <yunlian at google.com> wrote:
> >
> > When I run
> > busybox ash on an arm device with busybox built with clang 6.
> > I got a segmentation fault
> > in the macro
> > #define INIT_S() do { \
> > (*(struct lineedit_statics**)&lineedit_ptr_to_statics) =
> xzalloc(sizeof(S)); \
> > barrier(); \
> > cmdedit_termw = 80; \
> > IF_USERNAME_OR_HOMEDIR(home_pwd_buf = (char*)null_str;) \
> > IF_FEATURE_EDITING_VI(delptr = delbuf;) \
> > } while (0)
> >
> > With the patch below, the segmentation disappears.
> >
> > --- busybox-1.27.2/libbb/lineedit.c
> > +++ busybox-1.27.2/libbb/lineedit.c
> > @@ -197,8 +197,8 @@ extern struct lineedit_statics *const li
> > (*(struct lineedit_statics**)&lineedit_ptr_to_statics) =
> xzalloc(sizeof(S)); \
> > barrier(); \
> > cmdedit_termw = 80; \
> > - IF_USERNAME_OR_HOMEDIR(home_pwd_buf = (char*)null_str;) \
> > - IF_FEATURE_EDITING_VI(delptr = delbuf;) \
> > + IF_USERNAME_OR_HOMEDIR(home_pwd_buf = (char*)null_str;); \
> > + IF_FEATURE_EDITING_VI(delptr = delbuf;); \
> > } while (0)
> >
> > static void deinit_S(void)
>
> What's the problem of the missing semicolons in the build? BusyBox has been
> using these constructs almost everywhere. And they should succeed.
>
> Could you show us the generated code differences?
> It looks like a bug in the compiler, and nothing to do with Busybox.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20171228/746e34a2/attachment-0001.html>
More information about the busybox
mailing list