https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99143

            Bug ID: 99143
           Summary: Bad section alignment on AArch64
           Product: gcc
           Version: 10.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nyphbl8d at gmail dot com
  Target Milestone: ---

aarch64-rtems6-gcc -v output:
Using built-in specs.
COLLECT_GCC=aarch64-rtems6-gcc
COLLECT_LTO_WRAPPER=/home/opticron/rtems-development/tools/libexec/gcc/aarch64-rtems6/10.2.1/lto-wrapper
Target: aarch64-rtems6
Configured with: ../gnu-mirror-gcc-949e0ad/configure
--prefix=/home/opticron/rtems-development/tools
--bindir=/home/opticron/rtems-development/tools/bin
--exec_prefix=/home/opticron/rtems-development/tools
--includedir=/home/opticron/rtems-development/tools/include
--libdir=/home/opticron/rtems-development/tools/lib
--libexecdir=/home/opticron/rtems-development/tools/libexec
--mandir=/home/opticron/rtems-development/tools/share/man
--infodir=/home/opticron/rtems-development/tools/share/info
--datadir=/home/opticron/rtems-development/tools/share --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=aarch64-rtems6 --disable-libstdcxx-pch
--with-gnu-as --with-gnu-ld --verbose --with-newlib --disable-nls
--without-included-gettext --disable-win32-registry
--enable-version-specific-runtime-libs --disable-lto
--enable-newlib-io-c99-formats --enable-newlib-iconv
--enable-newlib-iconv-encodings=big5,cp775,cp850,cp852,cp855,cp866,euc_jp,euc_kr,euc_tw,iso_8859_1,iso_8859_10,iso_8859_11,iso_8859_13,iso_8859_14,iso_8859_15,iso_8859_2,iso_8859_3,iso_8859_4,iso_8859_5,iso_8859_6,iso_8859_7,iso_8859_8,iso_8859_9,iso_ir_111,koi8_r,koi8_ru,koi8_u,koi8_uni,ucs_2,ucs_2_internal,ucs_2be,ucs_2le,ucs_4,ucs_4_internal,ucs_4be,ucs_4le,us_ascii,utf_16,utf_16be,utf_16le,utf_8,win_1250,win_1251,win_1252,win_1253,win_1254,win_1255,win_1256,win_1257,win_1258
--enable-threads --disable-plugin --enable-libgomp --enable-languages=c,c++
Thread model: rtems
Supported LTO compression algorithms: zlib
gcc version 10.2.1 20200918 (RTEMS 6, RSB
f5fc2bfabbd18f31901ffa6fc0e5b6b47874797c-modified, Newlib 749cbcc) (GCC)

Source file 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);

Command line:
aarch64-rtems6-gcc -O2 -S -o - test-align.c -mabi=ilp32 -fdata-sections

Compiler output:
        .arch armv8-a
        .file   "test-align.c"
        .text
        .global az
        .global aj
        .global ai
        .global z
        .global j
        .global i
        .section        .bss.i,"aw",@nobits
        .type   i, %object
        .size   i, 1
i:
        .zero   1
        .section        .bss.j,"aw",@nobits
        .align  3
        .type   j, %object
        .size   j, 1
j:
        .zero   1
        .section        .bss.z,"aw",@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 20200918 (RTEMS 6, RSB
f5fc2bfabbd18f31901ffa6fc0e5b6b47874797c-modified, Newlib 749cbcc)"

test-align.i from --save-temps:
# 1 "test-align.c"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "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);

Description:
When generating data sections for i, j, z for AArch64/ILP32 (also applies to
LP64), GCC does not align data sections to anything less than 8 bytes, even
when _Alignof() claims that the alignment of all three data elements should be
1 byte.

Reply via email to