2019-04-23 22:49:38 +08:00
|
|
|
; RUN: llc -relocation-model=pic -filetype=obj %s -o %t.o
|
|
|
|
; RUN: wasm-ld --no-gc-sections --allow-undefined -pie -o %t.wasm %t.o
|
|
|
|
; RUN: obj2yaml %t.wasm | FileCheck %s
|
|
|
|
|
2019-06-06 04:59:20 +08:00
|
|
|
target triple = "wasm32-unknown-emscripten"
|
2019-04-23 22:49:38 +08:00
|
|
|
|
|
|
|
@data = global i32 2, align 4
|
|
|
|
@data_external = external global i32
|
|
|
|
@indirect_func = local_unnamed_addr global i32 ()* @foo, align 4
|
|
|
|
|
|
|
|
@data_addr = local_unnamed_addr global i32* @data, align 4
|
|
|
|
@data_addr_external = local_unnamed_addr global i32* @data_external, align 4
|
|
|
|
|
2019-05-10 09:52:08 +08:00
|
|
|
define hidden i32 @foo() {
|
2019-04-23 22:49:38 +08:00
|
|
|
entry:
|
|
|
|
; To ensure we use __stack_pointer
|
|
|
|
%ptr = alloca i32
|
|
|
|
%0 = load i32, i32* @data, align 4
|
|
|
|
%1 = load i32 ()*, i32 ()** @indirect_func, align 4
|
|
|
|
call i32 %1()
|
|
|
|
ret i32 %0
|
|
|
|
}
|
|
|
|
|
|
|
|
define default i32** @get_data_address() {
|
|
|
|
entry:
|
|
|
|
ret i32** @data_addr_external
|
|
|
|
}
|
|
|
|
|
|
|
|
define void @_start() {
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK: - Type: IMPORT
|
|
|
|
; CHECK-NEXT: Imports:
|
|
|
|
; CHECK-NEXT: - Module: env
|
|
|
|
; CHECK-NEXT: Field: __indirect_function_table
|
|
|
|
; CHECK-NEXT: Kind: TABLE
|
|
|
|
; CHECK-NEXT: Table:
|
|
|
|
; CHECK-NEXT: ElemType: FUNCREF
|
|
|
|
; CHECK-NEXT: Limits:
|
2019-05-10 03:34:32 +08:00
|
|
|
; CHECK-NEXT: Initial: 0x00000001
|
2019-04-23 22:49:38 +08:00
|
|
|
; CHECK-NEXT: - Module: env
|
2019-07-11 21:13:25 +08:00
|
|
|
; CHECK-NEXT: Field: __stack_pointer
|
|
|
|
; CHECK-NEXT: Kind: GLOBAL
|
|
|
|
; CHECK-NEXT: GlobalType: I32
|
|
|
|
; CHECK-NEXT: GlobalMutable: true
|
|
|
|
; CHECK-NEXT: - Module: env
|
2019-04-23 22:49:38 +08:00
|
|
|
; CHECK-NEXT: Field: __memory_base
|
|
|
|
; CHECK-NEXT: Kind: GLOBAL
|
|
|
|
; CHECK-NEXT: GlobalType: I32
|
|
|
|
; CHECK-NEXT: GlobalMutable: false
|
|
|
|
; CHECK-NEXT: - Module: env
|
|
|
|
; CHECK-NEXT: Field: __table_base
|
|
|
|
; CHECK-NEXT: Kind: GLOBAL
|
|
|
|
; CHECK-NEXT: GlobalType: I32
|
|
|
|
; CHECK-NEXT: GlobalMutable: false
|
|
|
|
|
|
|
|
|