1// RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %s -o %t.o
2// RUN: wasm-ld --no-entry -Bsymbolic %t.o -o %t2.so 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:            - Module:          GOT.func
13// NOOPTION-NEXT:         Field:           foo
14// NOOPTION-NEXT:         Kind:            GLOBAL
15// NOOPTION-NEXT:         GlobalType:      I32
16// NOOPTION-NEXT:         GlobalMutable:   true
17// NOOPTION-NEXT:       - Module:          GOT.mem
18// NOOPTION-NEXT:         Field:           bar
19// NOOPTION-NEXT:         Kind:            GLOBAL
20// NOOPTION-NEXT:         GlobalType:      I32
21// NOOPTION-NEXT:         GlobalMutable:   true
22
23//      NOOPTION:  - Type:            GLOBAL
24// NOOPTION-NEXT:    Globals:
25// NOOPTION-NEXT:      - Index:           4
26// NOOPTION-NEXT:        Type:            I32
27// NOOPTION-NEXT:        Mutable:         false
28// NOOPTION-NEXT:        InitExpr:
29// NOOPTION-NEXT:          Opcode:          I32_CONST
30// NOOPTION-NEXT:          Value:           0
31// NOOPTION-NEXT:  - Type:            EXPORT
32
33// SYMBOLIC-NOT:   - Module:          GOT.mem
34// SYMBOLIC-NOT:   - Module:          GOT.func
35
36// SYMBOLIC:       - Type:            GLOBAL
37// SYMBOLIC-NEXT:    Globals:
38// SYMBOLIC-NEXT:      - Index:           2
39// SYMBOLIC-NEXT:        Type:            I32
40// SYMBOLIC-NEXT:        Mutable:         true
41// SYMBOLIC-NEXT:        InitExpr:
42// SYMBOLIC-NEXT:          Opcode:          I32_CONST
43// SYMBOLIC-NEXT:          Value:           0
44// SYMBOLIC-NEXT:      - Index:           3
45// SYMBOLIC-NEXT:        Type:            I32
46// SYMBOLIC-NEXT:        Mutable:         true
47// SYMBOLIC-NEXT:        InitExpr:
48// SYMBOLIC-NEXT:          Opcode:          I32_CONST
49// SYMBOLIC-NEXT:          Value:           0
50// SYMBOLIC-NEXT:      - Index:           4
51// SYMBOLIC-NEXT:        Type:            I32
52// SYMBOLIC-NEXT:        Mutable:         false
53// SYMBOLIC-NEXT:        InitExpr:
54// SYMBOLIC-NEXT:          Opcode:          I32_CONST
55// SYMBOLIC-NEXT:          Value:           0
56// SYMBOLIC-NEXT:  - Type:            EXPORT
57
58.globl foo
59foo:
60  .functype foo () -> ()
61  end_function
62
63.globl get_foo_address
64get_foo_address:
65  .functype get_foo_address () -> (i32)
66  global.get foo@GOT
67  end_function
68
69.globl get_bar_address
70get_bar_address:
71  .functype get_bar_address () -> (i32)
72  global.get bar@GOT
73  end_function
74
75.globl bar
76.section  .data.bar,"",@
77bar:
78  .int 42
79.size bar, 4
80