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

bugzilla at busybox.net bugzilla at busybox.net
Sun Sep 26 08:09:38 UTC 2021


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

--- Comment #4 from YU Jincheng <shana at zju.edu.cn> ---
I did have one trick.

```
#define INIT_G_misc() do { \
        (*(struct globals_misc**)not_const_pp(&ash_ptr_to_globals_misc)) = ({ \
                struct globals_misc *BB_GLOBAL_CONST ash_ptr_to_globals_misc =
xzalloc(sizeof(G_misc));  \
                savestatus = -1; \
                curdir = nullstr; \
            physdir = nullstr; \
            trap_ptr = trap; \
                ash_ptr_to_globals_misc;});                                    
                                                                               
                \
} while (0)
```

And the result is:
.text:0000000000491608                 BL              xzalloc
.text:000000000049160C                 ADRP            X21,
#ash_ptr_to_globals_misc_ptr at PAGE
.text:0000000000491610                 LDR             X21,
[X21,#ash_ptr_to_globals_misc_ptr at PAGEOFF]
.text:0000000000491614                 MOV             W8, #0xFFFFFFFF
.text:0000000000491618                 ADD             X9, X0, #0x54 ; 'T'
.text:000000000049161C                 ADD             X10, X0, #0xE8
.text:0000000000491620                 STR             W8, [X0,#8]
.text:0000000000491624                 MOV             X8, X21
.text:0000000000491628                 STP             X9, X9, [X0,#0x20]
.text:000000000049162C                 STR             X10, [X0,#0x2F0]
.text:0000000000491630                 STR             X0, [X8]
.text:0000000000491634                 MOV             W0, #0x220

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


More information about the busybox-cvs mailing list