xref: /llvm-project/lld/test/wasm/bsymbolic.s (revision 9647a6f719ee4b1c23eea7aef368c1dcd5317949)
1// RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %s -o %t.o
2// RUN: wasm-ld --no-entry -Bsymbolic %t.o -o %t.wasm 2>&1 | FileCheck -check-prefix=WARNING %s
3// WARNING: warning: -Bsymbolic is only meaningful when combined with -shared
4
5// RUN: wasm-ld --experimental-pic -shared %t.o -o %t0.so
6// RUN: obj2yaml %t0.so | FileCheck -check-prefix=NOOPTION %s
7
8// RUN: wasm-ld --experimental-pic -shared -Bsymbolic %t.o -o %t1.so
9// RUN: obj2yaml %t1.so | FileCheck -check-prefix=SYMBOLIC %s
10
11// NOOPTION:       - Type:            IMPORT
12// NOOPTION-NEXT:    Imports:
13// NOOPTION-NEXT:      - Module:          env
14// NOOPTION-NEXT:        Field:           memory
15// NOOPTION-NEXT:        Kind:            MEMORY
16// NOOPTION-NEXT:        Memory:
17// NOOPTION-NEXT:          Minimum:         0x1
18// NOOPTION-NEXT:      - Module:          env
19// NOOPTION-NEXT:        Field:           __memory_base
20// NOOPTION-NEXT:        Kind:            GLOBAL
21// NOOPTION-NEXT:        GlobalType:      I32
22// NOOPTION-NEXT:        GlobalMutable:   false
23// NOOPTION-NEXT:      - Module:          env
24// NOOPTION-NEXT:        Field:           __table_base
25// NOOPTION-NEXT:        Kind:            GLOBAL
26// NOOPTION-NEXT:        GlobalType:      I32
27// NOOPTION-NEXT:        GlobalMutable:   false
28// NOOPTION-NEXT:      - Module:          GOT.func
29// NOOPTION-NEXT:        Field:           foo
30// NOOPTION-NEXT:        Kind:            GLOBAL
31// NOOPTION-NEXT:        GlobalType:      I32
32// NOOPTION-NEXT:        GlobalMutable:   true
33// NOOPTION-NEXT:      - Module:          GOT.mem
34// NOOPTION-NEXT:        Field:           bar
35// NOOPTION-NEXT:        Kind:            GLOBAL
36// NOOPTION-NEXT:        GlobalType:      I32
37// NOOPTION-NEXT:        GlobalMutable:   true
38// NOOPTION-NEXT:  - Type:            FUNCTION
39
40//      NOOPTION:  - Type:            GLOBAL
41// NOOPTION-NEXT:    Globals:
42// NOOPTION-NEXT:      - Index:           4
43// NOOPTION-NEXT:        Type:            I32
44// NOOPTION-NEXT:        Mutable:         false
45// NOOPTION-NEXT:        InitExpr:
46// NOOPTION-NEXT:          Opcode:          I32_CONST
47// NOOPTION-NEXT:          Value:           0
48// NOOPTION-NEXT:  - Type:            EXPORT
49
50// SYMBOLIC-NOT:   - Module:          GOT.mem
51// SYMBOLIC-NOT:   - Module:          GOT.func
52
53// SYMBOLIC:       - Type:            IMPORT
54// SYMBOLIC-NEXT:    Imports:
55// SYMBOLIC-NEXT:      - Module:          env
56// SYMBOLIC-NEXT:        Field:           memory
57// SYMBOLIC-NEXT:        Kind:            MEMORY
58// SYMBOLIC-NEXT:        Memory:
59// SYMBOLIC-NEXT:          Minimum:         0x1
60// SYMBOLIC-NEXT:      - Module:          env
61// SYMBOLIC-NEXT:        Field:           __memory_base
62// SYMBOLIC-NEXT:        Kind:            GLOBAL
63// SYMBOLIC-NEXT:        GlobalType:      I32
64// SYMBOLIC-NEXT:        GlobalMutable:   false
65// SYMBOLIC-NEXT:      - Module:          env
66// SYMBOLIC-NEXT:        Field:           __table_base
67// SYMBOLIC-NEXT:        Kind:            GLOBAL
68// SYMBOLIC-NEXT:        GlobalType:      I32
69// SYMBOLIC-NEXT:        GlobalMutable:   false
70// SYMBOLIC-NEXT:      - Module:          env
71// SYMBOLIC-NEXT:        Field:           __indirect_function_table
72// SYMBOLIC-NEXT:        Kind:            TABLE
73// SYMBOLIC-NEXT:        Table:
74// SYMBOLIC-NEXT:          Index:           0
75// SYMBOLIC-NEXT:          ElemType:        FUNCREF
76// SYMBOLIC-NEXT:          Limits:
77// SYMBOLIC-NEXT:            Minimum:         0x1
78// SYMBOLIC-NEXT:  - Type:            FUNCTION
79
80// SYMBOLIC:       - Type:            GLOBAL
81// SYMBOLIC-NEXT:    Globals:
82// SYMBOLIC-NEXT:      - Index:           2
83// SYMBOLIC-NEXT:        Type:            I32
84// SYMBOLIC-NEXT:        Mutable:         true
85// SYMBOLIC-NEXT:        InitExpr:
86// SYMBOLIC-NEXT:          Opcode:          I32_CONST
87// SYMBOLIC-NEXT:          Value:           0
88// SYMBOLIC-NEXT:      - Index:           3
89// SYMBOLIC-NEXT:        Type:            I32
90// SYMBOLIC-NEXT:        Mutable:         true
91// SYMBOLIC-NEXT:        InitExpr:
92// SYMBOLIC-NEXT:          Opcode:          I32_CONST
93// SYMBOLIC-NEXT:          Value:           0
94// SYMBOLIC-NEXT:      - Index:           4
95// SYMBOLIC-NEXT:        Type:            I32
96// SYMBOLIC-NEXT:        Mutable:         false
97// SYMBOLIC-NEXT:        InitExpr:
98// SYMBOLIC-NEXT:          Opcode:          I32_CONST
99// SYMBOLIC-NEXT:          Value:           0
100// SYMBOLIC-NEXT:  - Type:            EXPORT
101
102.globl foo
103
104foo:
105  .functype foo () -> ()
106  end_function
107
108.globl get_foo_address
109get_foo_address:
110  .functype get_foo_address () -> (i32)
111  global.get foo@GOT
112  end_function
113
114.globl get_bar_address
115get_bar_address:
116  .functype get_bar_address () -> (i32)
117  global.get bar@GOT
118  end_function
119
120.globl bar
121.section  .data.bar,"",@
122bar:
123  .int 42
124.size bar, 4
125