2018-11-15 08:37:21 +08:00
|
|
|
; RUN: llc -O0 -filetype=obj %s -o %t.o
|
|
|
|
; RUN: wasm-ld -shared -o %t.wasm %t.o
|
|
|
|
; RUN: obj2yaml %t.wasm | FileCheck %s
|
|
|
|
|
|
|
|
target triple = "wasm32-unknown-unknown"
|
|
|
|
|
2018-11-30 04:07:13 +08:00
|
|
|
@data = hidden global i32 2, align 4
|
2018-11-15 08:37:21 +08:00
|
|
|
@indirect_func = local_unnamed_addr global void ()* @foo, align 4
|
2018-11-30 04:07:13 +08:00
|
|
|
@indirect_func_external = local_unnamed_addr global void ()* @func_external, align 4
|
2018-11-15 08:37:21 +08:00
|
|
|
|
|
|
|
define default void @foo() {
|
|
|
|
entry:
|
2018-11-16 02:15:54 +08:00
|
|
|
; To ensure we use __stack_pointer
|
|
|
|
%ptr = alloca i32
|
2018-11-30 04:07:13 +08:00
|
|
|
%0 = load i32, i32* @data, align 4
|
|
|
|
%1 = load i32, i32* @data_external, align 4
|
|
|
|
%2 = load void ()*, void ()** @indirect_func, align 4
|
|
|
|
call void %2()
|
2018-11-15 08:37:21 +08:00
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2018-11-30 04:07:13 +08:00
|
|
|
declare void @func_external()
|
|
|
|
|
|
|
|
@data_external = external global i32
|
|
|
|
|
|
|
|
|
2018-11-15 08:37:21 +08:00
|
|
|
; check for dylink section at start
|
|
|
|
|
|
|
|
; CHECK: Sections:
|
|
|
|
; CHECK-NEXT: - Type: CUSTOM
|
|
|
|
; CHECK-NEXT: Name: dylink
|
2018-11-30 04:07:13 +08:00
|
|
|
; CHECK-NEXT: MemorySize: 8
|
2018-11-15 08:37:21 +08:00
|
|
|
; CHECK-NEXT: MemoryAlignment: 2
|
2018-11-30 04:07:13 +08:00
|
|
|
; CHECK-NEXT: TableSize: 2
|
2018-11-15 08:37:21 +08:00
|
|
|
; CHECK-NEXT: TableAlignment: 0
|
|
|
|
|
|
|
|
; check for import of __table_base and __memory_base globals
|
|
|
|
|
|
|
|
; CHECK: - Type: IMPORT
|
|
|
|
; CHECK-NEXT: Imports:
|
|
|
|
; CHECK-NEXT: - Module: env
|
|
|
|
; CHECK-NEXT: Field: __indirect_function_table
|
|
|
|
; CHECK-NEXT: Kind: TABLE
|
|
|
|
; CHECK-NEXT: Table:
|
2019-01-08 14:25:55 +08:00
|
|
|
; CHECK-NEXT: ElemType: FUNCREF
|
2018-11-15 08:37:21 +08:00
|
|
|
; CHECK-NEXT: Limits:
|
2018-11-30 04:07:13 +08:00
|
|
|
; CHECK-NEXT: Initial: 0x00000002
|
2018-11-15 08:37:21 +08:00
|
|
|
; CHECK-NEXT: - Module: env
|
2018-11-16 02:15:54 +08:00
|
|
|
; CHECK-NEXT: Field: __stack_pointer
|
|
|
|
; CHECK-NEXT: Kind: GLOBAL
|
|
|
|
; CHECK-NEXT: GlobalType: I32
|
|
|
|
; CHECK-NEXT: GlobalMutable: true
|
|
|
|
; CHECK-NEXT: - Module: env
|
2018-11-15 08:37:21 +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
|
|
|
|
|
|
|
|
; check for elem segment initialized with __table_base global as offset
|
|
|
|
|
|
|
|
; CHECK: - Type: ELEM
|
|
|
|
; CHECK-NEXT: Segments:
|
|
|
|
; CHECK-NEXT: - Offset:
|
2019-01-08 14:25:55 +08:00
|
|
|
; CHECK-NEXT: Opcode: GLOBAL_GET
|
2018-11-16 02:15:54 +08:00
|
|
|
; CHECK-NEXT: Index: 2
|
2018-11-30 04:07:13 +08:00
|
|
|
; CHECK-NEXT: Functions: [ 2, 0 ]
|
2018-11-15 08:37:21 +08:00
|
|
|
|
|
|
|
; check the data segment initialized with __memory_base global as offset
|
|
|
|
|
|
|
|
; CHECK: - Type: DATA
|
|
|
|
; CHECK-NEXT: Segments:
|
|
|
|
; CHECK-NEXT: - SectionOffset: 6
|
|
|
|
; CHECK-NEXT: MemoryIndex: 0
|
|
|
|
; CHECK-NEXT: Offset:
|
2019-01-08 14:25:55 +08:00
|
|
|
; CHECK-NEXT: Opcode: GLOBAL_GET
|
2018-11-16 02:15:54 +08:00
|
|
|
; CHECK-NEXT: Index: 1
|
2018-11-30 04:07:13 +08:00
|
|
|
; CHECK-NEXT: Content: '0000000001000000'
|