binutils-gdb/gold/testsuite/x86_64_gd_to_le.s
H.J. Lu 00a17c6ad0 Gold: Handle R_X86_64_CODE_4_GOTPC32_TLSDESC/R_X86_64_CODE_4_GOTTPOFF
Handle R_X86_64_CODE_4_GOTTPOFF and R_X86_64_CODE_4_GOTPC32_TLSDESC.
Convert

	add	name@gottpoff(%rip), %reg
	mov	name@gottpoff(%rip), %reg

to

	add	$name@tpoff, %reg
	mov	$name@tpoff, %reg

and

	lea	name@tlsdesc(%rip), %reg

to

	mov     $name@tpoff, %reg
	mov	name@gottpoff(%rip), %reg

if the instruction is encoded with the REX2 prefix when possible.

elfcpp/

	* x86_64.h (R_X86_64_CODE_4_GOTTPOFF): New.
	(R_X86_64_CODE_4_GOTPC32_TLSDESC): Likewise.

gold/

	* x86_64.cc (Target_x86_64::optimize_tls_reloc): Handle
	R_X86_64_CODE_4_GOTPC32_TLSDESC and R_X86_64_CODE_4_GOTTPOFF.
	(Target_x86_64::Scan::get_reference_flags): Likewise.
	(Target_x86_64::Scan::local): Likewise.
	(Target_x86_64::Scan::global): Likewise.
	(Target_x86_64::Relocate::relocate): Likewise.
	(Target_x86_64::Relocate::relocate_tls): Likewise.
	(Target_x86_64::Relocate::tls_desc_gd_to_ie): Handle
	R_X86_64_CODE_4_GOTPC32_TLSDESC.
	(Target_x86_64::Relocate::tls_desc_gd_to_le): Likewise.
	(Target_x86_64::Relocate::tls_ie_to_le): Handle.
	R_X86_64_CODE_4_GOTTPOFF.
	* testsuite/Makefile.am: Add x86_64_ie_to_le test.
	* testsuite/Makefile.in: Regenerated.
	* testsuite/x86_64_gd_to_le.s: Add R_X86_64_CODE_4_GOTPC32_TLSDESC
	test.
	* testsuite/x86_64_gd_to_le.sh: Check GDesc to LE conversion.
	* testsuite/x86_64_ie_to_le.s: New file.
	* testsuite/x86_64_ie_to_le.sh: Likewise.
2023-12-28 08:47:17 -08:00

26 lines
452 B
ArmAsm

.text
.p2align 4
.globl _start
.type _start, @function
_start:
.cfi_startproc
subq $8, %rsp
.cfi_def_cfa_offset 16
leaq foo@TLSDESC(%rip), %r9
leaq foo@TLSDESC(%rip), %r29
movq %r9, %rax
call *foo@TLSCALL(%rax)
addq %fs:0, %rax
addq $8, %rsp
.cfi_def_cfa_offset 8
ret
.cfi_endproc
.size _start, .-_start
.section .tdata,"awT",@progbits
.align 4
.type foo, @object
.size foo, 4
foo:
.long 30
.section .note.GNU-stack,"",@progbits