[binutils-gdb] Generic ELF target group signature symbol
Alan Modra
amodra@sourceware.org
Mon May 27 04:58:00 GMT 2019
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=3d7d6a6ff4678685f86976f08ab4c9c639e262e1
commit 3d7d6a6ff4678685f86976f08ab4c9c639e262e1
Author: Alan Modra <amodra@gmail.com>
Date: Mon May 27 09:38:42 2019 +0930
Generic ELF target group signature symbol
Even though the generic ELF target doesn't handle groups correctly,
this helps avoid a segfault in bfd_elf_set_group_contents seen on
d30v-elf, dlx-elf, pj-elf, and xgate-elf when linking the pr22836
testcase.
PR 24596
bfd/
* linker.c (_bfd_generic_link_output_symbols): Heed BSF_KEEP.
ld/
* emultempl/genelf.em (gld${EMULATION_NAME}_after_open): Set
BFS_KEEP on group signature symbol.
Diff:
---
bfd/ChangeLog | 5 +++++
bfd/linker.c | 13 +++++++------
ld/ChangeLog | 6 ++++++
ld/emultempl/genelf.em | 4 +++-
4 files changed, 21 insertions(+), 7 deletions(-)
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index a7603da..3f7f174 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,8 @@
+2019-05-27 Alan Modra <amodra@gmail.com>
+
+ PR 24596
+ * linker.c (_bfd_generic_link_output_symbols): Heed BSF_KEEP.
+
2019-05-24 Szabolcs Nagy <szabolcs.nagy@arm.com>
* elfnn-aarch64.c (elfNN_aarch64_merge_symbol_attribute): New function.
diff --git a/bfd/linker.c b/bfd/linker.c
index 9e89c84..1b71fcf 100644
--- a/bfd/linker.c
+++ b/bfd/linker.c
@@ -2112,12 +2112,11 @@ _bfd_generic_link_output_symbols (bfd *output_bfd,
}
}
- /* This switch is straight from the old code in
- write_file_locals in ldsym.c. */
- if (info->strip == strip_all
- || (info->strip == strip_some
- && bfd_hash_lookup (info->keep_hash, bfd_asymbol_name (sym),
- FALSE, FALSE) == NULL))
+ if ((sym->flags & BSF_KEEP) == 0
+ && (info->strip == strip_all
+ || (info->strip == strip_some
+ && bfd_hash_lookup (info->keep_hash, bfd_asymbol_name (sym),
+ FALSE, FALSE) == NULL)))
output = FALSE;
else if ((sym->flags & (BSF_GLOBAL | BSF_WEAK | BSF_GNU_UNIQUE)) != 0)
{
@@ -2131,6 +2130,8 @@ _bfd_generic_link_output_symbols (bfd *output_bfd,
else
output = FALSE;
}
+ else if ((sym->flags & BSF_KEEP) != 0)
+ output = TRUE;
else if (bfd_is_ind_section (sym->section))
output = FALSE;
else if ((sym->flags & BSF_DEBUGGING) != 0)
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 4de04b6..36d866f 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,9 @@
+2019-05-27 Alan Modra <amodra@gmail.com>
+
+ PR 24596
+ * emultempl/genelf.em (gld${EMULATION_NAME}_after_open): Set
+ BFS_KEEP on group signature symbol.
+
2019-04-24 Szabolcs Nagy <szabolcs.nagy@arm.com>
* testsuite/ld-aarch64/aarch64-elf.exp: Add new tests.
diff --git a/ld/emultempl/genelf.em b/ld/emultempl/genelf.em
index 472f701..664a5b1 100644
--- a/ld/emultempl/genelf.em
+++ b/ld/emultempl/genelf.em
@@ -45,7 +45,9 @@ gld${EMULATION_NAME}_after_open (void)
if ((sec->flags & (SEC_GROUP | SEC_LINKER_CREATED)) == SEC_GROUP)
{
struct bfd_elf_section_data *sec_data = elf_section_data (sec);
- elf_group_id (sec) = syms[sec_data->this_hdr.sh_info - 1];
+ struct bfd_symbol *sym = syms[sec_data->this_hdr.sh_info - 1];
+ elf_group_id (sec) = sym;
+ sym->flags |= BSF_KEEP;
}
}
More information about the Binutils-cvs
mailing list