1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
BITS 64
global x86ident
global __savident
extern foobar ; :proc
extern foobar2 ; :abs
extern foobar3 ; :qword
extern foobar4 ; :byte
[SECTION .data]
__savident dd 0
savidentptr dd __savident
savidentptr2 dq __savident
x86identptr dd x86ident
x86identptr2 dq x86ident
foobarptr dd foobar
foobarptr2 dq foobar
foobar2ptr dd foobar2
foobar2ptr2 dq foobar2
foobar3ptr dd foobar3
foobar3ptr2 dq foobar3
xptr dd x
xptr2 dq x
[SECTION .bss]
x resq 1
y resq 1
[SECTION .text]
x86ident:
; extern with :proc
; This instruction generates a different relocation than
; MASM does at present.
mov ebx, foobar ; WTF ML64.. this had []
mov rcx, qword foobar
lea rdx, [foobar wrt rip]
mov rax, [foobar+rcx]
mov rax, qword foobar
mov rbx, qword foobar
movzx rax, byte [foobar wrt rip]
movzx rax, byte [foobar+rax]
; local "proc"
; See note above
mov ebx, trap
mov rcx, qword trap
; MASM generates a REL32 reloc for this even though it's in
; the same section. I don't know why, as the call instruction
; below doesn't cause a reloc, so the linker can't be moving
; functions around within an object!
lea rdx, [trap wrt rip]
mov rax, [trap+rcx]
mov rax, qword trap
mov rbx, qword trap
; MASM generates a REL32 reloc for this even though it's in
; the same section. I don't know why, as the call instruction
; below doesn't cause a reloc, so the linker can't be moving
; functions around within an object!
movzx rax, byte [trap wrt rip]
movzx rax, byte [trap+rax]
; with :abs
;mov ebx,[foobar2]
;mov rcx,offset foobar2
;lea rdx, foobar2
;mov rax, qword ptr foobar2[rcx]
;mov rax, foobar2
;mov rbx, foobar2
;movzx rax, byte ptr foobar2
;movzx rax, byte ptr foobar2[rax]
; with :qword
; See note above
mov ebx, foobar3
mov ebx, [foobar3 wrt rip]
mov rcx, qword foobar3
lea rdx, [foobar3 wrt rip]
mov rax, [foobar3+rcx]
mov rax, [foobar3 wrt rip]
mov rbx, [foobar3 wrt rip]
movzx rax, byte [foobar3 wrt rip]
movzx rax, byte [foobar3+rax]
; local var (dword)
; See note above
mov ebx, __savident
mov ebx,[__savident wrt rip]
mov rcx, qword __savident
lea rdx, [__savident wrt rip]
mov rax, [__savident+rcx]
mov rax, [__savident wrt rip]
mov rbx, [__savident wrt rip]
movzx rax, byte [__savident wrt rip]
movzx rax, byte [__savident+rax]
; local var (qword)
; See note above
mov ebx, savidentptr2
mov ebx, [savidentptr2 wrt rip]
mov rcx, qword savidentptr2
lea rdx, [savidentptr2 wrt rip]
mov rax, [savidentptr2+rcx]
mov rax, [savidentptr2 wrt rip]
mov rbx, [savidentptr2 wrt rip]
movzx rax, byte [savidentptr2 wrt rip]
movzx rax, byte [savidentptr2+rax]
; bss local var (qword)
; See note above
mov ebx, y
mov ebx, [y wrt rip]
mov rcx, qword y
lea rdx, [y wrt rip]
mov rax, [y+rcx]
mov rax, [y wrt rip]
mov rbx, [y wrt rip]
movzx rax, byte [y wrt rip]
movzx rax, byte [y+rax]
call foobar
call trap
ret
trap: sub rsp, 256
int3
add rsp, 256
.end
[SECTION .pdata]
dd trap
dd trap.end wrt trap
dd $$xdatasym
[SECTION .xdata]
$$xdatasym:
db 1, 7, 2, 0, 7, 1, 0x20, 0
[SECTION _FOO]
foo_foobar3ptr dd foobar3
foo_foobar3ptr2 dq foobar3
mov ebx, [foobar3 wrt rip]
mov rcx, qword foobar3
lea rdx, [foobar3 wrt rip]
mov rax, [foobar3+rcx]
mov rax, [foobar3 wrt rip]
mov rbx, [foobar3 wrt rip]
movzx rax, byte [foobar3 wrt rip]
movzx rax, byte [foobar3+rax]
|