From a14a5de357808faa8a25d1eff69454a8c0dca8d8 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Fri, 27 Oct 2006 03:22:09 +0000 Subject: [PATCH] bfd/ * section.c (SEC_KEEP): Update comment. * bfd-in2.h: Regenerate. * elflink.c (bfd_elf_gc_sections): Ignore SEC_EXCLUDE sections. * merge.c (_bfd_merge_sections): Set SEC_KEEP on excluded sections. * stabs.c (_bfd_discard_section_stabs): Likewise. (_bfd_link_section_stabs): Likewise. Simplify abs_section check. ld/ * ldlang.c (lang_map): Don't say SEC_LINKER_CREATED and SEC_KEEP sections have been discarded. (lang_do_version_exports_section): Set SEC_KEEP on export section. * emultempl/elf32.em (before_allocation): Set SEC_KEEP on warning sections. --- bfd/ChangeLog | 11 ++++++++++- bfd/bfd-in2.h | 4 +++- bfd/elflink.c | 2 +- bfd/merge.c | 2 +- bfd/section.c | 4 +++- bfd/stabs.c | 14 ++++++-------- ld/ChangeLog | 8 ++++++++ ld/emultempl/elf32.em | 2 +- ld/ldlang.c | 9 +++++---- 9 files changed, 38 insertions(+), 18 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 2d418333e65..1f8d8f090bb 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,12 @@ +2006-10-27 Alan Modra + + * section.c (SEC_KEEP): Update comment. + * bfd-in2.h: Regenerate. + * elflink.c (bfd_elf_gc_sections): Ignore SEC_EXCLUDE sections. + * merge.c (_bfd_merge_sections): Set SEC_KEEP on excluded sections. + * stabs.c (_bfd_discard_section_stabs): Likewise. + (_bfd_link_section_stabs): Likewise. Simplify abs_section check. + 2006-10-26 Ben Elliston * reloc.c (_bfd_relocate_contents): Remove explicit case 0. @@ -12,7 +21,7 @@ (maxq_reloc_map): Likewise. (maxq_reloc_type_lookup): Remove loop over maxq_reloc_map. -2006-10-26 Ben Elliston +2006-10-26 Ben Elliston * elf.c (bfd_elf_set_dyn_lib_class): Change second argument type from int to enum dynamic_lib_link_class lib_class. diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index 813d748be97..9b561ad9c13 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -1255,7 +1255,9 @@ typedef struct bfd_section else up the line will take care of it later. */ #define SEC_LINKER_CREATED 0x200000 - /* This section should not be subject to garbage collection. */ + /* This section should not be subject to garbage collection. + Also set to inform the linker that this section should not be + listed in the link map as discarded. */ #define SEC_KEEP 0x400000 /* This section contains "short" data, and should be placed diff --git a/bfd/elflink.c b/bfd/elflink.c index 34816fac9a3..1dad5047727 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -9794,7 +9794,7 @@ bfd_elf_gc_sections (bfd *abfd, struct bfd_link_info *info) continue; for (o = sub->sections; o != NULL; o = o->next) - if ((o->flags & SEC_KEEP) != 0 && !o->gc_mark) + if ((o->flags & (SEC_EXCLUDE | SEC_KEEP)) == SEC_KEEP && !o->gc_mark) if (!_bfd_elf_gc_mark (info, o, gc_mark_hook)) return FALSE; } diff --git a/bfd/merge.c b/bfd/merge.c index c1795d29112..577a716002e 100644 --- a/bfd/merge.c +++ b/bfd/merge.c @@ -766,7 +766,7 @@ _bfd_merge_sections (bfd *abfd ATTRIBUTE_UNUSED, the hash table at all. */ for (secinfo = sinfo->chain; secinfo; secinfo = secinfo->next) if (secinfo->first_str == NULL) - secinfo->sec->flags |= SEC_EXCLUDE; + secinfo->sec->flags |= SEC_EXCLUDE | SEC_KEEP; } return TRUE; diff --git a/bfd/section.c b/bfd/section.c index 2b5f7f8df72..5a100be517f 100644 --- a/bfd/section.c +++ b/bfd/section.c @@ -294,7 +294,9 @@ CODE_FRAGMENT . else up the line will take care of it later. *} .#define SEC_LINKER_CREATED 0x200000 . -. {* This section should not be subject to garbage collection. *} +. {* This section should not be subject to garbage collection. +. Also set to inform the linker that this section should not be +. listed in the link map as discarded. *} .#define SEC_KEEP 0x400000 . . {* This section contains "short" data, and should be placed diff --git a/bfd/stabs.c b/bfd/stabs.c index 4f48e8e8eff..93ab0a68861 100644 --- a/bfd/stabs.c +++ b/bfd/stabs.c @@ -175,10 +175,8 @@ _bfd_link_section_stabs (bfd *abfd, prepared to handle them. */ return TRUE; - if ((stabsec->output_section != NULL - && bfd_is_abs_section (stabsec->output_section)) - || (stabstrsec->output_section != NULL - && bfd_is_abs_section (stabstrsec->output_section))) + if (bfd_is_abs_section (stabsec->output_section) + || bfd_is_abs_section (stabstrsec->output_section)) /* At least one of the sections is being discarded from the link, so we should just ignore them. */ return TRUE; @@ -433,7 +431,7 @@ _bfd_link_section_stabs (bfd *abfd, ++nest; else if (incl_type == (int) N_EXCL) /* Keep existing exclusion marks. */ - continue; + continue; else if (nest == 0) { *incl_pstridx = (bfd_size_type) -1; @@ -458,8 +456,8 @@ _bfd_link_section_stabs (bfd *abfd, for that section. */ stabsec->size = (count - skip) * STABSIZE; if (stabsec->size == 0) - stabsec->flags |= SEC_EXCLUDE; - stabstrsec->flags |= SEC_EXCLUDE; + stabsec->flags |= SEC_EXCLUDE | SEC_KEEP; + stabstrsec->flags |= SEC_EXCLUDE | SEC_KEEP; sinfo->stabstr->size = _bfd_stringtab_size (sinfo->strings); /* Calculate the `cumulative_skips' array now that stabs have been @@ -611,7 +609,7 @@ _bfd_discard_section_stabs (bfd *abfd, /* Shrink the stabsec as needed. */ stabsec->size -= skip * STABSIZE; if (stabsec->size == 0) - stabsec->flags |= SEC_EXCLUDE; + stabsec->flags |= SEC_EXCLUDE | SEC_KEEP; /* Recalculate the `cumulative_skips' array now that stabs have been deleted for this section. */ diff --git a/ld/ChangeLog b/ld/ChangeLog index 17c703bd514..8b69b360e63 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,11 @@ +2006-10-27 Alan Modra + + * ldlang.c (lang_map): Don't say SEC_LINKER_CREATED and SEC_KEEP + sections have been discarded. + (lang_do_version_exports_section): Set SEC_KEEP on export section. + * emultempl/elf32.em (before_allocation): Set SEC_KEEP on warning + sections. + 2006-10-26 Joseph S. Myers Mark Mitchell diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em index 3350ac027ab..99fb8ab880e 100644 --- a/ld/emultempl/elf32.em +++ b/ld/emultempl/elf32.em @@ -1214,7 +1214,7 @@ ${ELF_INTERPRETER_SET_DEFAULT} /* Also set SEC_EXCLUDE, so that symbols defined in the warning section don't get copied to the output. */ - s->flags |= SEC_EXCLUDE; + s->flags |= SEC_EXCLUDE | SEC_KEEP; } } diff --git a/ld/ldlang.c b/ld/ldlang.c index 391fc1f2ad2..5df51706a72 100644 --- a/ld/ldlang.c +++ b/ld/ldlang.c @@ -1736,8 +1736,9 @@ lang_map (void) continue; for (s = file->the_bfd->sections; s != NULL; s = s->next) - if (s->output_section == NULL - || s->output_section->owner != output_bfd) + if ((s->output_section == NULL + || s->output_section->owner != output_bfd) + && (s->flags & (SEC_LINKER_CREATED | SEC_KEEP)) == 0) { if (! dis_header_printed) { @@ -4629,7 +4630,7 @@ lang_size_sections_1 &newdot); /* This symbol is relative to this section. */ - if ((tree->type.node_class == etree_provided + if ((tree->type.node_class == etree_provided || tree->type.node_class == etree_assign) && (tree->assign.dst [0] != '.' || tree->assign.dst [1] != '\0')) @@ -6922,7 +6923,7 @@ lang_do_version_exports_section (void) /* Do not free the contents, as we used them creating the regex. */ /* Do not include this section in the link. */ - sec->flags |= SEC_EXCLUDE; + sec->flags |= SEC_EXCLUDE | SEC_KEEP; } lreg = lang_new_vers_pattern (NULL, "*", NULL, FALSE); -- 2.30.2