llvm-project
61 строка · 2.3 Кб
1# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -o %t.o %s
2# RUN: wasm-ld --experimental-pic -shared -o %t.wasm %t.o
3# RUN: obj2yaml %t.wasm | FileCheck %s
4# RUN: llvm-objdump -d %t.wasm | FileCheck %s -check-prefix=ASM
5
6# Run the same test but include a definition of ret32 in a library file.
7# This verifies that LazySymbols (those found in library archives) are correctly
8# demoted to undefined symbols in the final link when they are only weakly
9# referenced.
10# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -o %t.ret32.o %p/Inputs/ret32.s
11# RUN: rm -f %T/libret32.a
12# RUN: llvm-ar cru %T/libret32.a %t.ret32.o
13# RUN: wasm-ld --experimental-pic -shared -o %t.ret32.wasm %t.o %T/libret32.a
14# RUN: obj2yaml %t.wasm | FileCheck %s
15# RUN: llvm-objdump -d %t.wasm | FileCheck %s -check-prefix=ASM
16
17# Verify the weak undefined symbols are marked as such in the
18# dylink section.
19
20.weak weak_func
21.functype weak_func () -> (i32)
22.weak ret32
23.functype ret32 (f32) -> (i32)
24
25.globl call_weak
26call_weak:
27# ASM: <call_weak>:
28.functype call_weak () -> (i32)
29call weak_func
30# ASM: 10 80 80 80 80 00 call 0
31end_function
32# ASM-NEXT: 0b end
33
34# This function is defined in library archive, but since our reference to it
35# is weak we don't expect this definition to be used. Instead we expect it to
36# act like an undefined reference and result in an imported function.
37.globl call_weak_libfunc
38call_weak_libfunc:
39# ASM: <call_weak_libfunc>:
40.functype call_weak_libfunc () -> (i32)
41f32.const 1.0
42call ret32
43# ASM: 10 81 80 80 80 00 call 1
44end_function
45# ASM-NEXT: 0b end
46
47# CHECK: Sections:
48# CHECK-NEXT: - Type: CUSTOM
49# CHECK-NEXT: Name: dylink.0
50# CHECK-NEXT: MemorySize: 0
51# CHECK-NEXT: MemoryAlignment: 0
52# CHECK-NEXT: TableSize: 0
53# CHECK-NEXT: TableAlignment: 0
54# CHECK-NEXT: Needed: []
55# CHECK-NEXT: ImportInfo:
56# CHECK-NEXT: - Module: env
57# CHECK-NEXT: Field: weak_func
58# CHECK-NEXT: Flags: [ BINDING_WEAK, UNDEFINED ]
59# CHECK-NEXT: - Module: env
60# CHECK-NEXT: Field: ret32
61# CHECK-NEXT: Flags: [ BINDING_WEAK, UNDEFINED ]
62