aboutsummaryrefslogtreecommitdiff
path: root/modules/objfmts/elf/tests/amd64
diff options
context:
space:
mode:
Diffstat (limited to 'modules/objfmts/elf/tests/amd64')
-rw-r--r--modules/objfmts/elf/tests/amd64/Makefile.inc11
-rw-r--r--modules/objfmts/elf/tests/amd64/elf-rip.asm7
-rw-r--r--modules/objfmts/elf/tests/amd64/elf-rip.hex704
-rwxr-xr-xmodules/objfmts/elf/tests/amd64/elf_amd64_test.sh3
-rw-r--r--modules/objfmts/elf/tests/amd64/elfso64.asm90
-rw-r--r--modules/objfmts/elf/tests/amd64/elfso64.hex1680
-rw-r--r--modules/objfmts/elf/tests/amd64/gotpcrel.asm6
-rw-r--r--modules/objfmts/elf/tests/amd64/gotpcrel.hex720
8 files changed, 3221 insertions, 0 deletions
diff --git a/modules/objfmts/elf/tests/amd64/Makefile.inc b/modules/objfmts/elf/tests/amd64/Makefile.inc
new file mode 100644
index 0000000..deb54bc
--- /dev/null
+++ b/modules/objfmts/elf/tests/amd64/Makefile.inc
@@ -0,0 +1,11 @@
+TESTS += modules/objfmts/elf/tests/amd64/elf_amd64_test.sh
+
+EXTRA_DIST += modules/objfmts/elf/tests/amd64/elf_amd64_test.sh
+EXTRA_DIST += modules/objfmts/elf/tests/amd64/elf-rip.asm
+EXTRA_DIST += modules/objfmts/elf/tests/amd64/elf-rip.hex
+EXTRA_DIST += modules/objfmts/elf/tests/amd64/elfso64.asm
+EXTRA_DIST += modules/objfmts/elf/tests/amd64/elfso64.hex
+EXTRA_DIST += modules/objfmts/elf/tests/amd64/gotpcrel.asm
+EXTRA_DIST += modules/objfmts/elf/tests/amd64/gotpcrel.hex
+EXTRA_DIST += modules/objfmts/elf/tests/amd64/multiplefixup.asm
+EXTRA_DIST += modules/objfmts/elf/tests/amd64/multiplefixup.hex
diff --git a/modules/objfmts/elf/tests/amd64/elf-rip.asm b/modules/objfmts/elf/tests/amd64/elf-rip.asm
new file mode 100644
index 0000000..5f10f09
--- /dev/null
+++ b/modules/objfmts/elf/tests/amd64/elf-rip.asm
@@ -0,0 +1,7 @@
+[bits 64]
+[extern sym]
+mov eax, [rip]
+mov eax, [rip+2]
+mov eax, [rip+sym]
+mov eax, [sym wrt rip]
+call sym
diff --git a/modules/objfmts/elf/tests/amd64/elf-rip.hex b/modules/objfmts/elf/tests/amd64/elf-rip.hex
new file mode 100644
index 0000000..4294742
--- /dev/null
+++ b/modules/objfmts/elf/tests/amd64/elf-rip.hex
@@ -0,0 +1,704 @@
+7f
+45
+4c
+46
+02
+01
+01
+00
+00
+00
+00
+00
+00
+00
+00
+00
+01
+00
+3e
+00
+01
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+40
+01
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+40
+00
+00
+00
+00
+00
+40
+00
+06
+00
+01
+00
+8b
+05
+00
+00
+00
+00
+8b
+05
+02
+00
+00
+00
+8b
+05
+00
+00
+00
+00
+8b
+05
+00
+00
+00
+00
+e8
+00
+00
+00
+00
+00
+00
+00
+0e
+00
+00
+00
+00
+00
+00
+00
+0a
+00
+00
+00
+03
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+14
+00
+00
+00
+00
+00
+00
+00
+02
+00
+00
+00
+03
+00
+00
+00
+fc
+ff
+ff
+ff
+ff
+ff
+ff
+ff
+19
+00
+00
+00
+00
+00
+00
+00
+02
+00
+00
+00
+03
+00
+00
+00
+fc
+ff
+ff
+ff
+ff
+ff
+ff
+ff
+00
+2e
+74
+65
+78
+74
+00
+2e
+72
+65
+6c
+61
+2e
+74
+65
+78
+74
+00
+2e
+73
+74
+72
+74
+61
+62
+00
+2e
+73
+79
+6d
+74
+61
+62
+00
+2e
+73
+68
+73
+74
+72
+74
+61
+62
+00
+00
+2d
+00
+73
+79
+6d
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+01
+00
+00
+00
+04
+00
+f1
+ff
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+03
+00
+04
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+03
+00
+00
+00
+10
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+22
+00
+00
+00
+03
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+a8
+00
+00
+00
+00
+00
+00
+00
+2c
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+12
+00
+00
+00
+03
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+d4
+00
+00
+00
+00
+00
+00
+00
+07
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+1a
+00
+00
+00
+02
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+dc
+00
+00
+00
+00
+00
+00
+00
+60
+00
+00
+00
+00
+00
+00
+00
+02
+00
+00
+00
+03
+00
+00
+00
+08
+00
+00
+00
+00
+00
+00
+00
+18
+00
+00
+00
+00
+00
+00
+00
+01
+00
+00
+00
+01
+00
+00
+00
+06
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+40
+00
+00
+00
+00
+00
+00
+00
+1d
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+10
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+07
+00
+00
+00
+04
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+60
+00
+00
+00
+00
+00
+00
+00
+48
+00
+00
+00
+00
+00
+00
+00
+03
+00
+00
+00
+04
+00
+00
+00
+08
+00
+00
+00
+00
+00
+00
+00
+18
+00
+00
+00
+00
+00
+00
+00
diff --git a/modules/objfmts/elf/tests/amd64/elf_amd64_test.sh b/modules/objfmts/elf/tests/amd64/elf_amd64_test.sh
new file mode 100755
index 0000000..1f48a32
--- /dev/null
+++ b/modules/objfmts/elf/tests/amd64/elf_amd64_test.sh
@@ -0,0 +1,3 @@
+#! /bin/sh
+${srcdir}/out_test.sh elf_amd64_test modules/objfmts/elf/tests/amd64 "elf-amd64 objfmt" "-m amd64 -f elf" ".o"
+exit $?
diff --git a/modules/objfmts/elf/tests/amd64/elfso64.asm b/modules/objfmts/elf/tests/amd64/elfso64.asm
new file mode 100644
index 0000000..931c7ff
--- /dev/null
+++ b/modules/objfmts/elf/tests/amd64/elfso64.asm
@@ -0,0 +1,90 @@
+; This code is UNTESTED, and almost certainly DOES NOT WORK!
+; Do NOT use this as an example of how to write AMD64 shared libraries!
+; This code is simply to test the AMD64 ELF WRT relocations.
+
+; This file should test the following:
+; [1] Define and export a global text-section symbol
+; [2] Define and export a global data-section symbol
+; [3] Define and export a global BSS-section symbol
+; [4] Define a non-global text-section symbol
+; [5] Define a non-global data-section symbol
+; [6] Define a non-global BSS-section symbol
+; [7] Define a COMMON symbol
+; [8] Define a NASM local label
+; [9] Reference a NASM local label
+; [10] Import an external symbol
+; [11] Make a PC-relative call to an external symbol
+; [12] Reference a text-section symbol in the text section
+; [13] Reference a data-section symbol in the text section
+; [14] Reference a BSS-section symbol in the text section
+; [15] Reference a text-section symbol in the data section
+; [16] Reference a data-section symbol in the data section
+; [17] Reference a BSS-section symbol in the data section
+
+ [BITS 64]
+ [GLOBAL lrotate:function] ; [1]
+ [GLOBAL greet:function] ; [1]
+ [GLOBAL asmstr:data asmstr.end-asmstr] ; [2]
+ [GLOBAL textptr:data 4] ; [2]
+ [GLOBAL selfptr:data 4] ; [2]
+ [GLOBAL integer:data 4] ; [3]
+ [EXTERN printf] ; [10]
+ [COMMON commvar 4:4] ; [7]
+ [EXTERN _GLOBAL_OFFSET_TABLE_]
+
+ [SECTION .text]
+
+; prototype: long lrotate(long x, int num);
+lrotate: ; [1]
+ push rbp
+ mov rbp,rsp
+ mov rax,[rbp+8]
+ mov rcx,[rbp+12]
+.label rol rax,1 ; [4] [8]
+ loop .label ; [9] [12]
+ mov rsp,rbp
+ pop rbp
+ ret
+
+; prototype: void greet(void);
+greet push rbx ; we'll use RBX for GOT, so save it
+ mov rbx,[integer wrt ..gotpcrel wrt rip]
+ mov rax,[rbx] ; [14]
+ inc rax
+ mov rbx,[_GLOBAL_OFFSET_TABLE_ wrt ..gotpcrel wrt rip]
+ mov [rbx+localint wrt ..got],eax ; [14]
+ mov rax,[rbx+commvar wrt ..got]
+ push qword [rax]
+ mov rax,[rbx+localptr wrt ..got] ; [13]
+ push qword [rax]
+ mov rax,[rbx+integer wrt ..got] ; [1] [14]
+ push qword [rax]
+ lea rax,[rbx+printfstr wrt ..got]
+ push rax ; [13]
+ call printf wrt ..plt ; [11]
+ add rsp,16
+ pop rbx
+ ret
+
+ [SECTION .data]
+
+; a string
+asmstr db 'hello, world', 0 ; [2]
+.end
+
+; a string for Printf
+printfstr db "integer==%d, localint==%d, commvar=%d"
+ db 10, 0
+
+; some pointers
+localptr dd localint ; [5] [17]
+textptr dd greet wrt ..sym ; [15]
+selfptr dd selfptr wrt ..sym ; [16]
+
+ [SECTION .bss]
+
+; an integer
+integer resd 1 ; [3]
+
+; a local integer
+localint resd 1 ; [6]
diff --git a/modules/objfmts/elf/tests/amd64/elfso64.hex b/modules/objfmts/elf/tests/amd64/elfso64.hex
new file mode 100644
index 0000000..61f07b7
--- /dev/null
+++ b/modules/objfmts/elf/tests/amd64/elfso64.hex
@@ -0,0 +1,1680 @@
+7f
+45
+4c
+46
+02
+01
+01
+00
+00
+00
+00
+00
+00
+00
+00
+00
+01
+00
+3e
+00
+01
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+50
+04
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+40
+00
+00
+00
+00
+00
+40
+00
+09
+00
+01
+00
+55
+48
+89
+e5
+48
+8b
+45
+08
+48
+8b
+4d
+0c
+48
+d1
+c0
+e2
+fb
+48
+89
+ec
+5d
+c3
+53
+48
+8b
+1d
+00
+00
+00
+00
+48
+8b
+03
+48
+ff
+c0
+48
+8b
+1d
+00
+00
+00
+00
+89
+83
+00
+00
+00
+00
+48
+8b
+83
+00
+00
+00
+00
+ff
+30
+48
+8b
+83
+00
+00
+00
+00
+ff
+30
+48
+8b
+83
+00
+00
+00
+00
+ff
+30
+48
+8d
+83
+00
+00
+00
+00
+50
+e8
+00
+00
+00
+00
+48
+83
+c4
+10
+5b
+c3
+00
+1a
+00
+00
+00
+00
+00
+00
+00
+09
+00
+00
+00
+0f
+00
+00
+00
+fc
+ff
+ff
+ff
+ff
+ff
+ff
+ff
+27
+00
+00
+00
+00
+00
+00
+00
+09
+00
+00
+00
+12
+00
+00
+00
+fc
+ff
+ff
+ff
+ff
+ff
+ff
+ff
+2d
+00
+00
+00
+00
+00
+00
+00
+03
+00
+00
+00
+06
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+34
+00
+00
+00
+00
+00
+00
+00
+03
+00
+00
+00
+11
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+3d
+00
+00
+00
+00
+00
+00
+00
+03
+00
+00
+00
+05
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+46
+00
+00
+00
+00
+00
+00
+00
+03
+00
+00
+00
+0f
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+4f
+00
+00
+00
+00
+00
+00
+00
+03
+00
+00
+00
+04
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+55
+00
+00
+00
+00
+00
+00
+00
+04
+00
+00
+00
+10
+00
+00
+00
+fc
+ff
+ff
+ff
+ff
+ff
+ff
+ff
+68
+65
+6c
+6c
+6f
+2c
+20
+77
+6f
+72
+6c
+64
+00
+69
+6e
+74
+65
+67
+65
+72
+3d
+3d
+25
+64
+2c
+20
+6c
+6f
+63
+61
+6c
+69
+6e
+74
+3d
+3d
+25
+64
+2c
+20
+63
+6f
+6d
+6d
+76
+61
+72
+3d
+25
+64
+0a
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+34
+00
+00
+00
+00
+00
+00
+00
+0a
+00
+00
+00
+02
+00
+00
+00
+04
+00
+00
+00
+00
+00
+00
+00
+38
+00
+00
+00
+00
+00
+00
+00
+0a
+00
+00
+00
+0b
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+3c
+00
+00
+00
+00
+00
+00
+00
+0a
+00
+00
+00
+0e
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+2e
+74
+65
+78
+74
+00
+2e
+64
+61
+74
+61
+00
+2e
+62
+73
+73
+00
+2e
+72
+65
+6c
+61
+2e
+74
+65
+78
+74
+00
+2e
+72
+65
+6c
+61
+2e
+64
+61
+74
+61
+00
+2e
+73
+74
+72
+74
+61
+62
+00
+2e
+73
+79
+6d
+74
+61
+62
+00
+2e
+73
+68
+73
+74
+72
+74
+61
+62
+00
+00
+00
+00
+2d
+00
+6c
+72
+6f
+74
+61
+74
+65
+00
+67
+72
+65
+65
+74
+00
+61
+73
+6d
+73
+74
+72
+00
+74
+65
+78
+74
+70
+74
+72
+00
+73
+65
+6c
+66
+70
+74
+72
+00
+69
+6e
+74
+65
+67
+65
+72
+00
+70
+72
+69
+6e
+74
+66
+00
+63
+6f
+6d
+6d
+76
+61
+72
+00
+5f
+47
+4c
+4f
+42
+41
+4c
+5f
+4f
+46
+46
+53
+45
+54
+5f
+54
+41
+42
+4c
+45
+5f
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+01
+00
+00
+00
+04
+00
+f1
+ff
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+03
+00
+08
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+03
+00
+06
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+06
+00
+0d
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+06
+00
+34
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+08
+00
+04
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+04
+00
+0c
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+06
+00
+0d
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+03
+00
+04
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+03
+00
+00
+00
+12
+00
+04
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+0b
+00
+00
+00
+12
+00
+04
+00
+16
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+11
+00
+00
+00
+11
+00
+06
+00
+00
+00
+00
+00
+00
+00
+00
+00
+0d
+00
+00
+00
+00
+00
+00
+00
+18
+00
+00
+00
+11
+00
+06
+00
+38
+00
+00
+00
+00
+00
+00
+00
+04
+00
+00
+00
+00
+00
+00
+00
+20
+00
+00
+00
+11
+00
+06
+00
+3c
+00
+00
+00
+00
+00
+00
+00
+04
+00
+00
+00
+00
+00
+00
+00
+28
+00
+00
+00
+11
+00
+08
+00
+00
+00
+00
+00
+00
+00
+00
+00
+04
+00
+00
+00
+00
+00
+00
+00
+30
+00
+00
+00
+10
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+37
+00
+00
+00
+10
+00
+f2
+ff
+04
+00
+00
+00
+00
+00
+00
+00
+04
+00
+00
+00
+00
+00
+00
+00
+3f
+00
+00
+00
+10
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+38
+00
+00
+00
+03
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+e8
+01
+00
+00
+00
+00
+00
+00
+42
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+28
+00
+00
+00
+03
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+2c
+02
+00
+00
+00
+00
+00
+00
+55
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+30
+00
+00
+00
+02
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+84
+02
+00
+00
+00
+00
+00
+00
+c8
+01
+00
+00
+00
+00
+00
+00
+02
+00
+00
+00
+0a
+00
+00
+00
+08
+00
+00
+00
+00
+00
+00
+00
+18
+00
+00
+00
+00
+00
+00
+00
+01
+00
+00
+00
+01
+00
+00
+00
+06
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+40
+00
+00
+00
+00
+00
+00
+00
+5f
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+10
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+12
+00
+00
+00
+04
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+a0
+00
+00
+00
+00
+00
+00
+00
+c0
+00
+00
+00
+00
+00
+00
+00
+03
+00
+00
+00
+04
+00
+00
+00
+08
+00
+00
+00
+00
+00
+00
+00
+18
+00
+00
+00
+00
+00
+00
+00
+07
+00
+00
+00
+01
+00
+00
+00
+03
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+60
+01
+00
+00
+00
+00
+00
+00
+40
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+04
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+1d
+00
+00
+00
+04
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+a0
+01
+00
+00
+00
+00
+00
+00
+48
+00
+00
+00
+00
+00
+00
+00
+03
+00
+00
+00
+06
+00
+00
+00
+08
+00
+00
+00
+00
+00
+00
+00
+18
+00
+00
+00
+00
+00
+00
+00
+0d
+00
+00
+00
+08
+00
+00
+00
+03
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+08
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+04
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
diff --git a/modules/objfmts/elf/tests/amd64/gotpcrel.asm b/modules/objfmts/elf/tests/amd64/gotpcrel.asm
new file mode 100644
index 0000000..c3d1238
--- /dev/null
+++ b/modules/objfmts/elf/tests/amd64/gotpcrel.asm
@@ -0,0 +1,6 @@
+var:
+mov rax, [var wrt ..got]
+mov rax, [var wrt ..gotpcrel] ; should be error/warning?
+mov rax, [rel var wrt ..got] ; automatic promotion to GOTPCREL
+mov rax, [rel var wrt ..gotpcrel]
+
diff --git a/modules/objfmts/elf/tests/amd64/gotpcrel.hex b/modules/objfmts/elf/tests/amd64/gotpcrel.hex
new file mode 100644
index 0000000..1ad9424
--- /dev/null
+++ b/modules/objfmts/elf/tests/amd64/gotpcrel.hex
@@ -0,0 +1,720 @@
+7f
+45
+4c
+46
+02
+01
+01
+00
+00
+00
+00
+00
+00
+00
+00
+00
+01
+00
+3e
+00
+01
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+50
+01
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+40
+00
+00
+00
+00
+00
+40
+00
+06
+00
+01
+00
+48
+8b
+04
+25
+00
+00
+00
+00
+48
+8b
+04
+25
+00
+00
+00
+00
+48
+8b
+05
+00
+00
+00
+00
+48
+8b
+05
+00
+00
+00
+00
+00
+00
+04
+00
+00
+00
+00
+00
+00
+00
+03
+00
+00
+00
+02
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+0c
+00
+00
+00
+00
+00
+00
+00
+09
+00
+00
+00
+02
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+13
+00
+00
+00
+00
+00
+00
+00
+09
+00
+00
+00
+02
+00
+00
+00
+fc
+ff
+ff
+ff
+ff
+ff
+ff
+ff
+1a
+00
+00
+00
+00
+00
+00
+00
+09
+00
+00
+00
+02
+00
+00
+00
+fc
+ff
+ff
+ff
+ff
+ff
+ff
+ff
+00
+2e
+74
+65
+78
+74
+00
+2e
+72
+65
+6c
+61
+2e
+74
+65
+78
+74
+00
+2e
+73
+74
+72
+74
+61
+62
+00
+2e
+73
+79
+6d
+74
+61
+62
+00
+2e
+73
+68
+73
+74
+72
+74
+61
+62
+00
+00
+2d
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+01
+00
+00
+00
+04
+00
+f1
+ff
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+04
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+03
+00
+04
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+22
+00
+00
+00
+03
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+c0
+00
+00
+00
+00
+00
+00
+00
+2c
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+12
+00
+00
+00
+03
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+ec
+00
+00
+00
+00
+00
+00
+00
+03
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+1a
+00
+00
+00
+02
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+f0
+00
+00
+00
+00
+00
+00
+00
+60
+00
+00
+00
+00
+00
+00
+00
+02
+00
+00
+00
+04
+00
+00
+00
+08
+00
+00
+00
+00
+00
+00
+00
+18
+00
+00
+00
+00
+00
+00
+00
+01
+00
+00
+00
+01
+00
+00
+00
+06
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+40
+00
+00
+00
+00
+00
+00
+00
+1e
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+10
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+07
+00
+00
+00
+04
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+60
+00
+00
+00
+00
+00
+00
+00
+60
+00
+00
+00
+00
+00
+00
+00
+03
+00
+00
+00
+04
+00
+00
+00
+08
+00
+00
+00
+00
+00
+00
+00
+18
+00
+00
+00
+00
+00
+00
+00