* 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.
This commit is contained in:
Alan Modra 2002-09-30 03:34:46 +00:00
parent 52575520c3
commit ba49312244
2 changed files with 36 additions and 27 deletions

View file

@ -1,3 +1,10 @@
2002-09-30 Alan Modra <amodra@bigpond.net.au>
* 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 <hjl@gnu.org>
* ld/emulparams/elf32ppc.sh (OTHER_GOT_RELOC_SECTIONS): New.

View file

@ -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;