xref: /llvm-project/lld/test/wasm/tls-align.s (revision 504cb2730c25baa1e9e2adf4769b4c9427144292)
1# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -o %t.o %s
2
3.globaltype __tls_base, i32
4.globaltype __tls_align, i32, immutable
5
6.globl tls1_addr
7tls1_addr:
8  .functype tls1_addr () -> (i32)
9  global.get __tls_base
10  i32.const tls1
11  i32.add
12  end_function
13
14.globl tls2_addr
15tls2_addr:
16  .functype tls2_addr () -> (i32)
17  global.get __tls_base
18  i32.const tls2
19  i32.add
20  end_function
21
22.globl tls_align
23tls_align:
24  .functype tls_align () -> (i32)
25  global.get __tls_align
26  end_function
27
28.section  .bss.no_tls,"",@
29.globl  no_tls
30.p2align  2
31no_tls:
32  .int32  0
33  .size no_tls, 4
34
35.section  .tdata.tls1,"",@
36.globl  tls1
37.p2align  2
38tls1:
39  .int32  1
40  .size tls1, 4
41
42.section  .tdata.tls2,"",@
43.globl  tls2
44.p2align  4
45tls2:
46  .int32  1
47  .size tls2, 4
48
49.section  .custom_section.target_features,"",@
50  .int8 2
51  .int8 43
52  .int8 7
53  .ascii  "atomics"
54  .int8 43
55  .int8 11
56  .ascii  "bulk-memory"
57
58# RUN: wasm-ld -no-gc-sections --shared-memory --max-memory=131072 --no-entry -o %t.wasm %t.o
59# RUN: obj2yaml %t.wasm | FileCheck %s
60
61# CHECK:      - Type:            GLOBAL
62# CHECK-NEXT:   Globals:
63# CHECK-NEXT:     - Index:           0
64# CHECK-NEXT:       Type:            I32
65# CHECK-NEXT:       Mutable:         true
66# CHECK-NEXT:       InitExpr:
67# CHECK-NEXT:         Opcode:          I32_CONST
68# CHECK-NEXT:         Value:           66592
69
70# __tls_base
71# CHECK-NEXT:     - Index:           1
72# CHECK-NEXT:       Type:            I32
73# CHECK-NEXT:       Mutable:         true
74# CHECK-NEXT:       InitExpr:
75# CHECK-NEXT:         Opcode:          I32_CONST
76# CHECK-NEXT:         Value:           0
77
78# __tls_size
79# CHECK-NEXT:     - Index:           2
80# CHECK-NEXT:       Type:            I32
81# CHECK-NEXT:       Mutable:         false
82# CHECK-NEXT:       InitExpr:
83# CHECK-NEXT:         Opcode:          I32_CONST
84# CHECK-NEXT:         Value:           20
85
86# __tls_align
87# CHECK-NEXT:     - Index:           3
88# CHECK-NEXT:       Type:            I32
89# CHECK-NEXT:       Mutable:         false
90# CHECK-NEXT:       InitExpr:
91# CHECK-NEXT:         Opcode:          I32_CONST
92# CHECK-NEXT:         Value:           16
93