summaryrefslogtreecommitdiffstats
path: root/bfd/elflink.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2008-01-15 07:25:49 +0000
committerAlan Modra <amodra@gmail.com>2008-01-15 07:25:49 +0000
commit74f0fb5065323b33bef71dfcbbd9b595c88c6c0c (patch)
tree887fac661eca7841cb2e40e01f993da0f5aa02c7 /bfd/elflink.c
parent5c07affcae1a9698e488eefae0b1eb30d9743657 (diff)
downloadppe42-binutils-74f0fb5065323b33bef71dfcbbd9b595c88c6c0c.tar.gz
ppe42-binutils-74f0fb5065323b33bef71dfcbbd9b595c88c6c0c.zip
bfd/
PR 5604 * elf-bfd.h (struct elf_backend_data): Add gc_keep. Remove param names from others. (_bfd_elf_gc_keep): Declare. * elfxx-target.h (elf_backend_gc_keep): Define. (elfNN_bed): Init new field. * elflink.c (_bfd_elf_gc_keep): New function. (bfd_elf_gc_sections): Call gc_keep. * elf64-ppc.c (elf_backend_gc_keep): Define. (struct _ppc64_elf_section_data): Move .opd related fields to a struct so they don't occupy the same storage. Adjust accesses throughout file. (ppc64_elf_gc_keep): New function, split out from.. (ppc64_elf_gc_mark_hook): ..here. Don't call _bfd_elf_gc_mark to mark .opd section, just set gc_mark. (ppc64_elf_edit_opd): Remove no_opd_opt parm. Don't set opd->adjust unless we are changing .opd. Test non-NULL opd->adjust at all accesses throughout file. * elf64-ppc.h (ppc64_elf_edit_opd): Update prototype. ld/ PR 5604 * ldlang.c (lang_gc_sections): Move code to set SEC_KEEP on entry syms to _bfd_elf_gc_keep. * emultempl/ppc64elf.em (ppc_before_allocation): Don't call ppc64_elf_edit_opd if no_opd_opt.
Diffstat (limited to 'bfd/elflink.c')
-rw-r--r--bfd/elflink.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/bfd/elflink.c b/bfd/elflink.c
index f9f7e13f51..ed691818c6 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -1,6 +1,6 @@
/* ELF linking support for BFD.
Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
- 2005, 2006, 2007 Free Software Foundation, Inc.
+ 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
This file is part of BFD, the Binary File Descriptor library.
@@ -11463,6 +11463,29 @@ bfd_elf_gc_mark_dynamic_ref_symbol (struct elf_link_hash_entry *h, void *inf)
return TRUE;
}
+/* Keep all sections containing symbols undefined on the command-line,
+ and the section containing the entry symbol. */
+
+void
+_bfd_elf_gc_keep (struct bfd_link_info *info)
+{
+ struct bfd_sym_chain *sym;
+
+ for (sym = info->gc_sym_list; sym != NULL; sym = sym->next)
+ {
+ struct elf_link_hash_entry *h;
+
+ h = elf_link_hash_lookup (elf_hash_table (info), sym->name,
+ FALSE, FALSE, FALSE);
+
+ if (h != NULL
+ && (h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
+ && !bfd_is_abs_section (h->root.u.def.section))
+ h->root.u.def.section->flags |= SEC_KEEP;
+ }
+}
+
/* Do mark and sweep of unused sections. */
bfd_boolean
@@ -11480,6 +11503,8 @@ bfd_elf_gc_sections (bfd *abfd, struct bfd_link_info *info)
return TRUE;
}
+ bed->gc_keep (info);
+
/* Try to parse each bfd's .eh_frame section. Point elf_eh_frame_section
at the .eh_frame section if we can mark the FDEs individually. */
_bfd_elf_begin_eh_frame_parsing (info);
@@ -11536,7 +11561,7 @@ bfd_elf_gc_sections (bfd *abfd, struct bfd_link_info *info)
/* Allow the backend to mark additional target specific sections. */
if (bed->gc_mark_extra_sections)
- bed->gc_mark_extra_sections(info, gc_mark_hook);
+ bed->gc_mark_extra_sections (info, gc_mark_hook);
/* ... and mark SEC_EXCLUDE for those that go. */
return elf_gc_sweep (abfd, info);
OpenPOWER on IntegriCloud