|
|
b37122 |
--- binutils.orig/bfd/elflink.c 2021-03-19 13:03:56.464793790 +0000
|
|
|
b37122 |
+++ binutils-2.30/bfd/elflink.c 2021-03-19 13:05:17.475264954 +0000
|
|
|
b37122 |
@@ -12825,7 +12825,7 @@ _bfd_elf_gc_mark_rsec (struct bfd_link_i
|
|
|
b37122 |
bfd_boolean *start_stop)
|
|
|
b37122 |
{
|
|
|
b37122 |
unsigned long r_symndx;
|
|
|
b37122 |
- struct elf_link_hash_entry *h;
|
|
|
b37122 |
+ struct elf_link_hash_entry *h, *hw;
|
|
|
b37122 |
|
|
|
b37122 |
r_symndx = cookie->rel->r_info >> cookie->r_sym_shift;
|
|
|
b37122 |
if (r_symndx == STN_UNDEF)
|
|
|
b37122 |
@@ -12845,12 +12845,16 @@ _bfd_elf_gc_mark_rsec (struct bfd_link_i
|
|
|
b37122 |
|| h->root.type == bfd_link_hash_warning)
|
|
|
b37122 |
h = (struct elf_link_hash_entry *) h->root.u.i.link;
|
|
|
b37122 |
h->mark = 1;
|
|
|
b37122 |
- /* If this symbol is weak and there is a non-weak definition, we
|
|
|
b37122 |
- keep the non-weak definition because many backends put
|
|
|
b37122 |
- dynamic reloc info on the non-weak definition for code
|
|
|
b37122 |
- handling copy relocs. */
|
|
|
b37122 |
- if (h->is_weakalias)
|
|
|
b37122 |
- weakdef (h)->mark = 1;
|
|
|
b37122 |
+ /* Keep all aliases of the symbol too. If an object symbol
|
|
|
b37122 |
+ needs to be copied into .dynbss then all of its aliases
|
|
|
b37122 |
+ should be present as dynamic symbols, not just the one used
|
|
|
b37122 |
+ on the copy relocation. */
|
|
|
b37122 |
+ hw = h;
|
|
|
b37122 |
+ while (hw->is_weakalias)
|
|
|
b37122 |
+ {
|
|
|
b37122 |
+ hw = hw->u.alias;
|
|
|
b37122 |
+ hw->mark = 1;
|
|
|
b37122 |
+ }
|
|
|
b37122 |
|
|
|
b37122 |
if (start_stop != NULL)
|
|
|
b37122 |
{
|
|
|
b37122 |
Only in binutils-2.30/ld/testsuite/ld-elf: pr25458.map
|
|
|
b37122 |
Only in binutils-2.30/ld/testsuite/ld-elf: pr25458.rd
|
|
|
b37122 |
Only in binutils-2.30/ld/testsuite/ld-elf: pr25458a.s
|
|
|
b37122 |
Only in binutils-2.30/ld/testsuite/ld-elf: pr25458b.s
|
|
|
b37122 |
diff -rup binutils.orig/ld/testsuite/ld-elf/shared.exp binutils-2.30/ld/testsuite/ld-elf/shared.exp
|
|
|
b37122 |
--- binutils.orig/ld/testsuite/ld-elf/shared.exp 2021-03-19 13:03:56.141795899 +0000
|
|
|
b37122 |
+++ binutils-2.30/ld/testsuite/ld-elf/shared.exp 2021-03-19 13:08:57.839826387 +0000
|
|
|
b37122 |
@@ -296,6 +296,38 @@ if { [check_gc_sections_available] } {
|
|
|
b37122 |
"pr22150" \
|
|
|
b37122 |
] \
|
|
|
b37122 |
]
|
|
|
b37122 |
+
|
|
|
b37122 |
+ switch -glob $target_triplet {
|
|
|
b37122 |
+ # Exclude targets that don't support copy relocs.
|
|
|
b37122 |
+ bfin-*-* { }
|
|
|
b37122 |
+ frv-*-* { }
|
|
|
b37122 |
+ lm32-*-* { }
|
|
|
b37122 |
+ mips*-*-* { }
|
|
|
b37122 |
+ tic6x-*-* { }
|
|
|
b37122 |
+ xtensa-*-* { }
|
|
|
b37122 |
+ default {
|
|
|
b37122 |
+ run_ld_link_tests [list \
|
|
|
b37122 |
+ [list \
|
|
|
b37122 |
+ "Build pr25458.so" \
|
|
|
b37122 |
+ "$LFLAGS -shared --version-script=pr25458.map" \
|
|
|
b37122 |
+ "" \
|
|
|
b37122 |
+ "$AFLAGS_PIC" \
|
|
|
b37122 |
+ {pr25458b.s} \
|
|
|
b37122 |
+ {} \
|
|
|
b37122 |
+ "pr25458.so" \
|
|
|
b37122 |
+ ] \
|
|
|
b37122 |
+ [list \
|
|
|
b37122 |
+ "Build pr25458" \
|
|
|
b37122 |
+ "$LFLAGS -e _start --gc-sections" \
|
|
|
b37122 |
+ "tmpdir/pr25458.so" \
|
|
|
b37122 |
+ "$AFLAGS_PIC" \
|
|
|
b37122 |
+ {pr25458a.s} \
|
|
|
b37122 |
+ {{readelf {--dyn-sym --wide} pr25458.rd}} \
|
|
|
b37122 |
+ "pr25458" \
|
|
|
b37122 |
+ ] \
|
|
|
b37122 |
+ ]
|
|
|
b37122 |
+ }
|
|
|
b37122 |
+ }
|
|
|
b37122 |
}
|
|
|
b37122 |
|
|
|
b37122 |
set ASFLAGS $old_ASFLAGS
|
|
|
b37122 |
--- /dev/null 2021-03-19 08:56:47.991465597 +0000
|
|
|
b37122 |
+++ binutils-2.30/ld/testsuite/ld-elf/pr25458.map 2021-03-19 13:06:34.859759781 +0000
|
|
|
b37122 |
@@ -0,0 +1,4 @@
|
|
|
b37122 |
+FOO {
|
|
|
b37122 |
+global:
|
|
|
b37122 |
+ __environ; _environ; environ;
|
|
|
b37122 |
+};
|
|
|
b37122 |
--- /dev/null 2021-03-19 08:56:47.991465597 +0000
|
|
|
b37122 |
+++ binutils-2.30/ld/testsuite/ld-elf/pr25458.rd 2021-03-19 13:06:34.860759774 +0000
|
|
|
b37122 |
@@ -0,0 +1,10 @@
|
|
|
b37122 |
+#...
|
|
|
b37122 |
+Symbol table '\.dynsym' contains [0-9]+ entries:
|
|
|
b37122 |
+ +Num: +Value +Size Type +Bind +Vis +Ndx Name
|
|
|
b37122 |
+#...
|
|
|
b37122 |
+ +[0-9]+: [0-9a-f]+ +(4|8)+ OBJECT +(WEAK|GLOBAL) +DEFAULT +[0-9]+ _*environ@FOO \(2\)
|
|
|
b37122 |
+#...
|
|
|
b37122 |
+ +[0-9]+: [0-9a-f]+ +(4|8)+ OBJECT +(WEAK|GLOBAL) +DEFAULT +[0-9]+ _*environ@FOO \(2\)
|
|
|
b37122 |
+#...
|
|
|
b37122 |
+ +[0-9]+: [0-9a-f]+ +(4|8)+ OBJECT +(WEAK|GLOBAL) +DEFAULT +[0-9]+ _*environ@FOO \(2\)
|
|
|
b37122 |
+#pass
|
|
|
b37122 |
--- /dev/null 2021-03-19 08:56:47.991465597 +0000
|
|
|
b37122 |
+++ binutils-2.30/ld/testsuite/ld-elf/pr25458a.s 2021-03-19 13:06:34.860759774 +0000
|
|
|
b37122 |
@@ -0,0 +1,6 @@
|
|
|
b37122 |
+ .text
|
|
|
b37122 |
+ .globl _start
|
|
|
b37122 |
+ .type _start, %function
|
|
|
b37122 |
+_start:
|
|
|
b37122 |
+ .dc.a environ
|
|
|
b37122 |
+ .size _start, .-_start
|
|
|
b37122 |
--- /dev/null 2021-03-19 08:56:47.991465597 +0000
|
|
|
b37122 |
+++ binutils-2.30/ld/testsuite/ld-elf/pr25458b.s 2021-03-19 13:06:34.860759774 +0000
|
|
|
b37122 |
@@ -0,0 +1,11 @@
|
|
|
b37122 |
+ .data
|
|
|
b37122 |
+ .globl __environ
|
|
|
b37122 |
+ .type __environ,%object
|
|
|
b37122 |
+__environ:
|
|
|
b37122 |
+ .dc.a 0
|
|
|
b37122 |
+ .size __environ, .-__environ
|
|
|
b37122 |
+ .weak _environ
|
|
|
b37122 |
+ .globl _environ
|
|
|
b37122 |
+ .set _environ, __environ
|
|
|
b37122 |
+ .weak environ
|
|
|
b37122 |
+ .set environ, __environ
|