[binutils-gdb] Handle -z unique/-z nounique in ld
Alan Modra
amodra@sourceware.org
Tue Dec 15 08:15:54 GMT 2020
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=6a0a0dd0cc43765d8e5e277aeaaf169a863f2315
commit 6a0a0dd0cc43765d8e5e277aeaaf169a863f2315
Author: Vivek Das Mohapatra <vivek@collabora.com>
Date: Mon Dec 14 17:25:51 2020 +0000
Handle -z unique/-z nounique in ld
Add (or suppress) a DT_GNU_FLAGS_1 dynamic section
with a bit flag value of DF_GNU_1_UNIQUE.
bfd/
* elflink.c (bfd_elf_size_dynamic_sections): Call
_bfd_elf_add_dynamic_entry to add a DT_GNU_FLAGS_1 section.
include/
* bfdlink.h (struct bfd_link_info): New field gnu_flags_1.
ld/
* emultempl/elf.em (gld${EMULATION_NAME}_handle_option):
Parse -z unique / -z nounique options.
Diff:
---
bfd/ChangeLog | 5 +++++
bfd/elflink.c | 5 ++++-
include/ChangeLog | 1 +
include/bfdlink.h | 3 +++
ld/ChangeLog | 5 +++++
ld/emultempl/elf.em | 4 ++++
6 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index e3a5c8a6eeb..11b901a2204 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,8 @@
+2020-12-15 Vivek Das Mohapatra <vivek@collabora.com>
+
+ * elflink.c (bfd_elf_size_dynamic_sections): Call
+ _bfd_elf_add_dynamic_entry to add a DT_GNU_FLAGS_1 section.
+
2020-12-14 Alan Modra <amodra@gmail.com>
* elf-bfd.h (struct elf_obj_tdata): Add being_created.
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 29b46f1568d..37af3efcb06 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -7178,7 +7178,10 @@ bfd_elf_size_dynamic_sections (bfd *output_bfd,
|| !_bfd_elf_add_dynamic_entry (info, DT_SYMTAB, 0)
|| !_bfd_elf_add_dynamic_entry (info, DT_STRSZ, strsize)
|| !_bfd_elf_add_dynamic_entry (info, DT_SYMENT,
- bed->s->sizeof_sym))
+ bed->s->sizeof_sym)
+ || (info->gnu_flags_1
+ && !_bfd_elf_add_dynamic_entry (info, DT_GNU_FLAGS_1,
+ info->gnu_flags_1)))
return FALSE;
}
}
diff --git a/include/ChangeLog b/include/ChangeLog
index f19742eafb6..a8316ee1342 100644
--- a/include/ChangeLog
+++ b/include/ChangeLog
@@ -1,6 +1,7 @@
2020-12-15 Vivek Das Mohapatra <vivek@collabora.com>
* elf/common.h (DT_GNU_FLAGS_1, DF_GNU_1_UNIQUE): Define.
+ * bfdlink.h (struct bfd_link_info): New field gnu_flags_1.
2020-12-11 Cary Coutant <ccoutant@gmail.com>
diff --git a/include/bfdlink.h b/include/bfdlink.h
index b92ef5408d5..3019033ea22 100644
--- a/include/bfdlink.h
+++ b/include/bfdlink.h
@@ -655,6 +655,9 @@ struct bfd_link_info
/* May be used to set DT_FLAGS_1 for ELF. */
bfd_vma flags_1;
+ /* May be used to set DT_GNU_FLAGS_1 for ELF. */
+ bfd_vma gnu_flags_1;
+
/* May be used to set ELF visibility for __start_* / __stop_. */
unsigned int start_stop_visibility;
diff --git a/ld/ChangeLog b/ld/ChangeLog
index b649e6870b4..3db7fc6a864 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,8 @@
+2020-12-15 Vivek Das Mohapatra <vivek@collabora.com>
+
+ * emultempl/elf.em (gld${EMULATION_NAME}_handle_option):
+ Parse -z unique / -z nounique options.
+
2020-12-14 Howard Chu <hyc@symas.com>
* libdep_plugin.c: New file: Processes archives that contain a
diff --git a/ld/emultempl/elf.em b/ld/emultempl/elf.em
index cfdf60e1365..aa40c7829e5 100644
--- a/ld/emultempl/elf.em
+++ b/ld/emultempl/elf.em
@@ -809,6 +809,10 @@ fragment <<EOF
link_info.flags |= (bfd_vma) DF_ORIGIN;
link_info.flags_1 |= (bfd_vma) DF_1_ORIGIN;
}
+ else if (strcmp (optarg, "unique") == 0)
+ link_info.gnu_flags_1 |= (bfd_vma) DF_GNU_1_UNIQUE;
+ else if (strcmp (optarg, "nounique") == 0)
+ link_info.gnu_flags_1 &= ~(bfd_vma) DF_GNU_1_UNIQUE;
else if (strcmp (optarg, "combreloc") == 0)
link_info.combreloc = TRUE;
else if (strcmp (optarg, "nocombreloc") == 0)
More information about the Binutils-cvs
mailing list