aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2018-05-14 03:47:47 -0700
committerH.J. Lu <hjl.tools@gmail.com>2018-05-14 03:48:02 -0700
commit9bc935ef3380a2d471b9447e2bf8e61297654e2f (patch)
tree7a3dcd50c0392966eceef1ab218a8650d071d603 /ld
parent85bd2d83f8a3d813718418df11c2bee2a50c1274 (diff)
downloadgdb-9bc935ef3380a2d471b9447e2bf8e61297654e2f.zip
gdb-9bc935ef3380a2d471b9447e2bf8e61297654e2f.tar.gz
gdb-9bc935ef3380a2d471b9447e2bf8e61297654e2f.tar.bz2
x86: Mark __bss_start, _end and _edata locally defined
__bss_start, _end and _edata are defined by linker to mark regions within executables and shared libraries. All references within executables should be locally resolved. This patch doesn't change how their references within shared libraries are resolved. bfd/ PR ld/23162 * elfxx-x86.c (elf_x86_linker_defined): New function. (_bfd_x86_elf_link_check_relocs): Use it to mark __bss_start, _end and _edata locally defined within executables. ld/ PR ld/23162 * testsuite/ld-elf/pr23162.map: New file. * testsuite/ld-elf/pr23162.rd: Likewise. * testsuite/ld-elf/pr23162a.c: Likewise. * testsuite/ld-elf/pr23162b.c: Likewise. * testsuite/ld-elf/shared.exp: Run PR ld/23162 tests.
Diffstat (limited to 'ld')
-rw-r--r--ld/ChangeLog9
-rw-r--r--ld/testsuite/ld-elf/pr23162.map4
-rw-r--r--ld/testsuite/ld-elf/pr23162.rd12
-rw-r--r--ld/testsuite/ld-elf/pr23162a.c4
-rw-r--r--ld/testsuite/ld-elf/pr23162b.c20
-rw-r--r--ld/testsuite/ld-elf/shared.exp46
6 files changed, 95 insertions, 0 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 3360959..178ca68 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,12 @@
+2018-05-14 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR ld/23162
+ * testsuite/ld-elf/pr23162.map: New file.
+ * testsuite/ld-elf/pr23162.rd: Likewise.
+ * testsuite/ld-elf/pr23162a.c: Likewise.
+ * testsuite/ld-elf/pr23162b.c: Likewise.
+ * testsuite/ld-elf/shared.exp: Run PR ld/23162 tests.
+
2018-05-12 Alan Modra <amodra@gmail.com>
PR 20659
diff --git a/ld/testsuite/ld-elf/pr23162.map b/ld/testsuite/ld-elf/pr23162.map
new file mode 100644
index 0000000..cc817dc
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr23162.map
@@ -0,0 +1,4 @@
+FOO {
+ global:
+ *;
+};
diff --git a/ld/testsuite/ld-elf/pr23162.rd b/ld/testsuite/ld-elf/pr23162.rd
new file mode 100644
index 0000000..3ac848f
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr23162.rd
@@ -0,0 +1,12 @@
+There are no relocations in this file\.
+
+Symbol table '\.dynsym' contains [0-9]+ entries:
+ +Num: +Value +Size Type +Bind +Vis +Ndx Name
+ +0: 0+ +0 +NOTYPE +LOCAL +DEFAULT +UND +
+#...
+ +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +GLOBAL +DEFAULT +[0-9]+ +_edata
+#...
+ +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +GLOBAL +DEFAULT +[0-9]+ +_end
+#...
+ +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +GLOBAL +DEFAULT +[0-9]+ +__bss_start
+#...
diff --git a/ld/testsuite/ld-elf/pr23162a.c b/ld/testsuite/ld-elf/pr23162a.c
new file mode 100644
index 0000000..cd0130c
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr23162a.c
@@ -0,0 +1,4 @@
+void
+foo (void)
+{
+}
diff --git a/ld/testsuite/ld-elf/pr23162b.c b/ld/testsuite/ld-elf/pr23162b.c
new file mode 100644
index 0000000..8476120
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr23162b.c
@@ -0,0 +1,20 @@
+static char *_edata_p;
+static char *_end_p;
+static char *__bss_start_p;
+extern char *_end;
+extern char *_edata;
+extern char *__bss_start;
+
+void
+bar (void)
+{
+ _edata_p = (char*) &_edata;
+ _end_p = (char*) &_end;
+ __bss_start_p = (char*) &__bss_start;
+}
+
+void
+_start ()
+{
+ bar ();
+}
diff --git a/ld/testsuite/ld-elf/shared.exp b/ld/testsuite/ld-elf/shared.exp
index eb54eb9..ef517ba 100644
--- a/ld/testsuite/ld-elf/shared.exp
+++ b/ld/testsuite/ld-elf/shared.exp
@@ -1349,3 +1349,49 @@ proc mix_pic_and_non_pic {xfails cflags ldflags exe} {
mix_pic_and_non_pic [list "arm*-*-*" "aarch64*-*-*"] "" "" "pr19719"
mix_pic_and_non_pic [] "-fPIE" "-pie" "pr19719pie"
+
+if { ([istarget "i?86-*-*"]
+ || [istarget "x86_64-*-*"]) } {
+ run_ld_link_tests [list \
+ [list \
+ "Build libpr23162a.so" \
+ "-shared" \
+ "" \
+ "$AFLAGS_PIC" \
+ { pr23162a.c } \
+ "" \
+ "libpr23162a.so" \
+ "-fPIC -O2" \
+ ] \
+ [list \
+ "Build pr23162a" \
+ "-pie --no-as-needed tmpdir/libpr23162a.so" \
+ "" \
+ "-mrelax-relocations=yes" \
+ { pr23162b.c } \
+ {{readelf {--dyn-syms -rW} pr23162.rd}} \
+ "pr23162a" \
+ "-fPIC -O0" \
+ ] \
+ [list \
+ "Build libpr23162b.so" \
+ "-shared --version-script=pr23162.map" \
+ "" \
+ "$AFLAGS_PIC" \
+ { pr23162a.c } \
+ "" \
+ "libpr23162b.so" \
+ "-fPIC -O2" \
+ ] \
+ [list \
+ "Build pr23162b" \
+ "-pie --no-as-needed tmpdir/libpr23162b.so" \
+ "" \
+ "-mrelax-relocations=yes" \
+ { pr23162b.c } \
+ {{readelf {--dyn-syms -rW} pr23162.rd}} \
+ "pr23162b" \
+ "-fPIC -O0" \
+ ] \
+ ]
+}