145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgBITS 64
245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org
345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgglobal		x86ident
445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgglobal		__savident
545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgextern		foobar		; :proc
645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgextern		foobar2		; :abs
745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgextern		foobar3		; :qword
845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgextern		foobar4		; :byte
945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org
1045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org[SECTION .data]
1145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org__savident	dd 0              
1245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgsavidentptr	dd __savident
1345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgsavidentptr2	dq __savident
1445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgx86identptr	dd x86ident
1545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgx86identptr2	dq x86ident
1645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgfoobarptr	dd foobar
1745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgfoobarptr2	dq foobar
1845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgfoobar2ptr	dd foobar2
1945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgfoobar2ptr2	dq foobar2
2045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgfoobar3ptr	dd foobar3
2145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgfoobar3ptr2	dq foobar3
2245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgxptr		dd x
2345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgxptr2		dq x
2445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org
2545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org[SECTION .bss]
2645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgx		resq	1
2745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgy		resq	1
2845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org
2945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org[SECTION .text]
3045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgx86ident:
3145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		; extern with :proc
3245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		; This instruction generates a different relocation than
3345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		; MASM does at present.
3445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		mov	ebx, foobar		; WTF ML64.. this had []
3545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		mov	rcx, qword foobar
3645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		lea	rdx, [foobar wrt rip]
3745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		mov	rax, [foobar+rcx]
3845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		mov	rax, qword foobar
3945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		mov	rbx, qword foobar
4045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		movzx	rax, byte [foobar wrt rip]
4145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		movzx	rax, byte [foobar+rax]
4245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org
4345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		; local "proc"
4445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		; See note above
4545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		mov	ebx, trap
4645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		mov	rcx, qword trap
4745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		; MASM generates a REL32 reloc for this even though it's in
4845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		; the same section.  I don't know why, as the call instruction
4945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		; below doesn't cause a reloc, so the linker can't be moving
5045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		; functions around within an object!
5145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		lea	rdx, [trap wrt rip]
5245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		mov	rax, [trap+rcx]
5345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		mov	rax, qword trap
5445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		mov	rbx, qword trap
5545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		; MASM generates a REL32 reloc for this even though it's in
5645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		; the same section.  I don't know why, as the call instruction
5745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		; below doesn't cause a reloc, so the linker can't be moving
5845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		; functions around within an object!
5945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		movzx	rax, byte [trap wrt rip]
6045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		movzx	rax, byte [trap+rax]
6145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org
6245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		; with :abs
6345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		;mov	ebx,[foobar2]
6445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		;mov	rcx,offset foobar2
6545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		;lea	rdx, foobar2
6645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		;mov	rax, qword ptr foobar2[rcx]
6745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		;mov	rax, foobar2
6845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		;mov	rbx, foobar2
6945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		;movzx	rax, byte ptr foobar2
7045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		;movzx	rax, byte ptr foobar2[rax]
7145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org
7245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		; with :qword
7345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		; See note above
7445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		mov	ebx, foobar3
7545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		mov	ebx, [foobar3 wrt rip]
7645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		mov	rcx, qword foobar3
7745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		lea	rdx, [foobar3 wrt rip]
7845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		mov	rax, [foobar3+rcx]
7945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		mov	rax, [foobar3 wrt rip]
8045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		mov	rbx, [foobar3 wrt rip]
8145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		movzx	rax, byte [foobar3 wrt rip]
8245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		movzx	rax, byte [foobar3+rax]
8345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org
8445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		; local var (dword)
8545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		; See note above
8645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		mov	ebx, __savident
8745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		mov	ebx,[__savident wrt rip]
8845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		mov	rcx, qword __savident
8945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		lea	rdx, [__savident wrt rip]
9045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		mov	rax, [__savident+rcx]
9145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		mov	rax, [__savident wrt rip]
9245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		mov	rbx, [__savident wrt rip]
9345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		movzx	rax, byte [__savident wrt rip]
9445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		movzx	rax, byte [__savident+rax]
9545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org
9645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		; local var (qword)
9745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		; See note above
9845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		mov	ebx, savidentptr2
9945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		mov	ebx, [savidentptr2 wrt rip]
10045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		mov	rcx, qword savidentptr2
10145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		lea	rdx, [savidentptr2 wrt rip]
10245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		mov	rax, [savidentptr2+rcx]
10345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		mov	rax, [savidentptr2 wrt rip]
10445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		mov	rbx, [savidentptr2 wrt rip]
10545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		movzx	rax, byte [savidentptr2 wrt rip]
10645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		movzx	rax, byte [savidentptr2+rax]
10745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org
10845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		; bss local var (qword)
10945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		; See note above
11045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		mov	ebx, y
11145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		mov	ebx, [y wrt rip]
11245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		mov	rcx, qword y
11345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		lea	rdx, [y wrt rip]
11445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		mov	rax, [y+rcx]
11545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		mov	rax, [y wrt rip]
11645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		mov	rbx, [y wrt rip]
11745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		movzx	rax, byte [y wrt rip]
11845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		movzx	rax, byte [y+rax]
11945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org
12045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		call	foobar
12145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org
12245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		call	trap
12345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org
12445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		ret
12545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org
12645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgtrap:		sub	rsp, 256
12745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		int3
12845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		add	rsp, 256
12945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org.end
13045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org
13145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org[SECTION .pdata]
13245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgdd	trap
13345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgdd	trap.end wrt trap
13445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgdd	$$xdatasym
13545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org
13645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org[SECTION .xdata]
13745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org$$xdatasym:
13845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgdb	1, 7, 2, 0, 7, 1, 0x20, 0
13945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org
14045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org[SECTION _FOO]
14145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgfoo_foobar3ptr	dd foobar3
14245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgfoo_foobar3ptr2	dq foobar3
14345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		mov	ebx, [foobar3 wrt rip]
14445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		mov	rcx, qword foobar3
14545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		lea	rdx, [foobar3 wrt rip]
14645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		mov	rax, [foobar3+rcx]
14745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		mov	rax, [foobar3 wrt rip]
14845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		mov	rbx, [foobar3 wrt rip]
14945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		movzx	rax, byte [foobar3 wrt rip]
15045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org		movzx	rax, byte [foobar3+rax]
15145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org
152