blob: 18823f8b29a1317ec87e3e59a723b46df17b3267 [file] [log] [blame]
Andy Ayers9e5c8512015-05-14 01:10:41 +00001; Verify the assembler produces the expected expressions
2; RUN: llc -mtriple=x86_64-pc-win32 %s -o - | FileCheck %s
3; Verify the .fix data section conveys the right offsets and the right relocations
4; RUN: llc -mtriple=x86_64-pc-win32 -filetype=obj %s -o - | llvm-readobj -relocations -expand-relocs -sections -section-data | FileCheck %s --check-prefix=READOBJ
5
6;;;; some globals
7
8@g1 = constant i32 1;
9@g2 = constant i32 2;
10@g3 = constant i32 3;
11@g4 = constant i32 4;
12@__ImageBase = external global i64*;
13
14;;;; cross-section relative relocations
15
16; CHECK: .quad (g3-t1)+4
17@t1 = global i64 add(i64 sub(i64 ptrtoint(i32* @g3 to i64), i64 ptrtoint(i64* @t1 to i64)), i64 4), section ".fix"
18; CHECK: .quad g3-t2
19@t2 = global i64 sub(i64 ptrtoint(i32* @g3 to i64), i64 ptrtoint(i64* @t2 to i64)), section ".fix"
20; CHECK: .quad (g3-t3)-4
21@t3 = global i64 sub(i64 sub(i64 ptrtoint(i32* @g3 to i64), i64 ptrtoint(i64* @t3 to i64)), i64 4), section ".fix"
22; CHECK: .long g3-t4
23@t4 = global i32 trunc(i64 sub(i64 ptrtoint(i32* @g3 to i64), i64 ptrtoint(i32* @t4 to i64)) to i32), section ".fix"
24
25;;;; image base relocation
26
27; CHECK: .long g3@IMGREL
28@t5 = global i32 trunc(i64 sub(i64 ptrtoint(i32* @g3 to i64), i64 ptrtoint(i64** @__ImageBase to i64)) to i32), section ".fix"
29
30;;;; cross-section relative with source offset
31
32%struct.EEType = type { [2 x i8], i64, i32}
33
34; CHECK: .long g3-(t6+16)
35@t6 = global %struct.EEType {
36 [2 x i8] c"\01\02",
37 i64 256,
38 i32 trunc(i64 sub(i64 ptrtoint(i32* @g3 to i64), i64 ptrtoint(i32* getelementptr inbounds (%struct.EEType, %struct.EEType* @t6, i32 0, i32 2) to i64)) to i32 )
39}, section ".fix"
40
41; READOBJ: Section {
42; READOBJ: Number: 5
43; READOBJ: Name: .fix (2E 66 69 78 00 00 00 00)
44; READOBJ: VirtualSize: 0x0
45; READOBJ: VirtualAddress: 0x0
46; READOBJ: RawDataSize: 56
47; READOBJ: PointerToRawData: 0xEC
48; READOBJ: PointerToRelocations: 0x124
49; READOBJ: PointerToLineNumbers: 0x0
50; READOBJ: RelocationCount: 6
51; READOBJ: LineNumberCount: 0
52; READOBJ: Characteristics [ (0xC0500040)
53; READOBJ: IMAGE_SCN_ALIGN_16BYTES (0x500000)
54; READOBJ: IMAGE_SCN_CNT_INITIALIZED_DATA (0x40)
55; READOBJ: IMAGE_SCN_MEM_READ (0x40000000)
56; READOBJ: IMAGE_SCN_MEM_WRITE (0x80000000)
57; READOBJ: ]
58; READOBJ: SectionData (
59; READOBJ: 0000: 10000000 00000000 0C000000 00000000 |................|
60; READOBJ: 0010: 08000000 00000000 0C000000 00000000 |................|
61; READOBJ: 0020: 01020000 00000000 00010000 00000000 |................|
62; READOBJ: 0030: 0C000000 00000000 |........|
63; READOBJ: )
64; READOBJ: }
65; READOBJ: ]
66; READOBJ: Relocations [
67; READOBJ: Section (5) .fix {
68; READOBJ: Relocation {
69; READOBJ: Offset: 0x0
70; READOBJ: Type: IMAGE_REL_AMD64_REL32 (4)
71; READOBJ: Symbol: .rdata
72; READOBJ: }
73; READOBJ: Relocation {
74; READOBJ: Offset: 0x8
75; READOBJ: Type: IMAGE_REL_AMD64_REL32 (4)
76; READOBJ: Symbol: .rdata
77; READOBJ: }
78; READOBJ: Relocation {
79; READOBJ: Offset: 0x10
80; READOBJ: Type: IMAGE_REL_AMD64_REL32 (4)
81; READOBJ: Symbol: .rdata
82; READOBJ: }
83; READOBJ: Relocation {
84; READOBJ: Offset: 0x18
85; READOBJ: Type: IMAGE_REL_AMD64_REL32 (4)
86; READOBJ: Symbol: .rdata
87; READOBJ: }
88; READOBJ: Relocation {
89; READOBJ: Offset: 0x1C
90; READOBJ: Type: IMAGE_REL_AMD64_ADDR32NB (3)
91; READOBJ: Symbol: g3
92; READOBJ: }
93; READOBJ: Relocation {
94; READOBJ: Offset: 0x30
95; READOBJ: Type: IMAGE_REL_AMD64_REL32 (4)
96; READOBJ: Symbol: .rdata
97; READOBJ: }