aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2020-12-18 04:24:26 -0800
committerH.J. Lu <hjl.tools@gmail.com>2020-12-18 04:24:36 -0800
commit04f8967487515179cc6dfc7c828f77eeb75c08d3 (patch)
treee94cbcef29d4c243b02807377d5f9a98f2c3808c
parent3fafa2e26ed651e3d3a50193b5bbf8f55779c7aa (diff)
downloadgdb-04f8967487515179cc6dfc7c828f77eeb75c08d3.zip
gdb-04f8967487515179cc6dfc7c828f77eeb75c08d3.tar.gz
gdb-04f8967487515179cc6dfc7c828f77eeb75c08d3.tar.bz2
elf: Copy elf_gnu_osabi_retain only for relocatable link
Copy elf_gnu_osabi_retain from input only for relocatable link since SHF_GNU_RETAIN has no impact on non-relocatable outputs. bfd/ PR ld/27091 * elflink.c (elf_link_input_bfd): Copy elf_gnu_osabi_retain from input only for relocatable link. ld/ PR ld/27091 * testsuite/ld-elf/retain7.s: New file. * testsuite/ld-elf/retain7a.d: Likewise. * testsuite/ld-elf/retain7b.d: Likewise.
-rw-r--r--bfd/ChangeLog6
-rw-r--r--bfd/elflink.c4
-rw-r--r--ld/ChangeLog7
-rw-r--r--ld/testsuite/ld-elf/retain7.s5
-rw-r--r--ld/testsuite/ld-elf/retain7a.d11
-rw-r--r--ld/testsuite/ld-elf/retain7b.d10
6 files changed, 42 insertions, 1 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index cb72b13..582add8 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2020-12-18 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR ld/27091
+ * elflink.c (elf_link_input_bfd): Copy elf_gnu_osabi_retain
+ from input only for relocatable link.
+
2020-12-18 Alan Modra <amodra@gmail.com>
* elf32-microblaze.c (dbg): Delete unused variable.
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 2489700..1b33981 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -10806,7 +10806,9 @@ elf_link_input_bfd (struct elf_final_link_info *flinfo, bfd *input_bfd)
|| bed->elf_osabi == ELFOSABI_GNU
|| bed->elf_osabi == ELFOSABI_FREEBSD)
elf_tdata (output_bfd)->has_gnu_osabi
- |= elf_tdata (input_bfd)->has_gnu_osabi;
+ |= (elf_tdata (input_bfd)->has_gnu_osabi
+ & (bfd_link_relocatable (flinfo->info)
+ ? -1 : ~elf_gnu_osabi_retain));
/* Read the local symbols. */
isymbuf = (Elf_Internal_Sym *) symtab_hdr->contents;
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 34d58d4..392165b 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,10 @@
+2020-12-18 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR ld/27091
+ * testsuite/ld-elf/retain7.s: New file.
+ * testsuite/ld-elf/retain7a.d: Likewise.
+ * testsuite/ld-elf/retain7b.d: Likewise.
+
2020-12-16 Howard Chu <hyc@symas.com>
H.J. Lu <hongjiu.lu@intel.com>
diff --git a/ld/testsuite/ld-elf/retain7.s b/ld/testsuite/ld-elf/retain7.s
new file mode 100644
index 0000000..a6cc869
--- /dev/null
+++ b/ld/testsuite/ld-elf/retain7.s
@@ -0,0 +1,5 @@
+ .type _start,"function"
+ .section .text,"axR",%progbits
+ .global _start
+_start:
+ .nop
diff --git a/ld/testsuite/ld-elf/retain7a.d b/ld/testsuite/ld-elf/retain7a.d
new file mode 100644
index 0000000..544ff8a
--- /dev/null
+++ b/ld/testsuite/ld-elf/retain7a.d
@@ -0,0 +1,11 @@
+#name: SHF_GNU_RETAIN 7a
+#source: retain7.s
+#ld: -e _start --gc-sections
+#notarget: ![supports_gnu_osabi] ![check_gc_sections_available]
+#readelf: -h
+
+#failif
+ELF Header:
+#...
+ OS/ABI: UNIX - GNU
+#pass
diff --git a/ld/testsuite/ld-elf/retain7b.d b/ld/testsuite/ld-elf/retain7b.d
new file mode 100644
index 0000000..0e5b12b
--- /dev/null
+++ b/ld/testsuite/ld-elf/retain7b.d
@@ -0,0 +1,10 @@
+#name: SHF_GNU_RETAIN 7a
+#source: retain7.s
+#ld: -r
+#notarget: ![supports_gnu_osabi] ![check_gc_sections_available]
+#readelf: -h
+
+ELF Header:
+#...
+ OS/ABI: UNIX - GNU
+#pass