From: Alan Modra Date: Mon, 30 Sep 2002 03:34:46 +0000 (+0000) Subject: * emultempl/elf32.em (output_rel_find): Always place orphan loadable X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ba49312244a0a0dab1f20e539069a72a3448ae50;p=binutils-gdb.git * emultempl/elf32.em (output_rel_find): Always place orphan loadable reloc sections just before .rel.plt/.rela.plt. (gld${EMULATION_NAME}_place_orphan <.rel>): Remove combreloc code. Only put loadable reloc sections in hold_rel. --- diff --git a/ld/ChangeLog b/ld/ChangeLog index 6bbe1effefc..8cba873e282 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,10 @@ +2002-09-30 Alan Modra + + * emultempl/elf32.em (output_rel_find): Always place orphan loadable + reloc sections just before .rel.plt/.rela.plt. + (gld${EMULATION_NAME}_place_orphan <.rel>): Remove combreloc code. + Only put loadable reloc sections in hold_rel. + 2002-09-29 H.J. Lu * ld/emulparams/elf32ppc.sh (OTHER_GOT_RELOC_SECTIONS): New. diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em index 26e4c46297f..7f8637483bd 100644 --- a/ld/emultempl/elf32.em +++ b/ld/emultempl/elf32.em @@ -1000,20 +1000,39 @@ output_rel_find () { lang_statement_union_type *u; lang_output_section_statement_type *lookup; + lang_output_section_statement_type *last = NULL; + lang_output_section_statement_type *last_rel = NULL; + lang_output_section_statement_type *last_rel_alloc = NULL; - for (u = lang_output_section_statement.head; - u != (lang_statement_union_type *) NULL; - u = lookup->next) + for (u = lang_output_section_statement.head; u; u = lookup->next) { lookup = &u->output_section_statement; - if (strncmp (".rel", lookup->name, 4) == 0 - && lookup->bfd_section != NULL - && (lookup->bfd_section->flags & SEC_ALLOC) != 0) + if (strncmp (".rel", lookup->name, 4) == 0) { - return lookup; + /* Don't place after .rel.plt as doing so results in wrong + dynamic tags. Also, place allocated reloc sections before + non-allocated. */ + int rela = lookup->name[4] == 'a'; + + if (strcmp (".plt", lookup->name + 4 + rela) == 0 + || (lookup->bfd_section != NULL + && (lookup->bfd_section->flags & SEC_ALLOC) == 0)) + break; + last_rel = lookup; + if (lookup->bfd_section != NULL + && (lookup->bfd_section->flags & SEC_ALLOC) != 0) + last_rel_alloc = lookup; } + last = lookup; } - return (lang_output_section_statement_type *) NULL; + + if (last_rel_alloc) + return last_rel_alloc; + + if (last_rel) + return last_rel; + + return last; } /* Find the last output section before given output statement. @@ -1138,27 +1157,10 @@ gld${EMULATION_NAME}_place_orphan (file, s) && HAVE_SECTION (hold_data, ".data")) place = &hold_data; else if (strncmp (secname, ".rel", 4) == 0 + && (s->flags & SEC_LOAD) != 0 && (hold_rel.os != NULL || (hold_rel.os = output_rel_find ()) != NULL)) - { - if (! link_info.relocateable && link_info.combreloc) - { - if (strncmp (secname, ".rela", 5) == 0) - os = lang_output_section_find (".rela.dyn"); - else - os = lang_output_section_find (".rel.dyn"); - - if (os != NULL - && os->bfd_section != NULL - && ((s->flags ^ os->bfd_section->flags) - & (SEC_LOAD | SEC_ALLOC)) == 0) - { - lang_add_section (&os->children, s, os, file); - return true; - } - } - place = &hold_rel; - } + place = &hold_rel; else if ((s->flags & (SEC_CODE | SEC_READONLY)) == SEC_READONLY && HAVE_SECTION (hold_rodata, ".rodata")) place = &hold_rodata;