xref: /llvm-project/lld/test/wasm/stub-library-archive.s (revision afb3f7e0b723a88ffbd950736ac2396630154dd9)
1# RUN: split-file %s %t
2# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -o %t.o %t/main.s
3# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -o %t/foodeps.o %t/foodeps.s
4# RUN: rm -f %t/libfoodeps.a
5# RUN: llvm-ar rcs %t/libfoodeps.a %t/foodeps.o
6# RUN: wasm-ld %t.o %p/Inputs/libstub.so %t/libfoodeps.a -o %t.wasm
7# RUN: obj2yaml %t.wasm | FileCheck %s
8
9#--- main.s
10
11# The function foo is defined in libstub.so but depends on foodep1 and foodep2
12
13# foodep1 and foodep2 a defined libfoodeps.a(foodeps.o) but this function
14# depeds on baz which is also defined in libstub.so.
15
16.functype foo () -> ()
17.import_name foo, foo_import
18
19.globl _start
20_start:
21    .functype _start () -> ()
22    call foo
23    end_function
24
25.globl bazdep
26bazdep:
27    .functype bazdep () -> ()
28    end_function
29
30#--- foodeps.s
31
32.functype baz () -> ()
33
34.globl foodep1
35foodep1:
36  .functype foodep1 () -> ()
37  call baz
38  end_function
39
40.globl foodep2
41foodep2:
42  .functype foodep2 () -> ()
43  end_function
44
45# CHECK:       - Type:            EXPORT
46# CHECK-NEXT:    Exports:
47# CHECK-NEXT:      - Name:            memory
48# CHECK-NEXT:        Kind:            MEMORY
49# CHECK-NEXT:        Index:           0
50# CHECK-NEXT:      - Name:            _start
51# CHECK-NEXT:        Kind:            FUNCTION
52# CHECK-NEXT:        Index:           2
53# CHECK-NEXT:      - Name:            bazdep
54# CHECK-NEXT:        Kind:            FUNCTION
55# CHECK-NEXT:        Index:           3
56# CHECK-NEXT:      - Name:            foodep1
57# CHECK-NEXT:        Kind:            FUNCTION
58# CHECK-NEXT:        Index:           4
59# CHECK-NEXT:      - Name:            foodep2
60# CHECK-NEXT:        Kind:            FUNCTION
61# CHECK-NEXT:        Index:           5
62