On Sat, May 7, 2011 at 1:10 AM, Alan Modra wrote: > On Fri, May 06, 2011 at 09:16:20AM -0700, H.J. Lu wrote: >> How about this patch? > > Much better, thanks.  But, > >>       * elf.c (_bfd_elf_section_reloc_offset): New. > > why not put your changes in _bfd_elf_section_offset? > >>       * elf64-x86-64.c (elf_x86_64_relocate_section): Call >>       _bfd_elf_section_reloc_offset instead of >>       _bfd_elf_section_offset. >>       * elfxx-ia64.c (elfNN_ia64_install_dyn_reloc): Likewise. > > The world is more than just Intel..  Every other ELF target will need > the same as you've done for x86_64 and ia64, and it would be better to > reverse relocs even for REL targets just in case you have a reloc > against a global sym. > >> +       /* We need to reverse-copy input .ctors/.dtors sections if >> +          they are placed in .init_array/.finit_array for output.  */ >> +       if (o->size > address_size >> +           && ((strcmp (o->name, ".ctors") == 0 > > strncmp (o->name, ".ctors", 6) == 0 > && (o->name[6] == 0 || o->name[6] == '.') > > Ditto for dtors, or explain to me why not.  Seems to me that .ctors.nn > section could possibly have more than one constructor. > Here is the updated patch. OK to install? Thanks. -- H.J. --- bfd/ 2011-05-07 H.J. Lu PR ld/12730 * elf.c (_bfd_elf_section_offset): Check SEC_ELF_REVERSE_COPY. * elflink.c (elf_link_input_bfd): Reverse copy .ctors/.dtors sections if needed. * section.c (SEC_ELF_REVERSE_COPY): New. * bfd-in2.h: Regenerated. ld/testsuite/ 2011-05-07 H.J. Lu PR ld/12730 * ld-elf/elf.exp (array_tests): Add "pr12730". (array_tests_pie): New. (array_tests_static): Add -static for ""static init array mixed". Add "static pr12730". Run array_tests_pie for Linux. * ld-elf/init-mixed.c (ctor1007): Renamed to ... (ctor1007a): This. (ctor1007b): New. (ctors1007): Remove ctor1007. Add ctor1007b and ctor1007a. (dtor1007): Renamed to ... (dtor1007a): This. (dtor1007b): New. (dtors1007): Remove dtor1007. Add dtor1007b and dtor1007a. (ctor65535): Renamed to ... (ctor65535a): This. (ctor65535b): New. (ctors65535): Remove ctor65535. Add ctor65535b and ctor65535a. (dtor65535): Renamed to ... (dtor65535a): This. (dtor65535b): New. (dtors65535): Remove dtor65535. Add dtor65535b and dtor65535a. * ld-elf/pr12730.cc: New. * ld-elf/pr12730.out: Likewise.