From 17c6c3b99156fe82c1e637e1a5fd9f163ac788c8 Mon Sep 17 00:00:00 2001 From: Jan Beulich Date: Fri, 7 May 2021 12:05:12 +0200 Subject: 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. --- ld/ChangeLog | 5 +++++ ld/testsuite/ld-x86-64/rela.d | 10 ++++++++++ ld/testsuite/ld-x86-64/x86-64.exp | 1 + 3 files changed, 16 insertions(+) create mode 100644 ld/testsuite/ld-x86-64/rela.d (limited to 'ld') diff --git a/ld/ChangeLog b/ld/ChangeLog index 998c403..d78c706 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,8 @@ +2021-05-07 Jan Beulich + + * testsuite/ld-x86-64/rela.d: New. + * testsuite/ld-x86-64/x86-64.exp: Run new test. + 2021-05-07 Nick Clifton * ldelfgen.c (compare_link_order): Ignore section size when diff --git a/ld/testsuite/ld-x86-64/rela.d b/ld/testsuite/ld-x86-64/rela.d new file mode 100644 index 0000000..ac91834 --- /dev/null +++ b/ld/testsuite/ld-x86-64/rela.d @@ -0,0 +1,10 @@ +#name: x86-64 rela relocs w/ non-zero relocated fields +#as: --64 +#source: ${srcdir}/../../../gas/testsuite/gas/i386/rela.s +#ld: -melf_x86_64 +#objdump: -sj .data + +.*: +file format .* + +Contents of section .data: + *[0-9a-f]*0 08 ?.. ?.. ?.. 00 ?00 ?00 ?00 00 ?.. ?.. ?.. 44 ?44 ?44 ?44 .* diff --git a/ld/testsuite/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp index 269f70d..17fd10e 100644 --- a/ld/testsuite/ld-x86-64/x86-64.exp +++ b/ld/testsuite/ld-x86-64/x86-64.exp @@ -262,6 +262,7 @@ run_dump_test "apic" run_dump_test "pcrel8" run_dump_test "pcrel16" run_dump_test "pcrel16-2" +run_dump_test "rela" run_dump_test "tlsgd2" run_dump_test "tlsgd3" run_dump_test "tlsgd12" -- cgit v1.1