aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2004-05-26 10:23:51 +0000
committerAlan Modra <amodra@gmail.com>2004-05-26 10:23:51 +0000
commite49f502242bc5fc72547397cd344aea5b9f53a14 (patch)
treeae210021072a6f2ccbcc28338697c52a865fb43c /ld
parentc23968a21823bf856b9876dcf30483dc26c1a650 (diff)
downloadgdb-e49f502242bc5fc72547397cd344aea5b9f53a14.zip
gdb-e49f502242bc5fc72547397cd344aea5b9f53a14.tar.gz
gdb-e49f502242bc5fc72547397cd344aea5b9f53a14.tar.bz2
bfd/
* elf.c (_bfd_elf_make_section_from_shdr): Don't set SEC_EXCLUDE for SHT_GROUP sections. ld/ * ldlang.c (lang_add_section): Set SEC_EXCLUDE for SEC_GROUP sections when doing a final link. Clear SEC_EXCLUDE when doing a relocable link, except for SEC_DEBUGGING sections. * emultempl/elf32.em (gld${EMULATION_NAME}_place_orphan): Use the same condition here to drop SEC_EXCLUDE orphan sections.
Diffstat (limited to 'ld')
-rw-r--r--ld/ChangeLog8
-rw-r--r--ld/emultempl/elf32.em4
-rw-r--r--ld/ldlang.c25
3 files changed, 31 insertions, 6 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index d923216..6c34103 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,11 @@
+2004-05-26 Alan Modra <amodra@bigpond.net.au>
+
+ * ldlang.c (lang_add_section): Set SEC_EXCLUDE for SEC_GROUP
+ sections when doing a final link. Clear SEC_EXCLUDE when doing
+ a relocable link, except for SEC_DEBUGGING sections.
+ * emultempl/elf32.em (gld${EMULATION_NAME}_place_orphan): Use the
+ same condition here to drop SEC_EXCLUDE orphan sections.
+
2004-05-25 Alan Modra <amodra@bigpond.net.au>
* ldlang.c (lang_process): Call bfd_merge_sections later, and
diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em
index cf002e5..89c5d5d 100644
--- a/ld/emultempl/elf32.em
+++ b/ld/emultempl/elf32.em
@@ -1182,7 +1182,9 @@ gld${EMULATION_NAME}_place_orphan (lang_input_statement_type *file, asection *s)
#define HAVE_SECTION(hold, name) \
(hold.os != NULL || (hold.os = lang_output_section_find (name)) != NULL)
- if ((s->flags & SEC_EXCLUDE) != 0 && !link_info.relocatable)
+ if (((s->flags & (SEC_EXCLUDE | SEC_GROUP)) != 0 && !link_info.relocatable)
+ || ((s->flags & (SEC_EXCLUDE | SEC_DEBUGGING))
+ == (SEC_EXCLUDE | SEC_DEBUGGING)))
{
if (s->output_section == NULL)
s->output_section = bfd_abs_section_ptr;
diff --git a/ld/ldlang.c b/ld/ldlang.c
index 7a268c0..34cff0f 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -1096,11 +1096,26 @@ lang_add_section (lang_statement_list_type *ptr,
discard = FALSE;
- /* Discard sections marked with SEC_EXCLUDE if we are doing a final
- link. Discard debugging sections marked with SEC_EXCLUDE on a
- relocatable link too. */
- if ((flags & SEC_EXCLUDE) != 0
- && ((flags & SEC_DEBUGGING) != 0 || !link_info.relocatable))
+ if (link_info.relocatable)
+ {
+ /* SEC_EXCLUDE is ignored when doing a relocatable link,
+ except in the special case of debug info. (See bfd/stabs.c) */
+ if ((flags & SEC_DEBUGGING) == 0)
+ flags &= ~SEC_EXCLUDE;
+ }
+ else
+ {
+ /* SEC_GROUP sections should be dropped on a final link. */
+ if ((flags & SEC_GROUP) != 0)
+ flags |= SEC_EXCLUDE;
+ }
+
+ /* Write SEC_EXCLUDE flag back, to simplify later linker code. */
+ if (section->owner != NULL)
+ bfd_set_section_flags (section->owner, section, flags);
+
+ /* Discard sections marked with SEC_EXCLUDE. */
+ if ((flags & SEC_EXCLUDE) != 0)
discard = TRUE;
/* Discard input sections which are assigned to a section named