mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-21 04:42:53 +08:00
14470f0755
For x32, we must encode "lea x@TLSDESC(%rip), %reg" with a REX prefix even if it isn't required. Otherwise linker can’t safely perform GDesc -> IE/LE optimization. X32 TLSDESC sequences can be: 40 8d 05 00 00 00 00 rex lea x@TLSDESC(%rip), %reg ... 67 ff 10 call *x@TLSCALL(%eax) or the same sequence as LP64: 48 8d 05 00 00 00 00 lea foo@TLSDESC(%rip), %reg ... ff 10 call *foo@TLSCALL(%rax) We need to support both sequences for x32. For both GDesc -> IE/LE transitions, 67 ff 10 call *x@TLSCALL(%eax) should relaxed to 0f 1f 00 nopl (%rax) For GDesc -> LE transition, 40 8d 05 00 00 00 00 rex lea x@TLSDESC(%rip), %reg should relaxed to 40 c7 c0 fc ff ff ff rex movl $x@tpoff, %reg For GDesc -> IE transition, 40 8d 05 00 00 00 00 rex lea x@TLSDESC(%rip), %reg should relaxed to 40 8b 05 00 00 00 00 rex movl x@gottpoff(%rip), %eax bfd/ PR ld/25416 * elf64-x86-64.c (elf_x86_64_check_tls_transition): Support "rex leal x@tlsdesc(%rip), %reg" and "call *x@tlsdesc(%eax)" in X32 mode. (elf_x86_64_relocate_section): In x32 mode, for GDesc -> LE transition, relax "rex leal x@tlsdesc(%rip), %reg" to "rex movl $x@tpoff, %reg", for GDesc -> IE transition, relax "rex leal x@tlsdesc(%rip), %reg" to "rex movl x@gottpoff(%rip), %eax". For both transitions, relax "call *(%eax)" to "nopl (%rax)". gas/ PR ld/25416 * config/tc-i386.c (output_insn): Add a dummy REX_OPCODE prefix for lea with R_X86_64_GOTPC32_TLSDESC relocation when generating x32 object. * testsuite/gas/i386/ilp32/x32-tls.d: Updated. * testsuite/gas/i386/ilp32/x32-tls.s: Add tests for lea with R_X86_64_GOTPC32_TLSDESC relocation. ld/ PR ld/25416 * testsuite/ld-x86-64/pr25416-1.s: New file * testsuite/ld-x86-64/pr25416-1a.d: Likewise. * testsuite/ld-x86-64/pr25416-1b.d: Likewise. * testsuite/ld-x86-64/pr25416-1.s: Likewise. * testsuite/ld-x86-64/pr25416-2.s: Likewise. * testsuite/ld-x86-64/pr25416-2a.d: Likewise. * testsuite/ld-x86-64/pr25416-2b.d: Likewise. * testsuite/ld-x86-64/pr25416-3.d: Likewise. * testsuite/ld-x86-64/pr25416-3.s: Likewise. * testsuite/ld-x86-64/pr25416-4.d: Likewise. * testsuite/ld-x86-64/pr25416-4.s: Likewise. * testsuite/ld-x86-64/pr25416-5a.c: Likewise. * testsuite/ld-x86-64/pr25416-5b.s: Likewise. * testsuite/ld-x86-64/pr25416-5c.s: Likewise. * testsuite/ld-x86-64/pr25416-5d.s: Likewise. * testsuite/ld-x86-64/pr25416-5e.s: Likewise. * testsuite/ld-x86-64/x86-64.exp: Run PR ld/25416 tests.
53 lines
869 B
ArmAsm
53 lines
869 B
ArmAsm
.text
|
|
.p2align 4
|
|
.globl test1
|
|
.type test1, @function
|
|
test1:
|
|
.cfi_startproc
|
|
subl $8, %esp
|
|
.cfi_def_cfa_offset 16
|
|
lea foo@TLSDESC(%rip), %eax
|
|
call *foo@TLSCALL(%eax)
|
|
addl %fs:0, %eax
|
|
cmpl %edi, (%eax)
|
|
jne .L5
|
|
addl $8, %esp
|
|
.cfi_remember_state
|
|
.cfi_def_cfa_offset 8
|
|
ret
|
|
.L5:
|
|
.cfi_restore_state
|
|
call abort@PLT
|
|
.cfi_endproc
|
|
.size test1, .-test1
|
|
.p2align 4
|
|
.globl test2
|
|
.type test2, @function
|
|
test2:
|
|
.cfi_startproc
|
|
subl $8, %esp
|
|
.cfi_def_cfa_offset 16
|
|
lea bar@TLSDESC(%rip), %eax
|
|
call *bar@TLSCALL(%eax)
|
|
addl %fs:0, %eax
|
|
cmpl %edi, (%eax)
|
|
jne .L9
|
|
addl $8, %esp
|
|
.cfi_remember_state
|
|
.cfi_def_cfa_offset 8
|
|
ret
|
|
.L9:
|
|
.cfi_restore_state
|
|
call abort@PLT
|
|
.cfi_endproc
|
|
.size test2, .-test2
|
|
.section .tdata,"awT",@progbits
|
|
.align 4
|
|
.hidden foo
|
|
.globl foo
|
|
.type foo, @object
|
|
.size foo, 4
|
|
foo:
|
|
.long 30
|
|
.section .note.GNU-stack,"",@progbits
|