1 ; RUN: llc %s -mtriple=armv7-linux-gnueabi -relocation-model=pic -filetype=obj -o - | \
2 ; RUN: elf-dump --dump-section-data | FileCheck -check-prefix=PIC01 %s
4 ;; FIXME: Reduce this test further, or even better,
5 ;; redo as .s -> .o test once ARM AsmParser is working better
7 ; ModuleID = 'large2.pnacl.bc'
8 target triple = "armv7-none-linux-gnueabi"
10 %struct._Bigint = type { %struct._Bigint*, i32, i32, i32, i32, [1 x i32] }
11 %struct.__FILE = type { i8*, i32, i32, i16, i16, %struct.__sbuf, i32, %struct._reent*, i8*, i32 (%struct._reent*, i8*, i8*, i32)*, i32 (%struct._reent*, i8*, i8*, i32)*, i32 (%struct._reent*, i8*, i32, i32)*, i32 (%struct._reent*, i8*)*, %struct.__sbuf, i8*, i32, [3 x i8], [1 x i8], %struct.__sbuf, i32, i32, %struct._flock_t, %struct._mbstate_t, i32 }
12 %struct.__sbuf = type { i8*, i32 }
13 %struct.__tm = type { i32, i32, i32, i32, i32, i32, i32, i32, i32 }
14 %struct._atexit = type { %struct._atexit*, i32, [32 x void ()*], %struct._on_exit_args* }
15 %struct._flock_t = type { i32, i32, i32, i32, i32 }
16 %struct._glue = type { %struct._glue*, i32, %struct.__FILE* }
17 %struct._mbstate_t = type { i32, %union.anon }
18 %struct._misc_reent = type { i8*, %struct._mbstate_t, %struct._mbstate_t, %struct._mbstate_t, [8 x i8], i32, %struct._mbstate_t, %struct._mbstate_t, %struct._mbstate_t, %struct._mbstate_t, %struct._mbstate_t }
19 %struct._mprec = type { %struct._Bigint*, i32, %struct._Bigint*, %struct._Bigint** }
20 %struct._on_exit_args = type { [32 x i8*], [32 x i8*], i32, i32 }
21 %struct._rand48 = type { [3 x i16], [3 x i16], i16, i64 }
22 %struct._reent = type { %struct.__FILE*, %struct.__FILE*, %struct.__FILE*, i32, i32, i8*, i32, i32, i8*, %struct._mprec*, void (%struct._reent*)*, i32, i32, i8*, %struct._rand48*, %struct.__tm*, i8*, void (i32)**, %struct._atexit*, %struct._atexit, %struct._glue, %struct.__FILE*, %struct._misc_reent*, i8* }
23 %union.anon = type { i32 }
25 @buf = constant [2 x i8] c"x\00", align 4
26 @_impure_ptr = external thread_local global %struct._reent*
27 @.str = private constant [22 x i8] c"This should fault...\0A\00", align 4
28 @.str1 = private constant [40 x i8] c"We're still running. This is not good.\0A\00", align 4
30 define i32 @main() nounwind {
32 %0 = load %struct._reent** @_impure_ptr, align 4
33 %1 = getelementptr inbounds %struct._reent* %0, i32 0, i32 1
34 %2 = load %struct.__FILE** %1, align 4
35 %3 = bitcast %struct.__FILE* %2 to i8*
36 %4 = tail call i32 @fwrite(i8* getelementptr inbounds ([22 x i8]* @.str, i32 0, i32 0), i32 1, i32 21, i8* %3) nounwind
37 %5 = load %struct._reent** @_impure_ptr, align 4
38 %6 = getelementptr inbounds %struct._reent* %5, i32 0, i32 1
39 %7 = load %struct.__FILE** %6, align 4
40 %8 = tail call i32 @fflush(%struct.__FILE* %7) nounwind
41 store i8 121, i8* getelementptr inbounds ([2 x i8]* @buf, i32 0, i32 0), align 4
42 %9 = load %struct._reent** @_impure_ptr, align 4
43 %10 = getelementptr inbounds %struct._reent* %9, i32 0, i32 1
44 %11 = load %struct.__FILE** %10, align 4
45 %12 = bitcast %struct.__FILE* %11 to i8*
46 %13 = tail call i32 @fwrite(i8* getelementptr inbounds ([40 x i8]* @.str1, i32 0, i32 0), i32 1, i32 39, i8* %12) nounwind
51 ; PIC01: Relocation 0x00000000
52 ; PIC01-NEXT: 'r_offset', 0x0000001c
54 ; PIC01-NEXT: 'r_type', 0x0000001b
57 ; PIC01: Relocation 0x00000001
58 ; PIC01-NEXT: 'r_offset', 0x00000038
60 ; PIC01-NEXT: 'r_type', 0x0000001b
62 ; PIC01: Relocation 0x00000002
63 ; PIC01-NEXT: 'r_offset', 0x00000044
65 ; PIC01-NEXT: 'r_type', 0x0000001b
67 ; PIC01: Relocation 0x00000003
68 ; PIC01-NEXT: 'r_offset', 0x00000070
70 ; PIC01-NEXT: 'r_type', 0x0000001b
72 ; PIC01: Relocation 0x00000004
73 ; PIC01-NEXT: 'r_offset', 0x0000007c
75 ; PIC01-NEXT: 'r_type', 0x00000019
78 ; PIC01: Relocation 0x00000005
79 ; PIC01-NEXT: 'r_offset', 0x00000080
81 ; PIC01-NEXT: 'r_type', 0x00000018
83 ; PIC01: Relocation 0x00000006
84 ; PIC01-NEXT: 'r_offset', 0x00000084
86 ; PIC01-NEXT: 'r_type', 0x00000068
88 ; PIC01: Relocation 0x00000007
89 ; PIC01-NEXT: 'r_offset', 0x00000088
91 ; PIC01-NEXT: 'r_type', 0x0000001a
93 ; PIC01: Relocation 0x00000008
94 ; PIC01-NEXT: 'r_offset', 0x0000008c
96 ; PIC01-NEXT: 'r_type', 0x00000018
98 declare i32 @fwrite(i8* nocapture, i32, i32, i8* nocapture) nounwind
100 declare i32 @fflush(%struct.__FILE* nocapture) nounwind