llvm-project
62 строки · 1.9 Кб
1# RUN: split-file %s %t
2# RUN: llvm-mc -filetype=obj --triple=wasm32-unknown-unknown -o %t/main.o %t/main.s
3# RUN: llvm-mc -filetype=obj --triple=wasm32-unknown-unknown -o %t/liba_x.o %t/liba_x.s
4# RUN: llvm-mc -filetype=obj --triple=wasm32-unknown-unknown -o %t/liba_y.o %t/liba_y.s
5# RUN: rm -f %t/liba.a
6# RUN: llvm-ar rcs %t/liba.a %t/liba_x.o %t/liba_y.o
7# RUN: wasm-ld %t/main.o %t/liba.a --gc-sections -o %t/main.wasm --print-gc-sections | FileCheck %s --check-prefix=GC
8# RUN: obj2yaml %t/main.wasm | FileCheck %s
9
10# --gc-sections should remove non-retained and unused "weathers" section from live object liba_x.o
11# GC: removing unused section {{.*}}/liba.a(liba_x.o):(weathers)
12# Should not remove retained "greetings" sections from live objects main.o and liba_x.o
13# GC-NOT: removing unused section %t/main.o:(greetings)
14# GC-NOT: removing unused section %t/liba_x.o:(greetings)
15
16# Note: All symbols are private so that they don't join the symbol table.
17
18#--- main.s
19.functype grab_liba () -> ()
20.globl _start
21_start:
22.functype _start () -> ()
23call grab_liba
24end_function
25
26.section greetings,"R",@
27.asciz "hello"
28.section weathers,"R",@
29.asciz "cloudy"
30
31#--- liba_x.s
32.globl grab_liba
33grab_liba:
34.functype grab_liba () -> ()
35end_function
36
37.section greetings,"R",@
38.asciz "world"
39.section weathers,"",@
40.asciz "rainy"
41
42#--- liba_y.s
43.section greetings,"R",@
44.asciz "bye"
45
46
47# "greetings" section
48# CHECK: - Type: DATA
49# CHECK: Segments:
50# CHECK: - SectionOffset: 7
51# CHECK: InitFlags: 0
52# CHECK: Offset:
53# CHECK: Opcode: I32_CONST
54# CHECK: Value: 1024
55# CHECK: Content: 68656C6C6F00776F726C6400
56# "weahters" section.
57# CHECK: - SectionOffset: 25
58# CHECK: InitFlags: 0
59# CHECK: Offset:
60# CHECK: Opcode: I32_CONST
61# CHECK: Value: 1036
62# CHECK: Content: 636C6F75647900
63