[binutils-gdb/binutils-2_31-branch] Correct removal of .gnu.attributes
Alan Modra
amodra@sourceware.org
Thu Jul 5 12:59:00 GMT 2018
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=e89e89c9f8ceced99ebad21c045d7203939a5e33
commit e89e89c9f8ceced99ebad21c045d7203939a5e33
Author: Alan Modra <amodra@gmail.com>
Date: Tue Jul 3 17:57:36 2018 +0930
Correct removal of .gnu.attributes
Setting SEC_EXCLUDE for empty .gnu.attributes is too late in the link
process for the linker to remove the section. That must be done in
bfd_elf_final_link, as we do for removed group sections.
* elflink.c (bfd_elf_final_link): Remove zero size .gnu.attributes
sections.
(cherry picked from commit b8a6ced79668ec8af3180e50b76f7517ebbab0d9)
Diff:
---
bfd/ChangeLog | 5 +++++
bfd/elflink.c | 18 +++++++++++-------
2 files changed, 16 insertions(+), 7 deletions(-)
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index ebf032b..355f657 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,5 +1,10 @@
2018-07-03 Alan Modra <amodra@gmail.com>
+ * elflink.c (bfd_elf_final_link): Remove zero size .gnu.attributes
+ sections.
+
+2018-07-03 Alan Modra <amodra@gmail.com>
+
* elf-bfd.h (ATTR_TYPE_FLAG_ERROR, ATTR_TYPE_HAS_ERROR): Define.
* elf-attrs.c (is_default_attr): Handle ATTR_TYPE_HAS_ERROR.
* elf32-ppc.c (_bfd_elf_ppc_merge_fp_attributes): Use
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 36e0c37..138efac 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -11715,6 +11715,8 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info)
std_attrs_section = get_elf_backend_data (abfd)->obj_attrs_section;
for (o = abfd->sections; o != NULL; o = o->next)
{
+ bfd_boolean remove = FALSE;
+
if ((std_attrs_section && strcmp (o->name, std_attrs_section) == 0)
|| strcmp (o->name, ".gnu.attributes") == 0)
{
@@ -11731,19 +11733,21 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info)
}
attr_size = bfd_elf_obj_attr_size (abfd);
+ bfd_set_section_size (abfd, o, attr_size);
+ /* Skip this section later on. */
+ o->map_head.link_order = NULL;
if (attr_size)
- {
- bfd_set_section_size (abfd, o, attr_size);
- attr_section = o;
- /* Skip this section later on. */
- o->map_head.link_order = NULL;
- }
+ attr_section = o;
else
- o->flags |= SEC_EXCLUDE;
+ remove = TRUE;
}
else if ((o->flags & SEC_GROUP) != 0 && o->size == 0)
{
/* Remove empty group section from linker output. */
+ remove = TRUE;
+ }
+ if (remove)
+ {
o->flags |= SEC_EXCLUDE;
bfd_section_list_remove (abfd, o);
abfd->section_count--;
More information about the Binutils-cvs
mailing list