splinkersets01 test assumptions

Sebastian Huber sebastian.huber at embedded-brains.de
Wed Feb 17 17:19:41 UTC 2021


On 17/02/2021 17:41, Kinsey Moore wrote:

>>>> I would remove the SUBALIGN() from the linker script. You can also add a
>>>> new test case for splinkersets01 similar to struct s from above. Then we
>>>> should check if the test fails on aarch64 and why it fails.
>>> The example above actually shows the issue I'm having in _Linker_set_i_begin and _Linker_set_i_end. The alignment expands for the larger struct, but does not shrink for data types smaller than 8 bytes, leaving padding that the test interprets as additional space in the linker set.
>> I still don't see why a larger alignment is an issue. The begin/end
>> objects have a size of zero. Where do you observe a padding?
> Even when the begin/end objects have a size of 0, they're aligned out to 8 bytes forcing empty bytes if the content does not exactly fill a multiple of 8 bytes. Those non-content bytes are counted as part of the section.

Ok, it took a while, but I understand now the problem. I think this is a 
GCC bug.

cat test-align.c
char i;
char j[1];
char z[0];
unsigned long ai = _Alignof(i);
unsigned long aj = _Alignof(j);
unsigned long az = _Alignof(z);

aarch64-rtems6-gcc -O2 -S -o - test-align.c -mabi=ilp32 -fdata-sections
         .arch armv8-a
         .file   "test-align.c"
         .text
         .global az
         .global aj
         .global ai
         .global z
         .global j
         .global i
         .section        .bss.i,"aw", at nobits
         .type   i, %object
         .size   i, 1
i:
         .zero   1
         .section        .bss.j,"aw", at nobits
         .align  3
         .type   j, %object
         .size   j, 1
j:
         .zero   1
         .section        .bss.z,"aw", at nobits
         .align  3
         .type   z, %object
         .size   z, 0
z:
         .section        .data.ai,"aw"
         .align  2
         .type   ai, %object
         .size   ai, 4
ai:
         .word   1
         .section        .data.aj,"aw"
         .align  2
         .type   aj, %object
         .size   aj, 4
aj:
         .word   1
         .section        .data.az,"aw"
         .align  2
         .type   az, %object
         .size   az, 4
az:
         .word   1
         .ident  "GCC: (GNU) 10.2.1 20210205 (RTEMS 6, RSB 
61dcadee0825867ebe51f9f367430ef75b8fe9c0, Newlib d4a756f)"

clang --target=aarch64 -O2 -S -o - test-align.c  -fdata-sections -fno-common
test-align.c:4:20: warning: '_Alignof' applied to an expression is a GNU 
extension [-Wgnu-alignof-expression]
unsigned long ai = _Alignof(i);
                    ^
test-align.c:5:20: warning: '_Alignof' applied to an expression is a GNU 
extension [-Wgnu-alignof-expression]
unsigned long aj = _Alignof(j);
                    ^
test-align.c:6:20: warning: '_Alignof' applied to an expression is a GNU 
extension [-Wgnu-alignof-expression]
unsigned long az = _Alignof(z);
                    ^
         .text
         .file   "test-align.c"
         .type   ai, at object              // @ai
         .section        .data.ai,"aw", at progbits
         .globl  ai
         .p2align        3
ai:
         .xword  1                       // 0x1
         .size   ai, 8

         .type   aj, at object              // @aj
         .section        .data.aj,"aw", at progbits
         .globl  aj
         .p2align        3
aj:
         .xword  1                       // 0x1
         .size   aj, 8

         .type   az, at object              // @az
         .section        .data.az,"aw", at progbits
         .globl  az
         .p2align        3
az:
         .xword  1                       // 0x1
         .size   az, 8

         .type   i, at object               // @i
         .section        .bss.i,"aw", at nobits
         .globl  i
i:
         .byte   0                       // 0x0
         .size   i, 1

         .type   j, at object               // @j
         .section        .bss.j,"aw", at nobits
         .globl  j
j:
         .zero   1
         .size   j, 1

         .type   z, at object               // @z
         .section        .bss.z,"aw", at nobits
         .globl  z
z:
         .size   z, 0


         .ident  "clang version 9.0.1 "
         .section        ".note.GNU-stack","", at progbits
         .addrsig
3 warnings generated.

I would file a GCC bug report.

-- 
embedded brains GmbH
Herr Sebastian HUBER
Dornierstr. 4
82178 Puchheim
Germany
email: sebastian.huber at embedded-brains.de
phone: +49-89-18 94 741 - 16
fax:   +49-89-18 94 741 - 08

Registergericht: Amtsgericht München
Registernummer: HRB 157899
Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
Unsere Datenschutzerklärung finden Sie hier:
https://embedded-brains.de/datenschutzerklaerung/



More information about the devel mailing list