aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorClaudiu Zissulescu <claziss@synopsys.com>2021-09-14 12:10:54 +0300
committerClaudiu Zissulescu <claziss@synopsys.com>2021-09-14 12:10:54 +0300
commit09a7e912932db766d5e6badfcba61c55f185503a (patch)
tree9e0d738f0382a4cedf8423afe9bef0315070ce75 /ld
parentf050cfdd82625e6214c4a77ae3b4b364dede1b52 (diff)
downloadgdb-09a7e912932db766d5e6badfcba61c55f185503a.zip
gdb-09a7e912932db766d5e6badfcba61c55f185503a.tar.gz
gdb-09a7e912932db766d5e6badfcba61c55f185503a.tar.bz2
arc: Fix potential invalid pointer access when fixing got symbols.
When statically linking, it can arrive to an undefined weak symbol of which its value cannot be determined. However, we are having pieces of code which doesn't take this situation into account, leading to access a structure which may not be initialized. Fix this situation and add a test. bfd/ xxxx-xx-xx Cupertino Miranda <cmiranda@synopsys.com> Claudiu Zissulescu <claziss@synopsys.com> * arc-got.h (arc_static_sym_data): New structure. (get_static_sym_data): New function. (relocate_fix_got_relocs_for_got_info): Move the computation fo symbol value and section to above introduced function, and use this new function. ld/testsuite/ xxxx-xx-xx Claudiu Zissulescu <claziss@synopsys.com> * ld-arc/got-weak.d: New file. * ld-arc/got-weak.s: Likewise. Signed-off-by: Claudiu Zissulescu <claziss@synopsys.com> fix
Diffstat (limited to 'ld')
-rw-r--r--ld/ChangeLog5
-rw-r--r--ld/testsuite/ld-arc/got-weak.d12
-rw-r--r--ld/testsuite/ld-arc/got-weak.s7
3 files changed, 24 insertions, 0 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 28deefc..ebcd4cd 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,8 @@
+2021-09-14 Claudiu Zissulescu <claziss@synopsys.com>
+
+ * ld-arc/got-weak.d: New file.
+ * ld-arc/got-weak.s: Likewise.
+
2021-07-26 Roland McGrath <mcgrathr@google.com>
* testsuite/ld-x86-64/x86-64.exp (Build textrel-1): Use --warn-textrel.
diff --git a/ld/testsuite/ld-arc/got-weak.d b/ld/testsuite/ld-arc/got-weak.d
new file mode 100644
index 0000000..cf15069
--- /dev/null
+++ b/ld/testsuite/ld-arc/got-weak.d
@@ -0,0 +1,12 @@
+#source: got-weak.s
+#as:
+#ld: -Bstatic
+#objdump: -d
+
+[^:]*: file format elf32-.*arc
+
+
+Disassembly of section \.text:
+
+00000100 <.*>:
+ 100: 2730 7f80 0000 2014 ld r0,\[pcl,0x2014\].*
diff --git a/ld/testsuite/ld-arc/got-weak.s b/ld/testsuite/ld-arc/got-weak.s
new file mode 100644
index 0000000..8ea18be
--- /dev/null
+++ b/ld/testsuite/ld-arc/got-weak.s
@@ -0,0 +1,7 @@
+ .cpu archs
+
+ .weak symb
+ .global __start
+ .text
+__start:
+ ld r0,[pcl,@symb@gotpc]