2019-10-17 11:21:02 +08:00
|
|
|
; Test that weak undefined symbols do not fetch members from archive files.
|
2019-01-30 06:26:31 +08:00
|
|
|
; RUN: llc -filetype=obj %s -o %t.o
|
2020-05-21 12:35:18 +08:00
|
|
|
; RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/ret32.s -o %t.ret32.o
|
|
|
|
; RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/hello.s -o %t.hello.o
|
2019-01-30 06:26:31 +08:00
|
|
|
; RUN: rm -f %t.a
|
2019-10-17 11:21:02 +08:00
|
|
|
; RUN: llvm-ar rcs %t.a %t.ret32.o %t.hello.o
|
|
|
|
|
2019-01-30 06:26:31 +08:00
|
|
|
; RUN: wasm-ld %t.o %t.a -o %t.wasm
|
|
|
|
; RUN: obj2yaml %t.wasm | FileCheck %s
|
|
|
|
|
2019-10-17 11:21:02 +08:00
|
|
|
; RUN: wasm-ld -u hello_str %t.o %t.a -o %t2.wasm
|
|
|
|
; RUN: obj2yaml %t2.wasm | FileCheck %s -check-prefix=CHECK-DATA
|
|
|
|
|
2019-01-30 06:26:31 +08:00
|
|
|
target triple = "wasm32-unknown-unknown"
|
|
|
|
|
2019-10-17 11:21:02 +08:00
|
|
|
; Weak external function symbol
|
2019-01-30 06:26:31 +08:00
|
|
|
declare extern_weak i32 @ret32()
|
|
|
|
|
2019-10-17 11:21:02 +08:00
|
|
|
; Weak external data symbol
|
|
|
|
@hello_str = extern_weak global i8*, align 4
|
|
|
|
|
2019-01-30 06:26:31 +08:00
|
|
|
define void @_start() {
|
2019-10-17 11:21:02 +08:00
|
|
|
br i1 icmp ne (i8** @hello_str, i8** null), label %if.then, label %if.end
|
|
|
|
|
|
|
|
if.then:
|
2019-01-30 06:26:31 +08:00
|
|
|
%call1 = call i32 @ret32()
|
2019-10-17 11:21:02 +08:00
|
|
|
br label %if.end
|
|
|
|
|
|
|
|
if.end:
|
2019-01-30 06:26:31 +08:00
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2019-10-17 11:21:02 +08:00
|
|
|
; Ensure we have no data section. If we do, would mean that hello_str was
|
|
|
|
; pulled out of the library.
|
|
|
|
; CHECK-NOT: Type: DATA
|
|
|
|
; CHECK-DATA: Type: DATA
|
|
|
|
|
2019-02-08 06:42:16 +08:00
|
|
|
; CHECK: Name: 'undefined:ret32'
|
2019-01-30 06:26:31 +08:00
|
|
|
; CHECK-NOT: Name: ret32
|