xref: /illumos-gate/usr/src/test/elf-tests/tests/relocs/amd64/gotpcrelx/gotpcrel.s (revision 2c4055ebe2826777af400387612994d8bf26d113)
1*2c4055ebSRichard Lowe	.text
2*2c4055ebSRichard Lowe	.globl	foo
3*2c4055ebSRichard Lowe	.section	.rodata
4*2c4055ebSRichard Lowefoo_addr:
5*2c4055ebSRichard Lowe	.string	"string"
6*2c4055ebSRichard Lowe
7*2c4055ebSRichard Lowe	.section	.data.rel.local,"aw",@progbits
8*2c4055ebSRichard Lowe	.align 8
9*2c4055ebSRichard Lowe	.type	foo, @object
10*2c4055ebSRichard Lowe	.size	foo, 8
11*2c4055ebSRichard Lowefoo:
12*2c4055ebSRichard Lowe	.quad	foo_addr
13*2c4055ebSRichard Lowe
14*2c4055ebSRichard Lowe	.text
15*2c4055ebSRichard Lowe	.globl	main
16*2c4055ebSRichard Lowe	.type	main, @function
17*2c4055ebSRichard Lowemain:
18*2c4055ebSRichard Lowe	pushq	%rbp
19*2c4055ebSRichard Lowe	movq	%rsp, %rbp
20*2c4055ebSRichard Lowe	subq	$16, %rsp
21*2c4055ebSRichard Lowe	movl	%edi, -4(%rbp)
22*2c4055ebSRichard Lowe	movq	%rsi, -16(%rbp)
23*2c4055ebSRichard Lowe	/*
24*2c4055ebSRichard Lowe	 * We do this to explicitly _NOT_ get a REX prefix.
25*2c4055ebSRichard Lowe	 * This relies on our load address to actually _work_, and is otherwise
26*2c4055ebSRichard Lowe	 * disgusting.
27*2c4055ebSRichard Lowe	 */
28*2c4055ebSRichard Lowe	movl	foo@GOTPCREL(%rip), %eax
29*2c4055ebSRichard Lowe	movq	(%rax), %rax
30*2c4055ebSRichard Lowe	movq	%rax, %rdi
31*2c4055ebSRichard Lowe	call	puts@PLT
32*2c4055ebSRichard Lowe	movl	$0, %eax
33*2c4055ebSRichard Lowe	leave
34*2c4055ebSRichard Lowe	ret
35*2c4055ebSRichard Lowe	.size	main, .-main
36