1 # Regression test based on https://github.com/llvm/llvm-project/issues/54386
2 # Test that that linker synthetic functions such as __wasm_tls_init and
3 # __wasm_apply_global_tls_relocs can be created successfully in programs
4 # that don't reference __tls_base or __wasm_tls_init. These function both
5 # reference __tls_base which need to be marks as alive if they are generated.
7 # This is very basic TLS-using program that doesn't reference any of the
8 # linker-generated symbols.
10 # RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -o %t.o %s
11 # RUN: wasm-ld -no-gc-sections --shared-memory -o %t.wasm %t.o
12 # RUN: obj2yaml %t.wasm | FileCheck %s
13 # RUN: llvm-objdump -d --no-show-raw-insn --no-leading-addr %t.wasm | FileCheck %s --check-prefixes DIS
17 .functype _start () -> (i32)
18 global.get tls_sym@GOT@TLS
21 .section .tdata.tls_sym,"",@
28 .section .custom_section.target_features,"",@
37 # CHECK: - Type: CUSTOM
38 # CHECK-NEXT: Name: name
39 # CHECK-NEXT: FunctionNames:
40 # CHECK-NEXT: - Index: 0
41 # CHECK-NEXT: Name: __wasm_call_ctors
42 # CHECK-NEXT: - Index: 1
43 # CHECK-NEXT: Name: __wasm_init_tls
44 # CHECK-NEXT: - Index: 2
45 # CHECK-NEXT: Name: __wasm_init_memory
46 # CHECK-NEXT: - Index: 3
47 # CHECK-NEXT: Name: __wasm_apply_global_tls_relocs
48 # CHECK-NEXT: - Index: 4
49 # CHECK-NEXT: Name: _start
51 # DIS: <__wasm_init_tls>:
53 # DIS-NEXT: global.set 1
54 # DIS-NEXT: local.get 0
55 # DIS-NEXT: i32.const 0
56 # DIS-NEXT: i32.const 4
57 # DIS-NEXT: memory.init 0, 0
61 # DIS: <__wasm_apply_global_tls_relocs>:
63 # DIS-NEXT: i32.const 0
65 # DIS-NEXT: global.set 4