[Bug 14231] not_const_pp is causing memory reorder in clang without lto in arm

bugzilla at busybox.net bugzilla at busybox.net
Sat Sep 25 17:11:07 UTC 2021


https://bugs.busybox.net/show_bug.cgi?id=14231

Denys Vlasenko <vda.linux at googlemail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|INVALID                     |---
             Status|RESOLVED                    |REOPENED

--- Comment #3 from Denys Vlasenko <vda.linux at googlemail.com> ---
(In reply to YU Jincheng from comment #2)
> Ok I finally find the comment about `-DBB_GLOBAL_CONST=""` and it fixes.

 * However, this may break on weird arches or toolchains. In this case,
 * set "-DBB_GLOBAL_CONST=''" in CONFIG_EXTRA_CFLAGS to disable
 * this optimization.

This is not a fix, it's more of a work-around: constant optimization reduces
code size by _kilobytes_ here.

We need to find a way to prevent clang from reordering loads and stores here:

    0x491630 <+44>:   ldr    x21, [x8]
    0x491634 <+48>:   str    x0, [x8]

IOW: set ash_ptr_to_globals_misc to the needed value, THEN load it (or better
yet, just use x0 since that's the value).

Can you research what would work for clang 9 here?

#define INIT_G_misc() do { \
        (*(struct globals_misc**)not_const_pp(&ash_ptr_to_globals_misc)) =
xzalloc(sizeof(G_misc)); \
        barrier(); \
        savestatus = -1; \

Adding another "barrier();" _before_ the pointer assignment? Some other trick?

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the busybox-cvs mailing list