aboutsummaryrefslogtreecommitdiff
path: root/ld/testsuite
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2020-01-27 10:27:42 +1030
committerAlan Modra <amodra@gmail.com>2020-01-27 10:53:00 +1030
commit3024a17ae029ec7f55b498e99ddd6238e22fe565 (patch)
tree554320c69f99bb0a36f8301e9bcfe539873f6f20 /ld/testsuite
parent27ee3a66bfba776a2af8e9e1248e6a65c31e25a3 (diff)
downloadbinutils-3024a17ae029ec7f55b498e99ddd6238e22fe565.zip
binutils-3024a17ae029ec7f55b498e99ddd6238e22fe565.tar.gz
binutils-3024a17ae029ec7f55b498e99ddd6238e22fe565.tar.bz2
Mark all weak aliases for copy relocations
bfd/ PR ld/25458 * elflink.c (_bfd_elf_gc_mark_rsec): Mark all weak aliases. ld/ PR ld/25458 * testsuite/ld-elf/pr25458.map: New file. * testsuite/ld-elf/pr25458.rd: Likewise. * testsuite/ld-elf/pr25458a.s: Likewise. * testsuite/ld-elf/pr25458b.s: Likewise. * testsuite/ld-elf/shared.exp: Run PR ld/25458 test.
Diffstat (limited to 'ld/testsuite')
-rw-r--r--ld/testsuite/ld-elf/pr25458.map4
-rw-r--r--ld/testsuite/ld-elf/pr25458.rd10
-rw-r--r--ld/testsuite/ld-elf/pr25458a.s6
-rw-r--r--ld/testsuite/ld-elf/pr25458b.s11
-rw-r--r--ld/testsuite/ld-elf/shared.exp32
5 files changed, 63 insertions, 0 deletions
diff --git a/ld/testsuite/ld-elf/pr25458.map b/ld/testsuite/ld-elf/pr25458.map
new file mode 100644
index 0000000..5578d1f
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr25458.map
@@ -0,0 +1,4 @@
+FOO {
+global:
+ __environ; _environ; environ;
+};
diff --git a/ld/testsuite/ld-elf/pr25458.rd b/ld/testsuite/ld-elf/pr25458.rd
new file mode 100644
index 0000000..d0fc6b9
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr25458.rd
@@ -0,0 +1,10 @@
+#...
+Symbol table '\.dynsym' contains [0-9]+ entries:
+ +Num: +Value +Size Type +Bind +Vis +Ndx Name
+#...
+ +[0-9]+: [0-9a-f]+ +(4|8)+ OBJECT +(WEAK|GLOBAL) +DEFAULT +[0-9]+ _*environ@FOO \(2\)
+#...
+ +[0-9]+: [0-9a-f]+ +(4|8)+ OBJECT +(WEAK|GLOBAL) +DEFAULT +[0-9]+ _*environ@FOO \(2\)
+#...
+ +[0-9]+: [0-9a-f]+ +(4|8)+ OBJECT +(WEAK|GLOBAL) +DEFAULT +[0-9]+ _*environ@FOO \(2\)
+#pass
diff --git a/ld/testsuite/ld-elf/pr25458a.s b/ld/testsuite/ld-elf/pr25458a.s
new file mode 100644
index 0000000..59e6af2
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr25458a.s
@@ -0,0 +1,6 @@
+ .text
+ .globl _start
+ .type _start, %function
+_start:
+ .dc.a environ
+ .size _start, .-_start
diff --git a/ld/testsuite/ld-elf/pr25458b.s b/ld/testsuite/ld-elf/pr25458b.s
new file mode 100644
index 0000000..ff64cc7
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr25458b.s
@@ -0,0 +1,11 @@
+ .data
+ .globl __environ
+ .type __environ,%object
+__environ:
+ .dc.a 0
+ .size __environ, .-__environ
+ .weak _environ
+ .globl _environ
+ .set _environ, __environ
+ .weak environ
+ .set environ, __environ
diff --git a/ld/testsuite/ld-elf/shared.exp b/ld/testsuite/ld-elf/shared.exp
index e03906a..b1762af 100644
--- a/ld/testsuite/ld-elf/shared.exp
+++ b/ld/testsuite/ld-elf/shared.exp
@@ -337,6 +337,38 @@ if { [check_gc_sections_available] } {
"pr22150" \
] \
]
+
+ switch -glob $target_triplet {
+ # exclude targets that don't support copy relocs
+ bfin-*-* { }
+ frv-*-* { }
+ lm32-*-* { }
+ mips*-*-* { }
+ tic6x-*-* { }
+ xtensa-*-* { }
+ default {
+ run_ld_link_tests [list \
+ [list \
+ "Build pr25458.so" \
+ "$LFLAGS -shared --version-script=pr25458.map" \
+ "" \
+ "$AFLAGS_PIC" \
+ {pr25458b.s} \
+ {} \
+ "pr25458.so" \
+ ] \
+ [list \
+ "Build pr25458" \
+ "$LFLAGS -e _start --gc-sections" \
+ "tmpdir/pr25458.so" \
+ "$AFLAGS_PIC" \
+ {pr25458a.s} \
+ {{readelf {--dyn-sym --wide} pr25458.rd}} \
+ "pr25458" \
+ ] \
+ ]
+ }
+ }
}
set ASFLAGS $old_ASFLAGS