File: unresolved-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 (109 lines) | stat: -rw-r--r-- 4,397 bytes parent folder | download | duplicates (5)
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %s -o %t1.o

## Check that %t1.o contains undefined symbol undef_func.
# RUN: not wasm-ld %t1.o -o /dev/null 2>&1 | \
# RUN:   FileCheck -check-prefix=ERRUND %s
# ERRUND: error: {{.*}}1.o: undefined symbol: undef_func

## report-all is the default one. Check that we get the same error
# RUN: not wasm-ld %t1.o -o /dev/null --unresolved-symbols=report-all 2>&1 | \
# RUN:   FileCheck -check-prefix=ERRUND %s

## Error out if unknown option value was set.
# RUN: not wasm-ld %t1.o -o /dev/null --unresolved-symbols=xxx 2>&1 | \
# RUN:   FileCheck -check-prefix=ERR1 %s
# ERR1: unknown --unresolved-symbols value: xxx
## Check alias.
# RUN: not wasm-ld %t1.o -o /dev/null --unresolved-symbols xxx 2>&1 | \
# RUN:   FileCheck -check-prefix=ERR1 %s

## Ignore all should not produce error and should not produce
# any imports.  It should create a stub function in the place of the missing
# function symbol.
# RUN: wasm-ld %t1.o -o %t2.wasm --unresolved-symbols=ignore-all
# RUN: obj2yaml %t2.wasm | FileCheck -check-prefix=IGNORE %s
# IGNORE-NOT: - Type:            IMPORT
# IGNORE-NOT: - Type:            ELEM
#
#      IGNORE:  - Type:            CODE
# IGNORE-NEXT:    Functions:
# IGNORE-NEXT:      - Index:           0
# IGNORE-NEXT:        Locals:          []
# IGNORE-NEXT:        Body:            000B
# IGNORE-NEXT:      - Index:           1
# IGNORE-NEXT:        Locals:          []
# IGNORE-NEXT:        Body:            1080808080001082808080001083808080001A1A0B
# IGNORE-NEXT:      - Index:           2
# IGNORE-NEXT:        Locals:          []
# IGNORE-NEXT:        Body:            4180808080000F0B
# IGNORE-NEXT:      - Index:           3
# IGNORE-NEXT:        Locals:          []
# IGNORE-NEXT:        Body:            4180808080000F0B
#
#      IGNORE:  - Type:            CUSTOM
# IGNORE-NEXT:    Name:            name
# IGNORE-NEXT:    FunctionNames:
# IGNORE-NEXT:      - Index:           0
# IGNORE-NEXT:        Name:            undefined
# IGNORE-NEXT:      - Index:           1
# IGNORE-NEXT:        Name:            _start
# IGNORE-NEXT:      - Index:           2
# IGNORE-NEXT:        Name:            get_data_addr
# IGNORE-NEXT:      - Index:           3
# IGNORE-NEXT:        Name:            get_func_addr

## --import-undefined should handle unresolved funtions symbols
# by importing them but still report errors/warning for missing data symbols.
# `--allow-undefined` should behave like `--import-undefined` +
# `--unresolve-symbols=ignore`
# RUN: wasm-ld %t1.o -o %t3.wasm --import-undefined --unresolved-symbols=ignore-all
# RUN: obj2yaml %t3.wasm | FileCheck -check-prefix=IMPORT %s
#      IMPORT:  - Type:            IMPORT
# IMPORT-NEXT:    Imports:
# IMPORT-NEXT:      - Module:          env
# IMPORT-NEXT:        Field:           undef_func
# IMPORT-NEXT:        Kind:            FUNCTION
# IMPORT-NEXT:        SigIndex:        0
# IMPORT-NEXT:  - Type:            FUNCTION

## Check that --import-undefined reports unresolved data symbols.
# RUN: not wasm-ld %t1.o -o %t3.wasm --import-undefined --unresolved-symbols=report-all 2>&1 | FileCheck -check-prefix=IMPORTUNDEFINED %s
# IMPORTUNDEFINED-NOT: error: {{.*}}1.o: undefined symbol: undef_func
# IMPORTUNDEFINED: error: {{.*}}1.o: undefined symbol: undef_data

## Do not report undefines if linking relocatable.
# RUN: wasm-ld -r %t1.o -o %t4.wasm --unresolved-symbols=report-all
# RUN: llvm-readobj %t4.wasm > /dev/null 2>&1

.functype undef_func () -> ()
.functype get_data_addr () -> (i32)
.functype get_func_addr () -> (i32)

## import-dynamic should fail due to incompatible relocations.
# RUN: not wasm-ld %t1.o -o %t5.wasm --unresolved-symbols=import-dynamic 2>&1 | FileCheck -check-prefix=ERRNOPIC %s
# ERRNOPIC: relocation R_WASM_MEMORY_ADDR_SLEB cannot be used against symbol `undef_data`; recompile with -fPIC
# ERRNOPIC: relocation R_WASM_TABLE_INDEX_SLEB cannot be used against symbol `undef_func`; recompile with -fPIC

.globl _start
_start:
    .functype _start () -> ()
    call undef_func
    call get_data_addr
    call get_func_addr
    drop
    drop
    end_function

.globl get_data_addr
get_data_addr:
    .functype get_data_addr () -> (i32)
    i32.const undef_data
    return
    end_function

.globl get_func_addr
get_func_addr:
    .functype get_func_addr () -> (i32)
    i32.const undef_func
    return
    end_function