ld will copy .ctors section from the input files to .init_array section in the output file. .ctors section should start with 0xffffffffffffffff and end with 0x0000000000000000. But .init_array shouldn't have these and should have it's size explicitly specified somewhere. So if we link some files with .ctors sections, the .init_array section in the output file will contain some 0xffffffffffffffff entries. (As is observed in ld 2.30.51) And when ld.so loads the output file, it will segfault when calling the 0xffffffffffffffff entries in .init_array. In order not to segfault, we must 1) filter out 0xffffffffffffffff entries when ld copies the .ctors section to .init_array section or 2) tell ld.so to ignore the 0xffffffffffffffff entries in .init_array. (I think ld.so is in glibc, so should I report this to glibc or binutils?)
The input .ctors sections should never contain begin and end markers, except for the fragments from crtbegin.o/crtend.o (which are explicitly excluded).
(In reply to Andreas Schwab from comment #2) > The input .ctors sections should never contain begin and end markers, except > for the fragments from crtbegin.o/crtend.o (which are explicitly excluded). Thanks a lot! I'm compiling glibc, and they use soinit.os/sofini.os instead of crtbegin.o/crtend.o. So I think filtering out them manually would solve my problem. This is discussed before at https://binutils.sourceware.narkive.com/oqywJAtY/binutils-2-21-51-0-2-fails-to-build-glibc, but the discussion hard to find... This is a duplicate of 12379, but nothing useful can be found on that page... *** This bug has been marked as a duplicate of bug 12379 ***