54 lines · plain
1; RUN: llc -O2 -filetype=obj %s -o - | llvm-readobj -S -r --expand-relocs - | FileCheck %s2 3target triple = "wasm32-unknown-unknown"4 5declare i32 @import1()6declare i32 @import2()7declare i32 @import3()8 9; call the imports to make sure they are included in the imports section10define hidden void @call_imports() #0 {11entry:12 %call = call i32 @import1()13 %call1 = call i32 @import2()14 ret void15}16 17; take the address of the third import. This should generate a TABLE_INDEX18; relocation with index of 0 since its the first and only address taken19; function.20define hidden void @call_indirect() #0 {21entry:22 %adr = alloca ptr, align 423 store ptr @import3, ptr %adr, align 424 ret void25}26 27; CHECK: Type: ELEM (0x9)28; CHECK-NEXT: Size: 729 30; CHECK: Relocations [31; CHECK-NEXT: Section (5) CODE {32; CHECK-NEXT: Relocation {33; CHECK-NEXT: Type: R_WASM_FUNCTION_INDEX_LEB (0)34; CHECK-NEXT: Offset: 0x435; CHECK-NEXT: Symbol: import136; CHECK-NEXT: }37; CHECK-NEXT: Relocation {38; CHECK-NEXT: Type: R_WASM_FUNCTION_INDEX_LEB (0)39; CHECK-NEXT: Offset: 0xB40; CHECK-NEXT: Symbol: import241; CHECK-NEXT: }42; CHECK-NEXT: Relocation {43; CHECK-NEXT: Type: R_WASM_GLOBAL_INDEX_LEB (7)44; CHECK-NEXT: Offset: 0x1545; CHECK-NEXT: Symbol: __stack_pointer46; CHECK-NEXT: }47; CHECK-NEXT: Relocation {48; CHECK-NEXT: Type: R_WASM_TABLE_INDEX_SLEB (1)49; CHECK-NEXT: Offset: 0x1E50; CHECK-NEXT: Symbol: import351; CHECK-NEXT: }52; CHECK-NEXT: }53; CHECK-NEXT: ]54