summaryrefslogtreecommitdiffstats
path: root/lld/test/wasm/init-fini.ll
blob: bdae29811d8ef28f3037e9fcedc20f3e110dcf07 (plain)
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
; RUN: llc -mtriple=wasm32-unknown-unknown-wasm -filetype=obj -o %t.o %s
; RUN: llc -mtriple=wasm32-unknown-unknown-wasm -filetype=obj %S/Inputs/global-ctor-dtor.ll -o %t.global-ctor-dtor.o

define hidden void @func1() {
entry:
  ret void
}

define hidden void @func2() {
entry:
  ret void
}

define void @__cxa_atexit() {
  ret void
}

define hidden void @_start() {
entry:
  ret void
}

@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @func1, i8* null }]

@llvm.global_dtors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @func2, i8* null }]

; RUN: lld -flavor wasm %t.o %t.global-ctor-dtor.o -o %t.wasm
; RUN: obj2yaml %t.wasm | FileCheck %s

; CHECK:          Name:            linking
; CHECK-NEXT:     DataSize:        0
; CHECK-NEXT:   - Type:            CUSTOM
; CHECK-NEXT:     Name:            name
; CHECK-NEXT:     FunctionNames:   
; CHECK-NEXT:       - Index:           0
; CHECK-NEXT:         Name:            func1
; CHECK-NEXT:       - Index:           1
; CHECK-NEXT:         Name:            func2
; CHECK-NEXT:       - Index:           2
; CHECK-NEXT:         Name:            __cxa_atexit
; CHECK-NEXT:       - Index:           3
; CHECK-NEXT:         Name:            _start
; CHECK-NEXT:       - Index:           4
; CHECK-NEXT:         Name:            .Lcall_dtors
; CHECK-NEXT:       - Index:           5
; CHECK-NEXT:         Name:            .Lregister_call_dtors
; CHECK-NEXT:       - Index:           6
; CHECK-NEXT:         Name:            .Lbitcast
; CHECK-NEXT:       - Index:           7
; CHECK-NEXT:         Name:            myctor
; CHECK-NEXT:       - Index:           8
; CHECK-NEXT:         Name:            mydtor
; CHECK-NEXT:       - Index:           9
; CHECK-NEXT:         Name:            .Lcall_dtors
; CHECK-NEXT:       - Index:           10
; CHECK-NEXT:         Name:            .Lregister_call_dtors
; CHECK-NEXT: ...


; RUN: lld -flavor wasm -r %t.o %t.global-ctor-dtor.o -o %t.reloc.wasm
; RUN: obj2yaml %t.reloc.wasm | FileCheck -check-prefix=RELOC %s

; RELOC:          Name:            linking
; RELOC-NEXT:     DataSize:        0
; RELOC-NEXT:     InitFunctions:   
; RELOC-NEXT:       - Priority:        65535
; RELOC-NEXT:         FunctionIndex:   0
; RELOC-NEXT:       - Priority:        65535
; RELOC-NEXT:         FunctionIndex:   5
; RELOC-NEXT:       - Priority:        65535
; RELOC-NEXT:         FunctionIndex:   7
; RELOC-NEXT:       - Priority:        65535
; RELOC-NEXT:         FunctionIndex:   10
; RELOC-NEXT:   - Type:            CUSTOM
; RELOC-NEXT:     Name:            name
; RELOC-NEXT:     FunctionNames:   
; RELOC-NEXT:       - Index:           0
; RELOC-NEXT:         Name:            func1
; RELOC-NEXT:       - Index:           1
; RELOC-NEXT:         Name:            func2
; RELOC-NEXT:       - Index:           2
; RELOC-NEXT:         Name:            __cxa_atexit
; RELOC-NEXT:       - Index:           3
; RELOC-NEXT:         Name:            _start
; RELOC-NEXT:       - Index:           4
; RELOC-NEXT:         Name:            .Lcall_dtors
; RELOC-NEXT:       - Index:           5
; RELOC-NEXT:         Name:            .Lregister_call_dtors
; RELOC-NEXT:       - Index:           6
; RELOC-NEXT:         Name:            .Lbitcast
; RELOC-NEXT:       - Index:           7
; RELOC-NEXT:         Name:            myctor
; RELOC-NEXT:       - Index:           8
; RELOC-NEXT:         Name:            mydtor
; RELOC-NEXT:       - Index:           9
; RELOC-NEXT:         Name:            .Lcall_dtors
; RELOC-NEXT:       - Index:           10
; RELOC-NEXT:         Name:            .Lregister_call_dtors
; RELOC-NEXT: ...
OpenPOWER on IntegriCloud