aboutsummaryrefslogtreecommitdiff
path: root/gas
diff options
context:
space:
mode:
authorJan Beulich <jbeulich@suse.com>2021-05-07 12:05:12 +0200
committerJan Beulich <jbeulich@suse.com>2021-05-07 12:05:12 +0200
commit17c6c3b99156fe82c1e637e1a5fd9f163ac788c8 (patch)
tree71c76cc1471f142456595eea8af28d3e1eadb1ee /gas
parent98da05bf2698b55b73453480a3fbb92f163d2c7b (diff)
downloadbinutils-17c6c3b99156fe82c1e637e1a5fd9f163ac788c8.zip
binutils-17c6c3b99156fe82c1e637e1a5fd9f163ac788c8.tar.gz
binutils-17c6c3b99156fe82c1e637e1a5fd9f163ac788c8.tar.bz2
x86-64/ELF: clear src_mask for all reloc types
x86-64 uses rela relocations. The comment next to the field's declaration says "Non-zero values for ELF USE_RELA targets should be viewed with suspicion ..." And indeed the fields being non-zero causes section contents to be accumulated into the final relocated values in addition to the relocations' addends, which is contrary to the ELF spec.
Diffstat (limited to 'gas')
-rw-r--r--gas/ChangeLog5
-rw-r--r--gas/testsuite/gas/i386/i386.exp1
-rw-r--r--gas/testsuite/gas/i386/rela.d13
-rw-r--r--gas/testsuite/gas/i386/rela.s14
4 files changed, 33 insertions, 0 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog
index b3a2cfc..b04a764 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,5 +1,10 @@
2021-05-07 Jan Beulich <jbeulich@suse.com>
+ * testsuite/gas/i386/rela.s, testsuite/gas/i386/rela.d: New.
+ * testsuite/gas/i386/i386.exp: Run new test.
+
+2021-05-07 Jan Beulich <jbeulich@suse.com>
+
* config/tc-i386.c (output_disp): Use disps field instead of
imms one.
diff --git a/gas/testsuite/gas/i386/i386.exp b/gas/testsuite/gas/i386/i386.exp
index 234438e..39010bd 100644
--- a/gas/testsuite/gas/i386/i386.exp
+++ b/gas/testsuite/gas/i386/i386.exp
@@ -1246,6 +1246,7 @@ if [gas_64_check] then {
run_dump_test "reloc64"
run_list_test "reloc64" "--defsym _bad_=1"
run_dump_test "mixed-mode-reloc64"
+ run_dump_test "rela"
run_dump_test "x86-64-ifunc"
run_dump_test "x86-64-opcode-inval"
run_dump_test "x86-64-opcode-inval-intel"
diff --git a/gas/testsuite/gas/i386/rela.d b/gas/testsuite/gas/i386/rela.d
new file mode 100644
index 0000000..198f712
--- /dev/null
+++ b/gas/testsuite/gas/i386/rela.d
@@ -0,0 +1,13 @@
+#name: x86-64 rela relocs w/ non-zero relocated fields
+#objdump: -rsj .data
+
+.*: +file format .*
+
+RELOCATION RECORDS FOR \[\.data\]:
+
+OFFSET +TYPE +VALUE *
+0*0 R_X86_64_64 *q
+0*8 R_X86_64_32 *l
+
+Contents of section .data:
+ 0+0 11 ?11 ?11 ?11 22 ?22 ?22 ?22 33 ?33 ?33 ?33 44 ?44 ?44 ?44 .*
diff --git a/gas/testsuite/gas/i386/rela.s b/gas/testsuite/gas/i386/rela.s
new file mode 100644
index 0000000..28269fe
--- /dev/null
+++ b/gas/testsuite/gas/i386/rela.s
@@ -0,0 +1,14 @@
+# Note: This file is also used by an ld test case.
+
+ .text
+ .global _start
+_start:
+ ret
+
+ .data
+ .p2align 4
+l: .long 0x11111111, 0x22222222
+q: .quad 0x4444444433333333
+
+ .reloc l, BFD_RELOC_64, q
+ .reloc q, BFD_RELOC_32, l