You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
int a attribute((section(".data..ro_after_init")));
static int b[4] attribute((section(".data..ro_after_init")));
int c;
int fn1(void);
void fn2() { c = b[fn1()]; }
Extended Description
Building the linux kernel for i386, I get an assembler warning in one file:
/tmp/slab_common-bf04f6.s: Assembler messages:
/tmp/slab_common-bf04f6.s:38: Warning: ignoring changed section attributes for .data..ro_after_init
I reduced the test case to
int a attribute((section(".data..ro_after_init")));
static int b[4] attribute((section(".data..ro_after_init")));
int c;
int fn1(void);
void fn2() { c = b[fn1()]; }
clang-9 -fno-common -no-integrated-as -O2 -fno-strict-overflow -c test.c
Initializing 'a' to zero shuts up the warning, and causes this difference in the assembler output:
--- slab_common-broken.s 2019-07-10 22:36:57.262501626 +0200
+++ slab_common-good.s 2019-07-10 22:37:17.418912892 +0200
@@ -12,36 +12,35 @@
cltq
movl b(,%rax,4), %eax
movl %eax, c(%rip)
popq %rax
.cfi_def_cfa_offset 8
retq
.Lfunc_end0:
.size fn2, .Lfunc_end0-fn2
.cfi_endproc
# -- End function
+a:
.section .data..ro_after_init,"aM",@progbits,16
.p2align 4
b:
.zero 16
.size b, 16
.type c,@object # @c
.bss
.globl c
.p2align 2
c:
.long 0 # 0x0
.size c, 4
.type a,@object # @a
.section .data..ro_after_init,"aM",@progbits,16
.globl a
.p2align 2
-a:
.long 0 # 0x0
.size a, 4
See also https://godbolt.org/z/hBPgpb
The text was updated successfully, but these errors were encountered: