public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug other/101115] New: ld.bfd: warning: .init_array section has zero size
@ 2021-06-18  3:15 judge.packham at gmail dot com
  2021-06-18  3:31 ` [Bug target/101115] " pinskia at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: judge.packham at gmail dot com @ 2021-06-18  3:15 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 101115
           Summary: ld.bfd: warning: .init_array section has zero size
           Product: gcc
           Version: 11.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: other
          Assignee: unassigned at gcc dot gnu.org
          Reporter: judge.packham at gmail dot com
  Target Milestone: ---

When cross-compiling for arm using GCC 11.1.0 the linker complains that
.init_array and .fini_array have a zero size.

x-tool@063c4281c760:~$ rm -f test test.o; make CC=arm-unknown-linux-gnueabi-gcc
test
arm-unknown-linux-gnueabi-gcc     test.c   -o test
/home/x-tool/x-tools/arm-unknown-linux-gnueabi/lib/gcc/arm-unknown-linux-gnueabi/11.1.0/../../../../arm-unknown-linux-gnueabi/bin/ld.bfd:
warning: .init_array section has zero size
/home/x-tool/x-tools/arm-unknown-linux-gnueabi/lib/gcc/arm-unknown-linux-gnueabi/11.1.0/../../../../arm-unknown-linux-gnueabi/bin/ld.bfd:
warning: .fini_array section has zero size

The program being compiled is a simple "hello world".

I've also seen the same problem with GCC 10.3.0. I do not see the problem with
GCC 9.3.0.

Based on some debugging with the help of the bintutils mailing list[1] it seems
that crtbegin.o has a zero sized init_array/.fini_array

find . -name 'crtbegin.o' | xargs readelf -SW                                   

File:
./x-tools/arm-unknown-linux-gnueabi/lib/gcc/arm-unknown-linux-gnueabi/11.1.0/crtbegin.o 
There are 13 section headers, starting at offset 0x2bc:                         

Section Headers:                                                                
  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf
Al                                                                              
  [ 0]                   NULL            00000000 000000 000000 00      0   0 
0                                                                               
  [ 1] .text             PROGBITS        00000000 000034 000000 00  AX  0   0 
1                                                                               
  [ 2] .data             PROGBITS        00000000 000034 000004 00  WA  0   0 
4                                                                               
  [ 3] .bss              NOBITS          00000000 000038 000000 00  WA  0   0 
1                                                                               
  [ 4] .rodata           PROGBITS        00000000 000038 000090 00   A  0   0 
4                                                                               
  [ 5] .init_array       INIT_ARRAY      00000000 0000c8 000000 04  WA  0   0 
1                                                                               
  [ 6] .fini_array       FINI_ARRAY      00000000 0000c8 000000 04  WA  0   0 
1                                                                               
  [ 7] .comment          PROGBITS        00000000 0000c8 00002f 01  MS  0   0 
1                                                                               
  [ 8] .note.GNU-stack   PROGBITS        00000000 0000f7 000000 00      0   0 
1                                                                               
  [ 9] .ARM.attributes   ARM_ATTRIBUTES  00000000 0000f7 000031 00      0   0 
1                                                                               
  [10] .symtab           SYMTAB          00000000 000128 0000f0 10     11  14 
4                                                                               
  [11] .strtab           STRTAB          00000000 000218 00002e 00      0   0 
1                                                                               
  [12] .shstrtab         STRTAB          00000000 000246 000075 00      0   0 
1                                                                               
Key to Flags:                                                                   
  W (write), A (alloc), X (execute), M (merge), S (strings), I (info),
  L (link order), O (extra OS processing required), G (group), T (TLS),
  C (compressed), x (unknown), o (OS specific), E (exclude),
  y (purecode), p (processor specific)

With GCC 9.3.0 it does not

File:
./x-tools/arm-unknown-linux-gnueabi/lib/gcc/arm-unknown-linux-gnueabi/9.3.0/crtbegin.o
There are 16 section headers, starting at offset 0x518:

Section Headers:
  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf
Al
  [ 0]                   NULL            00000000 000000 000000 00      0   0 
0
  [ 1] .text             PROGBITS        00000000 000034 000090 00  AX  0   0 
4
  [ 2] .rel.text         REL             00000000 000444 000038 08   I 13   1 
4
  [ 3] .data             PROGBITS        00000000 0000c4 000004 00  WA  0   0 
4
  [ 4] .bss              NOBITS          00000000 0000c8 000001 00  WA  0   0 
1
  [ 5] .init_array       INIT_ARRAY      00000000 0000c8 000004 04  WA  0   0 
4
  [ 6] .rel.init_array   REL             00000000 00047c 000008 08   I 13   5 
4
  [ 7] .fini_array       FINI_ARRAY      00000000 0000cc 000004 04  WA  0   0 
4
readelf: Warning: [ 8]: Info field (7) should index a relocatable section.
  [ 8] .rel.fini_array   REL             00000000 000484 000008 08   I 13   7 
4
  [ 9] .tm_clone_table   PROGBITS        00000000 0000d0 000000 00  WA  0   0 
4
  [10] .comment          PROGBITS        00000000 0000d0 00002e 01  MS  0   0 
1
  [11] .note.GNU-stack   PROGBITS        00000000 0000fe 000000 00      0   0 
1
  [12] .ARM.attributes   ARM_ATTRIBUTES  00000000 0000fe 00002a 00      0   0 
1
  [13] .symtab           SYMTAB          00000000 000128 000220 10     14  30 
4
  [14] .strtab           STRTAB          00000000 000348 0000fa 00      0   0 
1
  [15] .shstrtab         STRTAB          00000000 00048c 000089 00      0   0 
1
Key to Flags:
  W (write), A (alloc), X (execute), M (merge), S (strings), I (info),
  L (link order), O (extra OS processing required), G (group), T (TLS),
  C (compressed), x (unknown), o (OS specific), E (exclude),
  y (purecode), p (processor specific)


I'm also tracking this problem on the crosstool-ng issue tracker[2] there is a
little bit more info there. I'll try to keep these two issues in sync so no
need to follow the link.

For completeness here's the output with the -v flag passed to GCC.

x-tool@063c4281c760:~$ rm -f test test.o; make CC=arm-unknown-linux-gnueabi-gcc
CFLAGS=-v test
arm-unknown-linux-gnueabi-gcc -v    test.c   -o test
Using built-in specs.
COLLECT_GCC=arm-unknown-linux-gnueabi-gcc
COLLECT_LTO_WRAPPER=/home/x-tool/x-tools/arm-unknown-linux-gnueabi/libexec/gcc/arm-unknown-linux-gnueabi/11.1.0/lto-wrapper
Target: arm-unknown-linux-gnueabi
Configured with:
/home/x-tool/.build/arm-unknown-linux-gnueabi/src/gcc/configure
--build=x86_64-build_pc-linux-gnu --host=x86_64-build_pc-linux-gnu
--target=arm-unknown-linux-gnueabi
--prefix=/home/x-tool/x-tools/arm-unknown-linux-gnueabi
--exec_prefix=/home/x-tool/x-tools/arm-unknown-linux-gnueabi
--with-sysroot=/home/x-tool/x-tools/arm-unknown-linux-gnueabi/arm-unknown-linux-gnueabi/sysroot
--enable-languages=c,c++ --with-float=soft --with-pkgversion='crosstool-NG
1.24.0.373_5ab29fb' --disable-sjlj-exceptions --enable-__cxa_atexit
--disable-tm-clone-registry --disable-libmudflap --disable-libgomp
--disable-libssp --disable-libquadmath --disable-libquadmath-support
--disable-libsanitizer --disable-libmpx
--with-gmp=/home/x-tool/.build/arm-unknown-linux-gnueabi/buildtools
--with-mpfr=/home/x-tool/.build/arm-unknown-linux-gnueabi/buildtools
--with-mpc=/home/x-tool/.build/arm-unknown-linux-gnueabi/buildtools
--with-isl=/home/x-tool/.build/arm-unknown-linux-gnueabi/buildtools
--enable-lto --with-host-libstdcxx='-static-libgcc
-Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --enable-threads=posix
--enable-target-optspace --enable-plugin --enable-gold --disable-nls
--disable-multilib
--with-local-prefix=/home/x-tool/x-tools/arm-unknown-linux-gnueabi/arm-unknown-linux-gnueabi/sysroot
--enable-long-long
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.1.0 (crosstool-NG 1.24.0.373_5ab29fb) 
COLLECT_GCC_OPTIONS='-v' '-o' 'test' '-mcpu=arm10tdmi' '-mfloat-abi=soft'
'-mtls-dialect=gnu' '-marm' '-march=armv5t'

/home/x-tool/x-tools/arm-unknown-linux-gnueabi/libexec/gcc/arm-unknown-linux-gnueabi/11.1.0/cc1
-quiet -v test.c -quiet -dumpbase test.c -dumpbase-ext .c -mcpu=arm10tdmi
-mfloat-abi=soft -mtls-dialect=gnu -marm -march=armv5t -version -o
/tmp/cc4QsweE.s
GNU C17 (crosstool-NG 1.24.0.373_5ab29fb) version 11.1.0
(arm-unknown-linux-gnueabi)
        compiled by GNU C version 8.3.0, GMP version 6.2.1, MPFR version 4.1.0,
MPC version 1.2.0, isl version isl-0.24-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory
"/home/x-tool/x-tools/arm-unknown-linux-gnueabi/arm-unknown-linux-gnueabi/sysroot/home/x-tool/x-tools/arm-unknown-linux-gnueabi/arm-unknown-linux-gnueabi/sysroot/include"
#include "..." search starts here:
#include <...> search starts here:

/home/x-tool/x-tools/arm-unknown-linux-gnueabi/lib/gcc/arm-unknown-linux-gnueabi/11.1.0/include

/home/x-tool/x-tools/arm-unknown-linux-gnueabi/lib/gcc/arm-unknown-linux-gnueabi/11.1.0/include-fixed

/home/x-tool/x-tools/arm-unknown-linux-gnueabi/lib/gcc/arm-unknown-linux-gnueabi/11.1.0/../../../../arm-unknown-linux-gnueabi/include

/home/x-tool/x-tools/arm-unknown-linux-gnueabi/arm-unknown-linux-gnueabi/sysroot/usr/include
End of search list.
GNU C17 (crosstool-NG 1.24.0.373_5ab29fb) version 11.1.0
(arm-unknown-linux-gnueabi)
        compiled by GNU C version 8.3.0, GMP version 6.2.1, MPFR version 4.1.0,
MPC version 1.2.0, isl version isl-0.24-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: e9288bd94a72e0d2532aee1fd8ebe463
COLLECT_GCC_OPTIONS='-v' '-o' 'test' '-mcpu=arm10tdmi' '-mfloat-abi=soft'
'-mtls-dialect=gnu' '-marm' '-march=armv5t'

/home/x-tool/x-tools/arm-unknown-linux-gnueabi/lib/gcc/arm-unknown-linux-gnueabi/11.1.0/../../../../arm-unknown-linux-gnueabi/bin/as
-v -march=armv5t -mfloat-abi=soft -meabi=5 -o /tmp/ccjAz6OZ.o /tmp/cc4QsweE.s
GNU assembler version 2.36.1 (arm-unknown-linux-gnueabi) using BFD version
(crosstool-NG 1.24.0.373_5ab29fb) 2.36.1
COMPILER_PATH=/home/x-tool/x-tools/arm-unknown-linux-gnueabi/libexec/gcc/arm-unknown-linux-gnueabi/11.1.0/:/home/x-tool/x-tools/arm-unknown-linux-gnueabi/libexec/gcc/arm-unknown-linux-gnueabi/11.1.0/:/home/x-tool/x-tools/arm-unknown-linux-gnueabi/libexec/gcc/arm-unknown-linux-gnueabi/:/home/x-tool/x-tools/arm-unknown-linux-gnueabi/lib/gcc/arm-unknown-linux-gnueabi/11.1.0/:/home/x-tool/x-tools/arm-unknown-linux-gnueabi/lib/gcc/arm-unknown-linux-gnueabi/:/home/x-tool/x-tools/arm-unknown-linux-gnueabi/lib/gcc/arm-unknown-linux-gnueabi/11.1.0/../../../../arm-unknown-linux-gnueabi/bin/
LIBRARY_PATH=/home/x-tool/x-tools/arm-unknown-linux-gnueabi/lib/gcc/arm-unknown-linux-gnueabi/11.1.0/:/home/x-tool/x-tools/arm-unknown-linux-gnueabi/lib/gcc/arm-unknown-linux-gnueabi/11.1.0/../../../../arm-unknown-linux-gnueabi/lib/:/home/x-tool/x-tools/arm-unknown-linux-gnueabi/arm-unknown-linux-gnueabi/sysroot/lib/:/home/x-tool/x-tools/arm-unknown-linux-gnueabi/arm-unknown-linux-gnueabi/sysroot/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-o' 'test' '-mcpu=arm10tdmi' '-mfloat-abi=soft'
'-mtls-dialect=gnu' '-marm' '-march=armv5t' '-dumpdir' 'test.'

/home/x-tool/x-tools/arm-unknown-linux-gnueabi/libexec/gcc/arm-unknown-linux-gnueabi/11.1.0/collect2
-plugin
/home/x-tool/x-tools/arm-unknown-linux-gnueabi/libexec/gcc/arm-unknown-linux-gnueabi/11.1.0/liblto_plugin.so
-plugin-opt=/home/x-tool/x-tools/arm-unknown-linux-gnueabi/libexec/gcc/arm-unknown-linux-gnueabi/11.1.0/lto-wrapper
-plugin-opt=-fresolution=/tmp/ccUgJcql.res -plugin-opt=-pass-through=-lgcc
-plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc
-plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s
--sysroot=/home/x-tool/x-tools/arm-unknown-linux-gnueabi/arm-unknown-linux-gnueabi/sysroot
--eh-frame-hdr -dynamic-linker /lib/ld-linux.so.3 -X -m armelf_linux_eabi -o
test
/home/x-tool/x-tools/arm-unknown-linux-gnueabi/arm-unknown-linux-gnueabi/sysroot/usr/lib/crt1.o
/home/x-tool/x-tools/arm-unknown-linux-gnueabi/arm-unknown-linux-gnueabi/sysroot/usr/lib/crti.o
/home/x-tool/x-tools/arm-unknown-linux-gnueabi/lib/gcc/arm-unknown-linux-gnueabi/11.1.0/crtbegin.o
-L/home/x-tool/x-tools/arm-unknown-linux-gnueabi/lib/gcc/arm-unknown-linux-gnueabi/11.1.0
-L/home/x-tool/x-tools/arm-unknown-linux-gnueabi/lib/gcc/arm-unknown-linux-gnueabi/11.1.0/../../../../arm-unknown-linux-gnueabi/lib
-L/home/x-tool/x-tools/arm-unknown-linux-gnueabi/arm-unknown-linux-gnueabi/sysroot/lib
-L/home/x-tool/x-tools/arm-unknown-linux-gnueabi/arm-unknown-linux-gnueabi/sysroot/usr/lib
/tmp/ccjAz6OZ.o -lgcc --push-state --as-needed -lgcc_s --pop-state -lc -lgcc
--push-state --as-needed -lgcc_s --pop-state
/home/x-tool/x-tools/arm-unknown-linux-gnueabi/lib/gcc/arm-unknown-linux-gnueabi/11.1.0/crtend.o
/home/x-tool/x-tools/arm-unknown-linux-gnueabi/arm-unknown-linux-gnueabi/sysroot/usr/lib/crtn.o
/home/x-tool/x-tools/arm-unknown-linux-gnueabi/lib/gcc/arm-unknown-linux-gnueabi/11.1.0/../../../../arm-unknown-linux-gnueabi/bin/ld.bfd:
warning: .init_array section has zero size
/home/x-tool/x-tools/arm-unknown-linux-gnueabi/lib/gcc/arm-unknown-linux-gnueabi/11.1.0/../../../../arm-unknown-linux-gnueabi/bin/ld.bfd:
warning: .fini_array section has zero size
COLLECT_GCC_OPTIONS='-v' '-o' 'test' '-mcpu=arm10tdmi' '-mfloat-abi=soft'
'-mtls-dialect=gnu' '-marm' '-march=armv5t' '-dumpdir' 'test.'

--
[1] - https://sourceware.org/pipermail/binutils/2021-June/116962.html
[2] - https://github.com/crosstool-ng/crosstool-ng/issues/1531

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug target/101115] ld.bfd: warning: .init_array section has zero size
  2021-06-18  3:15 [Bug other/101115] New: ld.bfd: warning: .init_array section has zero size judge.packham at gmail dot com
@ 2021-06-18  3:31 ` pinskia at gcc dot gnu.org
  2021-06-18  4:31 ` judge.packham at gmail dot com
  2021-06-19 23:17 ` judge.packham at gmail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-06-18  3:31 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Try adding --enable-initfini-array to gcc config

Most likely GCC config is not detecting .init_array/.fini_array support which
is now always turned on the trunk for *linux-* targets.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug target/101115] ld.bfd: warning: .init_array section has zero size
  2021-06-18  3:15 [Bug other/101115] New: ld.bfd: warning: .init_array section has zero size judge.packham at gmail dot com
  2021-06-18  3:31 ` [Bug target/101115] " pinskia at gcc dot gnu.org
@ 2021-06-18  4:31 ` judge.packham at gmail dot com
  2021-06-19 23:17 ` judge.packham at gmail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: judge.packham at gmail dot com @ 2021-06-18  4:31 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Chris Packham <judge.packham at gmail dot com> ---
(In reply to Andrew Pinski from comment #1)
> Try adding --enable-initfini-array to gcc config
> 
> Most likely GCC config is not detecting .init_array/.fini_array support
> which is now always turned on the trunk for *linux-* targets.

Yes that does the trick. I'll work on plumbing that into ct-ng when building
GCC 10 or GCC 11.

Any idea how that will interact with the non-GNU libcs (specifically musl and
uClibc)?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug target/101115] ld.bfd: warning: .init_array section has zero size
  2021-06-18  3:15 [Bug other/101115] New: ld.bfd: warning: .init_array section has zero size judge.packham at gmail dot com
  2021-06-18  3:31 ` [Bug target/101115] " pinskia at gcc dot gnu.org
  2021-06-18  4:31 ` judge.packham at gmail dot com
@ 2021-06-19 23:17 ` judge.packham at gmail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: judge.packham at gmail dot com @ 2021-06-19 23:17 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Chris Packham <judge.packham at gmail dot com> ---
An update[1]. It seems that --disable-tm-clone-registry is the option that
results in crtbegin.o having a zero sized .init_array. I can't really follow
crcstuff.c but I see USE_TM_CLONE_REGISTRY in the context of .init_array so
something is happening when tm-clone-registry is disabled.

[1] - https://sourceware.org/pipermail/binutils/2021-June/117066.html

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-06-19 23:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-18  3:15 [Bug other/101115] New: ld.bfd: warning: .init_array section has zero size judge.packham at gmail dot com
2021-06-18  3:31 ` [Bug target/101115] " pinskia at gcc dot gnu.org
2021-06-18  4:31 ` judge.packham at gmail dot com
2021-06-19 23:17 ` judge.packham at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).