|
| 1 | +## Based on lld/test/ELF/shared-lazy.s |
| 2 | + |
| 3 | +# RUN: rm -rf %t && split-file %s %t && cd %t |
| 4 | +# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-emscripten a.s -o a.o |
| 5 | +# RUN: wasm-ld a.o --experimental-pic -shared -o a.so |
| 6 | +# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-emscripten b.s -o b.o |
| 7 | +# RUN: wasm-ld b.o --experimental-pic -shared -o b.so |
| 8 | +# RUN: llvm-ar rc a.a a.o |
| 9 | +# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-emscripten ref.s -o ref.o |
| 10 | +# RUN: wasm-ld a.a b.so ref.o --experimental-pic -shared -o 1.so |
| 11 | +# RUN: obj2yaml 1.so | FileCheck %s |
| 12 | +# RUN: wasm-ld a.so a.a ref.o --experimental-pic -shared -o 1.so |
| 13 | +# RUN: obj2yaml 1.so | FileCheck %s |
| 14 | + |
| 15 | +## The definitions from a.so are used and we don't extract a member from the |
| 16 | +## archive. |
| 17 | + |
| 18 | +# CHECK: - Type: IMPORT |
| 19 | +# CHECK: - Module: GOT.mem |
| 20 | +# CHECK-NEXT: Field: x1 |
| 21 | +# CHECK-NEXT: Kind: GLOBAL |
| 22 | +# CHECK-NEXT: GlobalType: I32 |
| 23 | +# CHECK-NEXT: GlobalMutable: true |
| 24 | +# CHECK-NEXT: - Module: GOT.mem |
| 25 | +# CHECK-NEXT: Field: x2 |
| 26 | +# CHECK-NEXT: Kind: GLOBAL |
| 27 | +# CHECK-NEXT: GlobalType: I32 |
| 28 | +# CHECK-NEXT: GlobalMutable: true |
| 29 | + |
| 30 | +## The extracted x1 is defined as STB_GLOBAL. |
| 31 | +# RUN: wasm-ld ref.o a.a b.so -o 2.so --experimental-pic -shared |
| 32 | +# RUN: obj2yaml 2.so | FileCheck %s --check-prefix=CHECK2 |
| 33 | +# RUN: wasm-ld a.a ref.o b.so -o 2.so --experimental-pic -shared |
| 34 | +# RUN: obj2yaml 2.so | FileCheck %s --check-prefix=CHECK2 |
| 35 | + |
| 36 | +# CHECK2: - Type: EXPORT |
| 37 | +# CHECK2-NEXT: Exports: |
| 38 | +# CHECK2-NEXT: - Name: __wasm_call_ctors |
| 39 | +# CHECK2-NEXT: Kind: FUNCTION |
| 40 | +# CHECK2-NEXT: Index: |
| 41 | +# CHECK2-NEXT: - Name: x1 |
| 42 | +# CHECK2-NEXT: Kind: GLOBAL |
| 43 | +# CHECK2-NEXT: Index: |
| 44 | +# CHECK2-NEXT: - Name: x2 |
| 45 | +# CHECK2-NEXT: Kind: GLOBAL |
| 46 | + |
| 47 | +#--- a.s |
| 48 | +.section .data.x1,"",@ |
| 49 | +.global x1 |
| 50 | +x1: |
| 51 | + .byte 0 |
| 52 | +.size x1, 1 |
| 53 | + |
| 54 | +.section .data.x2,"",@ |
| 55 | +.weak x2 |
| 56 | +x2: |
| 57 | + .byte 0 |
| 58 | +.size x2, 1 |
| 59 | +#--- b.s |
| 60 | +.section .data.x1,"",@ |
| 61 | +.globl x1 |
| 62 | +x1: |
| 63 | + .byte 0 |
| 64 | +.size x1, 1 |
| 65 | + |
| 66 | +.section .data.x2,"",@ |
| 67 | +.globl x2 |
| 68 | +x2: |
| 69 | + .byte 0 |
| 70 | +.size x2, 1 |
| 71 | +#--- ref.s |
| 72 | +.globl x1 |
| 73 | +.globl x2 |
| 74 | +.globl d |
| 75 | +.section .data.d,"",@ |
| 76 | +d: |
| 77 | + .int x1 |
| 78 | + .int x2 |
| 79 | +.size d, 8 |
0 commit comments