From 9f61903d7388315e3d7b83a7e7c5ce1e30ab5ed3 Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Fri, 23 Jul 2004 16:32:53 +0000 Subject: [PATCH] (_place_orphan): Use an already existing section name if that section does not have any flags set. --- ld/ChangeLog | 5 +++++ ld/emultempl/elf32.em | 10 ++++++++-- ld/ldlang.c | 1 + 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/ld/ChangeLog b/ld/ChangeLog index 25aa0a05a94..16ff5a6ec06 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,8 @@ +2004-07-23 Nick Clifton + + * emultempl/elf32.em (_place_orphan): Use an already existing + section name if that section does not have any flags set. + 2004-07-21 H.J. Lu * ldlang.c (already_linked_hash_entry): Removed. diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em index 469f0540f4f..1956fd545dd 100644 --- a/ld/emultempl/elf32.em +++ b/ld/emultempl/elf32.em @@ -1175,8 +1175,10 @@ gld${EMULATION_NAME}_place_orphan (lang_input_statement_type *file, asection *s) lang_statement_union_type **os_tail; etree_type *load_base; int isdyn = 0; + asection *sec; secname = bfd_get_section_name (s->owner, s); + if (! link_info.relocatable && link_info.combreloc && (s->flags & SEC_ALLOC) @@ -1260,8 +1262,12 @@ gld${EMULATION_NAME}_place_orphan (lang_input_statement_type *file, asection *s) /* Choose a unique name for the section. This will be needed if the same section name appears in the input file with different - loadable or allocatable characteristics. */ - if (bfd_get_section_by_name (output_bfd, secname) != NULL) + loadable or allocatable characteristics. But if the section + already exists but does not have any flags set, then it has been + been created by the linker, probably as a result of a --section-start + command line switch. */ + if ((sec = bfd_get_section_by_name (output_bfd, secname)) != NULL + && bfd_get_section_flags (output_bfd, sec) != 0) { secname = bfd_get_unique_section_name (output_bfd, secname, &count); if (secname == NULL) diff --git a/ld/ldlang.c b/ld/ldlang.c index 6cc05a67cf2..8c6ebaf3c80 100644 --- a/ld/ldlang.c +++ b/ld/ldlang.c @@ -612,6 +612,7 @@ lang_output_section_find_1 (const char *const name, int constraint) for (u = lang_output_section_statement.head; u != NULL; u = lookup->next) { lookup = &u->output_section_statement; + if (strcmp (name, lookup->name) == 0 && lookup->constraint != -1 && (constraint == 0 || constraint == lookup->constraint)) -- 2.30.2