1; RUN: llc -relocation-model=pic -mattr=+mutable-globals -filetype=obj %s -o %t.o 2; RUN: wasm-ld --no-gc-sections --allow-undefined --experimental-pic -pie -o %t.wasm %t.o 3; RUN: obj2yaml %t.wasm | FileCheck %s 4 5target triple = "wasm32-unknown-emscripten" 6 7@data = global i32 2, align 4 8@data_external = external global i32 9@indirect_func = local_unnamed_addr global i32 ()* @foo, align 4 10 11@data_addr = local_unnamed_addr global i32* @data, align 4 12@data_addr_external = local_unnamed_addr global i32* @data_external, align 4 13 14define hidden i32 @foo() { 15entry: 16 ; To ensure we use __stack_pointer 17 %ptr = alloca i32 18 %0 = load i32, i32* @data, align 4 19 %1 = load i32 ()*, i32 ()** @indirect_func, align 4 20 call i32 %1() 21 ret i32 %0 22} 23 24define default i32** @get_data_address() { 25entry: 26 ret i32** @data_addr_external 27} 28 29define void @_start() { 30 ret void 31} 32 33; CHECK: Sections: 34; CHECK-NEXT: - Type: CUSTOM 35; CHECK-NEXT: Name: dylink 36; CHECK-NEXT: MemorySize: 16 37; CHECK-NEXT: MemoryAlignment: 2 38; CHECK-NEXT: TableSize: 1 39; CHECK-NEXT: TableAlignment: 0 40; CHECK-NEXT: Needed: [] 41 42; CHECK: - Type: IMPORT 43; CHECK-NEXT: Imports: 44; CHECK-NEXT: - Module: env 45; CHECK-NEXT: Field: __indirect_function_table 46; CHECK-NEXT: Kind: TABLE 47; CHECK-NEXT: Table: 48; CHECK-NEXT: Index: 0 49; CHECK-NEXT: ElemType: FUNCREF 50; CHECK-NEXT: Limits: 51; CHECK-NEXT: Initial: 0x1 52; CHECK-NEXT: - Module: env 53; CHECK-NEXT: Field: __stack_pointer 54; CHECK-NEXT: Kind: GLOBAL 55; CHECK-NEXT: GlobalType: I32 56; CHECK-NEXT: GlobalMutable: true 57; CHECK-NEXT: - Module: env 58; CHECK-NEXT: Field: __memory_base 59; CHECK-NEXT: Kind: GLOBAL 60; CHECK-NEXT: GlobalType: I32 61; CHECK-NEXT: GlobalMutable: false 62; CHECK-NEXT: - Module: env 63; CHECK-NEXT: Field: __table_base 64; CHECK-NEXT: Kind: GLOBAL 65; CHECK-NEXT: GlobalType: I32 66; CHECK-NEXT: GlobalMutable: false 67 68 69