1659a0839SSam Clegg# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -o %t.o %s 2659a0839SSam Clegg# RUN: wasm-ld --experimental-pic -shared -o %t.wasm %t.o 3659a0839SSam Clegg# RUN: obj2yaml %t.wasm | FileCheck %s 4659a0839SSam Clegg# RUN: llvm-objdump -d %t.wasm | FileCheck %s -check-prefix=ASM 5659a0839SSam Clegg 6*b0f18af3SSam Clegg# Run the same test but include a definition of ret32 in a library file. 7*b0f18af3SSam Clegg# This verifies that LazySymbols (those found in library archives) are correctly 8*b0f18af3SSam Clegg# demoted to undefined symbols in the final link when they are only weakly 9*b0f18af3SSam Clegg# referenced. 10*b0f18af3SSam Clegg# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -o %t.ret32.o %p/Inputs/ret32.s 11*b0f18af3SSam Clegg# RUN: rm -f %T/libret32.a 12*b0f18af3SSam Clegg# RUN: llvm-ar cru %T/libret32.a %t.ret32.o 13*b0f18af3SSam Clegg# RUN: wasm-ld --experimental-pic -shared -o %t.ret32.wasm %t.o %T/libret32.a 14*b0f18af3SSam Clegg# RUN: obj2yaml %t.wasm | FileCheck %s 15*b0f18af3SSam Clegg# RUN: llvm-objdump -d %t.wasm | FileCheck %s -check-prefix=ASM 16*b0f18af3SSam Clegg 17659a0839SSam Clegg# Verify the weak undefined symbols are marked as such in the 18659a0839SSam Clegg# dylink section. 19659a0839SSam Clegg 20659a0839SSam Clegg.weak weak_func 21659a0839SSam Clegg.functype weak_func () -> (i32) 22*b0f18af3SSam Clegg.weak ret32 23*b0f18af3SSam Clegg.functype ret32 (f32) -> (i32) 24659a0839SSam Clegg 25659a0839SSam Clegg.globl call_weak 26659a0839SSam Cleggcall_weak: 27659a0839SSam Clegg# ASM: <call_weak>: 28659a0839SSam Clegg .functype call_weak () -> (i32) 29659a0839SSam Clegg call weak_func 30659a0839SSam Clegg# ASM: 10 80 80 80 80 00 call 0 31659a0839SSam Clegg end_function 32659a0839SSam Clegg# ASM-NEXT: 0b end 33659a0839SSam Clegg 34*b0f18af3SSam Clegg# This function is defined in library archive, but since our reference to it 35*b0f18af3SSam Clegg# is weak we don't expect this definition to be used. Instead we expect it to 36*b0f18af3SSam Clegg# act like an undefined reference and result in an imported function. 37*b0f18af3SSam Clegg.globl call_weak_libfunc 38*b0f18af3SSam Cleggcall_weak_libfunc: 39*b0f18af3SSam Clegg# ASM: <call_weak_libfunc>: 40*b0f18af3SSam Clegg .functype call_weak_libfunc () -> (i32) 41*b0f18af3SSam Clegg f32.const 1.0 42*b0f18af3SSam Clegg call ret32 43*b0f18af3SSam Clegg# ASM: 10 81 80 80 80 00 call 1 44*b0f18af3SSam Clegg end_function 45*b0f18af3SSam Clegg# ASM-NEXT: 0b end 46*b0f18af3SSam Clegg 47659a0839SSam Clegg# CHECK: Sections: 48659a0839SSam Clegg# CHECK-NEXT: - Type: CUSTOM 49659a0839SSam Clegg# CHECK-NEXT: Name: dylink.0 50659a0839SSam Clegg# CHECK-NEXT: MemorySize: 0 51659a0839SSam Clegg# CHECK-NEXT: MemoryAlignment: 0 52659a0839SSam Clegg# CHECK-NEXT: TableSize: 0 53659a0839SSam Clegg# CHECK-NEXT: TableAlignment: 0 54659a0839SSam Clegg# CHECK-NEXT: Needed: [] 55659a0839SSam Clegg# CHECK-NEXT: ImportInfo: 56659a0839SSam Clegg# CHECK-NEXT: - Module: env 57659a0839SSam Clegg# CHECK-NEXT: Field: weak_func 58659a0839SSam Clegg# CHECK-NEXT: Flags: [ BINDING_WEAK, UNDEFINED ] 59*b0f18af3SSam Clegg# CHECK-NEXT: - Module: env 60*b0f18af3SSam Clegg# CHECK-NEXT: Field: ret32 61*b0f18af3SSam Clegg# CHECK-NEXT: Flags: [ BINDING_WEAK, UNDEFINED ] 62