File: COFF_i386.s

package info (click to toggle)
llvm-toolchain-14 1%3A14.0.6-12
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,496,180 kB
  • sloc: cpp: 5,593,972; ansic: 986,872; asm: 585,869; python: 184,223; objc: 72,530; lisp: 31,119; f90: 27,793; javascript: 9,780; pascal: 9,762; sh: 9,482; perl: 7,468; ml: 5,432; awk: 3,523; makefile: 2,538; xml: 953; cs: 573; fortran: 567
file content (72 lines) | stat: -rw-r--r-- 2,068 bytes parent folder | download | duplicates (21)
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
// RUN: rm -rf %t && mkdir -p %t
// RUN: llvm-mc -triple i686-windows -filetype obj -o %t/COFF_i386.o %s
// RUN: llvm-rtdyld -triple i686-windows -dummy-extern _printf=0x7ffffffd \
// RUN:   -dummy-extern _ExitProcess=0x7fffffff \
// RUN:   -verify -check=%s %t/COFF_i386.o

	.text

	.def _main
		.scl 2
		.type 32
	.endef
	.global _main
_main:
rel1:
	call _function				// IMAGE_REL_I386_REL32
# rtdyld-check: decode_operand(rel1, 0) = (_function-_main-4-1)
	xorl %eax, %eax
rel12:
	jmp _printf
# rtdyld-check: decode_operand(rel12, 0)[31:0] = (_printf-_main-4-8)

	.def _function
		.scl 2
		.type 32
	.endef
_function:
rel2:
	pushl string
# rtdyld-check: decode_operand(rel3, 3) = \
# rtdyld-check:   stub_addr(COFF_i386.o/.text, __imp__ExitProcess)
# rtdyld-check: *{4}(stub_addr(COFF_i386.o/.text, __imp__ExitProcess)) = \
# rtdyld-check:   _ExitProcess
rel3:
	calll *__imp__ExitProcess       	// IMAGE_REL_I386_DIR32

	.data

	.global relocations
relocations:
rel5:
	.long _function@imgrel			// IMAGE_REL_I386_DIR32NB
# rtdyld-check: *{4}rel5 = _function - section_addr(COFF_i386.o, .text)
rel6:
# rtdyld-check: *{2}rel6 = 1
	.secidx rel5                            // IMAGE_REL_I386_SECTION
rel7:
# rtdyld-check: *{4}rel7 = string - section_addr(COFF_i386.o, .data)
	.secrel32 string			// IMAGE_REL_I386_SECREL

# Test that addends work.
rel8:
# rtdyld-check: *{4}rel8 = string
	.long string				// IMAGE_REL_I386_DIR32
rel9:
# rtdyld-check: *{4}rel9 = string+1
	.long string+1				// IMAGE_REL_I386_DIR32
rel10:
# rtdyld-check: *{4}rel10 = string - section_addr(COFF_i386.o, .text) + 1
	.long string@imgrel+1			// IMAGE_REL_I386_DIR32NB
rel11:
# rtdyld-check: *{4}rel11 = string - section_addr(COFF_i386.o, .data) + 1
	.long string@SECREL32+1			// IMAGE_REL_I386_SECREL

# We explicitly add padding to put string outside of the 16bit address space
# (absolute and as an offset from .data), so that relocations involving
# 32bit addresses / offsets are not accidentally truncated to 16 bits.
	.space 65536
	.global string
	.align 1
string:
	.asciz "Hello World!\n"