aboutsummaryrefslogtreecommitdiff
path: root/ld/emultempl
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2005-10-15 14:57:55 +0000
committerH.J. Lu <hjl.tools@gmail.com>2005-10-15 14:57:55 +0000
commitecca98713a19ac7aac31886b4b15b806e63d9a99 (patch)
tree8606d4daeccd04e698371f934ba62278dd283d25 /ld/emultempl
parentff0929e51c0e9c26e0cf1e6b7229803ccd7cc769 (diff)
downloadgdb-ecca98713a19ac7aac31886b4b15b806e63d9a99.zip
gdb-ecca98713a19ac7aac31886b4b15b806e63d9a99.tar.gz
gdb-ecca98713a19ac7aac31886b4b15b806e63d9a99.tar.bz2
bfd/
2005-10-15 H.J. Lu <hongjiu.lu@intel.com> PR ld/1467 * elf-bfd.h (_bfd_elf_match_sections_by_type): New. (_bfd_generic_match_sections_by_type): New. Defined. * elf.c (_bfd_elf_match_sections_by_type): New. * libbfd-in.h (_bfd_generic_match_sections_by_type): New. * bfd-in2.h: Regenerated. * libbfd.h: Likewise. * libbfd.c (_bfd_generic_match_sections_by_type): New. * targets.c (BFD_JUMP_TABLE_LINK): Initialize _bfd_match_sections_by_type with _bfd_generic_match_sections_by_type. (bfd_target): Add _bfd_match_sections_by_type. ld/ 2005-10-15 H.J. Lu <hongjiu.lu@intel.com> PR ld/1467 * emultempl/elf32.em: Include "elf-bfd.h". (gld${EMULATION_NAME}_place_orphan): Check section type and don't use section name for ELF input sections. * ld.texinfo: Document orphan section processing. * ldlang.c (lang_output_section_find_by_flags): Match section types by calling bfd_match_sections_by_type.
Diffstat (limited to 'ld/emultempl')
-rw-r--r--ld/emultempl/elf32.em42
1 files changed, 31 insertions, 11 deletions
diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em
index 15d2722..e1e37f1 100644
--- a/ld/emultempl/elf32.em
+++ b/ld/emultempl/elf32.em
@@ -53,6 +53,7 @@ Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
#include "ldemul.h"
#include <ldgram.h>
#include "elf/common.h"
+#include "elf-bfd.h"
/* Declare functions used by various EXTRA_EM_FILEs. */
static void gld${EMULATION_NAME}_before_parse (void);
@@ -1324,19 +1325,34 @@ gld${EMULATION_NAME}_place_orphan (lang_input_statement_type *file, asection *s)
lang_output_section_statement_type *after;
lang_output_section_statement_type *os;
int isdyn = 0;
+ int iself = s->owner->xvec->flavour == bfd_target_elf_flavour;
+ unsigned int sh_type = iself ? elf_section_type (s) : SHT_NULL;
secname = bfd_get_section_name (s->owner, s);
if (! link_info.relocatable
&& link_info.combreloc
- && (s->flags & SEC_ALLOC)
- && strncmp (secname, ".rel", 4) == 0)
+ && (s->flags & SEC_ALLOC))
{
- if (secname[4] == 'a')
- secname = ".rela.dyn";
- else
- secname = ".rel.dyn";
- isdyn = 1;
+ if (iself)
+ switch (sh_type)
+ {
+ case SHT_RELA:
+ secname = ".rela.dyn";
+ isdyn = 1;
+ break;
+ case SHT_REL:
+ secname = ".rel.dyn";
+ isdyn = 1;
+ break;
+ default:
+ break;
+ }
+ else if (strncmp (secname, ".rel", 4) == 0)
+ {
+ secname = secname[4] == 'a' ? ".rela.dyn" : ".rel.dyn";
+ isdyn = 1;
+ }
}
if (isdyn || (!config.unique_orphan_sections && !unique_section_p (s)))
@@ -1347,8 +1363,10 @@ gld${EMULATION_NAME}_place_orphan (lang_input_statement_type *file, asection *s)
if (os != NULL
&& (os->bfd_section == NULL
|| os->bfd_section->flags == 0
- || ((s->flags ^ os->bfd_section->flags)
- & (SEC_LOAD | SEC_ALLOC)) == 0))
+ || ((!iself
+ || sh_type == elf_section_type (os->bfd_section))
+ && ((s->flags ^ os->bfd_section->flags)
+ & (SEC_LOAD | SEC_ALLOC)) == 0)))
{
/* We already have an output section statement with this
name, and its bfd section, if any, has compatible flags.
@@ -1395,7 +1413,8 @@ gld${EMULATION_NAME}_place_orphan (lang_input_statement_type *file, asection *s)
if ((s->flags & SEC_ALLOC) == 0)
;
else if ((s->flags & SEC_LOAD) != 0
- && strncmp (secname, ".note", 5) == 0)
+ && ((iself && sh_type == SHT_NOTE)
+ || (!iself && strncmp (secname, ".note", 5) == 0)))
place = &hold[orphan_interp];
else if ((s->flags & (SEC_LOAD | SEC_HAS_CONTENTS)) == 0)
place = &hold[orphan_bss];
@@ -1403,7 +1422,8 @@ gld${EMULATION_NAME}_place_orphan (lang_input_statement_type *file, asection *s)
place = &hold[orphan_sdata];
else if ((s->flags & SEC_READONLY) == 0)
place = &hold[orphan_data];
- else if (strncmp (secname, ".rel", 4) == 0
+ else if (((iself && (sh_type == SHT_RELA || sh_type == SHT_REL))
+ || (!iself && strncmp (secname, ".rel", 4) == 0))
&& (s->flags & SEC_LOAD) != 0)
place = &hold[orphan_rel];
else if ((s->flags & SEC_CODE) == 0)