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@TLSREL 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@TLSREL 19 i32.add 20 end_function 21 22.globl tls3_addr 23tls3_addr: 24 .functype tls3_addr () -> (i32) 25 global.get __tls_base 26 i32.const tls3 27 i32.add 28 end_function 29 30.globl tls_align 31tls_align: 32 .functype tls_align () -> (i32) 33 global.get __tls_align 34 end_function 35 36.section .bss.no_tls,"",@ 37.globl no_tls 38.p2align 2 39no_tls: 40 .int32 0 41 .size no_tls, 4 42 43.section .tdata.tls1,"",@ 44.globl tls1 45.p2align 2 46tls1: 47 .int32 1 48 .size tls1, 4 49 50.section .tdata.tls2,"",@ 51.globl tls2 52.p2align 2 53tls2: 54 .int32 1 55 .size tls2, 4 56 57.section .tbss.tls3,"",@ 58.globl tls3 59.p2align 2 60tls3: 61 .int32 0 62 .size tls3, 4 63 64.section .custom_section.target_features,"",@ 65 .int8 2 66 .int8 43 67 .int8 7 68 .ascii "atomics" 69 .int8 43 70 .int8 11 71 .ascii "bulk-memory" 72 73# RUN: wasm-ld -no-gc-sections --shared-memory --max-memory=131072 --no-entry -o %t.wasm %t.o 74# RUN: obj2yaml %t.wasm | FileCheck %s 75 76# RUN: wasm-ld -no-gc-sections --shared-memory --max-memory=131072 --no-merge-data-segments --no-entry -o %t.wasm %t.o 77# RUN: obj2yaml %t.wasm | FileCheck %s 78 79# CHECK: - Type: GLOBAL 80# CHECK-NEXT: Globals: 81# CHECK-NEXT: - Index: 0 82# CHECK-NEXT: Type: I32 83# CHECK-NEXT: Mutable: true 84# CHECK-NEXT: InitExpr: 85# CHECK-NEXT: Opcode: I32_CONST 86# CHECK-NEXT: Value: 66592 87 88# __tls_base 89# CHECK-NEXT: - Index: 1 90# CHECK-NEXT: Type: I32 91# CHECK-NEXT: Mutable: true 92# CHECK-NEXT: InitExpr: 93# CHECK-NEXT: Opcode: I32_CONST 94# CHECK-NEXT: Value: 0 95 96# __tls_size 97# CHECK-NEXT: - Index: 2 98# CHECK-NEXT: Type: I32 99# CHECK-NEXT: Mutable: false 100# CHECK-NEXT: InitExpr: 101# CHECK-NEXT: Opcode: I32_CONST 102# CHECK-NEXT: Value: 12 103 104# __tls_align 105# CHECK-NEXT: - Index: 3 106# CHECK-NEXT: Type: I32 107# CHECK-NEXT: Mutable: false 108# CHECK-NEXT: InitExpr: 109# CHECK-NEXT: Opcode: I32_CONST 110# CHECK-NEXT: Value: 4 111 112 113# CHECK: - Type: CODE 114# CHECK-NEXT: Functions: 115# Skip __wasm_call_ctors and __wasm_init_memory 116# CHECK: - Index: 2 117# CHECK-NEXT: Locals: [] 118# CHECK-NEXT: Body: 2000240120004100410CFC0800000B 119 120# Expected body of __wasm_init_tls: 121# local.get 0 122# global.set 1 123# local.get 0 124# i32.const 0 125# i32.const 12 126# memory.init 1, 0 127# end 128 129# CHECK-NEXT: - Index: 3 130# CHECK-NEXT: Locals: [] 131# CHECK-NEXT: Body: 2381808080004180808080006A0B 132 133# Expected body of tls1_addr: 134# global.get 1 135# i32.const 0 136# i32.add 137# end 138 139# CHECK-NEXT: - Index: 4 140# CHECK-NEXT: Locals: [] 141# CHECK-NEXT: Body: 2381808080004184808080006A0B 142 143# Expected body of tls2_addr: 144# global.get 1 145# i32.const 4 146# i32.add 147# end 148 149# CHECK-NEXT: - Index: 5 150# CHECK-NEXT: Locals: [] 151# CHECK-NEXT: Body: 2381808080004188808080006A0B 152 153# Expected body of tls3_addr: 154# global.get 1 155# i32.const 4 156# i32.add 157# end 158 159# CHECK-NEXT: - Index: 6 160# CHECK-NEXT: Locals: [] 161# CHECK-NEXT: Body: 2383808080000B 162 163# Expected body of tls_align: 164# global.get 3 165# end 166