aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2024-09-22 17:06:45 +0800
committerH.J. Lu <hjl.tools@gmail.com>2024-09-23 03:45:19 +0800
commit1b714c14e40f37ea8ea02a4998c4d95f25aff7f3 (patch)
tree87c9452df802c8983479585f8a0225df718d4bce /ld
parent104ee502450af85428012e1d3bde42d033024f22 (diff)
downloadbinutils-1b714c14e40f37ea8ea02a4998c4d95f25aff7f3.zip
binutils-1b714c14e40f37ea8ea02a4998c4d95f25aff7f3.tar.gz
binutils-1b714c14e40f37ea8ea02a4998c4d95f25aff7f3.tar.bz2
x86: Turn PLT32 to PC32 only for PC-relative relocations
commit 292676c15a615b5a95bede9ee91004d3f7ee7dfd Author: H.J. Lu <hjl.tools@gmail.com> Date: Thu Feb 13 13:44:17 2020 -0800 x86: Resolve PLT32 reloc aganst local symbol to section resolved PLT32 relocation against local symbol to section and commit 2585b7a5ce5830e60a089aa2316a329558902f0c Author: H.J. Lu <hjl.tools@gmail.com> Date: Sun Jul 19 06:51:19 2020 -0700 x86: Change PLT32 reloc against section to PC32 turned PLT32 relocation against section into PC32 relocation. But these transformations are valid only for PC-relative relocations. Add fx_pcrel check for PC-relative relocations when performing these transformations to keep PLT32 relocation in `movq $foo@PLT, %rax`. gas/ PR gas/32196 * config/tc-i386.c (tc_i386_fix_adjustable): Return fixP->fx_pcrel for PLT32 relocations. (i386_validate_fix): Turn PLT32 relocation into PC32 relocation only if fixp->fx_pcrel is set. * testsuite/gas/i386/reloc32.d: Updated. * testsuite/gas/i386/reloc64.d: Likewise. * testsuite/gas/i386/reloc32.s: Add PR gas/32196 test. * testsuite/gas/i386/reloc64.s: Likewise. ld/ PR gas/32196 * testsuite/ld-x86-64/plt3.s: New file. * testsuite/ld-x86-64/x86-64.exp: Run plt3. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Diffstat (limited to 'ld')
-rw-r--r--ld/testsuite/ld-x86-64/plt3.s27
-rw-r--r--ld/testsuite/ld-x86-64/x86-64.exp8
2 files changed, 35 insertions, 0 deletions
diff --git a/ld/testsuite/ld-x86-64/plt3.s b/ld/testsuite/ld-x86-64/plt3.s
new file mode 100644
index 0000000..c3a29b5
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/plt3.s
@@ -0,0 +1,27 @@
+ .text
+ .global _start
+_start:
+ movq $foo@PLT, %rax
+ leaq -11(%rip), %rbx
+ leaq (%rbx, %rax), %rax
+ call *%rax
+
+ # Write out "PASS\n".
+ movl $5, %edx
+ movl $.LC0, %esi
+ movl $1, %edi
+ movl $1, %eax
+ syscall
+
+ # exit
+ movq $60, %rax
+ movq $0, %rdi
+ syscall
+
+foo:
+ ret
+
+ .section .rodata.str1.1,"aMS",@progbits,1
+.LC0:
+ .string "PASS\n"
+ .section .note.GNU-stack,"",@progbits
diff --git a/ld/testsuite/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp
index cf78fff..1a6754d 100644
--- a/ld/testsuite/ld-x86-64/x86-64.exp
+++ b/ld/testsuite/ld-x86-64/x86-64.exp
@@ -1929,6 +1929,14 @@ if { [isnative] && [check_compiler_available] } {
"pr32189" \
"pass.out" \
] \
+ [list \
+ "Run plt3" \
+ "$NOPIE_LDFLAGS -nostdlib -nostartfiles" \
+ "" \
+ { plt3.s } \
+ "plt3" \
+ "pass.out" \
+ ] \
]
# Run-time tests which require working ifunc attribute support.