File: tls-init-symbols.s

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (71 lines) | stat: -rw-r--r-- 2,166 bytes parent folder | download | duplicates (15)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# Regression test based on https://github.com/llvm/llvm-project/issues/54386
# Test that that linker synthetic functions such as __wasm_tls_init and
# __wasm_apply_global_tls_relocs can be created successfully in programs
# that don't reference __tls_base or __wasm_tls_init.  These function both
# reference __tls_base which need to be marks as alive if they are generated.

# This is very basic TLS-using program that doesn't reference any of the
# linker-generated symbols.

# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -o %t.o %s
# RUN: wasm-ld -no-gc-sections --shared-memory -o %t.wasm %t.o
# RUN: obj2yaml %t.wasm | FileCheck %s
# RUN: llvm-objdump -d --no-show-raw-insn --no-leading-addr %t.wasm | FileCheck %s --check-prefixes DIS

.globl _start
_start:
  .functype _start () -> (i32)
  global.get tls_sym@GOT@TLS
  end_function

.section  .tdata.tls_sym,"",@
.globl  tls_sym
.p2align  2
tls_sym:
  .int32  1
  .size tls_sym, 4

.section  .custom_section.target_features,"",@
  .int8 2
  .int8 43
  .int8 7
  .ascii  "atomics"
  .int8 43
  .int8 11
  .ascii  "bulk-memory"

# CHECK:       - Type:            CUSTOM
# CHECK-NEXT:    Name:            name
# CHECK-NEXT:    FunctionNames:
# CHECK-NEXT:      - Index:           0
# CHECK-NEXT:        Name:            __wasm_call_ctors
# CHECK-NEXT:      - Index:           1
# CHECK-NEXT:        Name:            __wasm_init_tls
# CHECK-NEXT:      - Index:           2
# CHECK-NEXT:        Name:            __wasm_init_memory
# CHECK-NEXT:      - Index:           3
# CHECK-NEXT:        Name:            __wasm_apply_global_tls_relocs
# CHECK-NEXT:      - Index:           4
# CHECK-NEXT:        Name:            _start

# DIS:       <__wasm_init_tls>:
# DIS:        local.get 0
# DIS-NEXT:   global.set  1
# DIS-NEXT:   local.get 0
# DIS-NEXT:   i32.const 0
# DIS-NEXT:   i32.const 4
# DIS-NEXT:   memory.init 0, 0
# DIS-NEXT:   call  3
# DIS-NEXT:   end

# DIS:      <__wasm_apply_global_tls_relocs>:
# DIS:        global.get  1
# DIS-NEXT:   i32.const 0
# DIS-NEXT:   i32.add
# DIS-NEXT:   global.set  4
# DIS-NEXT:   end

# DIS:      <_start>:
# DIS:        global.get  4
# DIS-NEXT:   end