1 # RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -o %t.o %s
2 # RUN: wasm-ld -r -o %t.wasm %t.o
3 # RUN: obj2yaml %t.wasm | FileCheck %s
4 # RUN: llvm-objdump --disassemble-symbols=_start --no-show-raw-insn --no-leading-addr %t.wasm | FileCheck %s --check-prefixes DIS
11 # Similar to what would be generated from: `int foo[76]`
12 .section .bss.foo,"",@
18 # bar contains a pointer to the 16th element of foo, which happens to be 64
19 # bytes in. This generates an addend of 64 which is the value at which signed
20 # and unsigned LEB encodes will differ.
21 .section .data.bar,"",@
27 # Check that negative addends also work here
28 .section .data.negative_addend,"",@
32 .size negative_addend, 4
37 .functype _start () -> ()
45 # This will underflow because i32.load (and the
46 # corresponding relocation type) take an unsgiend (U32)
53 # CHECK-NEXT: Relocations:
54 # CHECK-NEXT: - Type: R_WASM_MEMORY_ADDR_LEB
55 # CHECK-NEXT: Index: 0
56 # CHECK-NEXT: Offset: 0x7
57 # CHECK-NEXT: Addend: 10
58 # CHECK-NEXT: - Type: R_WASM_MEMORY_ADDR_LEB
59 # CHECK-NEXT: Index: 0
60 # CHECK-NEXT: Offset: 0x11
61 # CHECK-NEXT: Addend: -10
62 # CHECK-NEXT: - Type: R_WASM_MEMORY_ADDR_LEB
63 # CHECK-NEXT: Index: 0
64 # CHECK-NEXT: Offset: 0x1B
65 # CHECK-NEXT: Addend: -2048
68 # CHECK-NEXT: Relocations:
69 # CHECK-NEXT: - Type: R_WASM_MEMORY_ADDR_I32
70 # CHECK-NEXT: Index: 0
71 # CHECK-NEXT: Offset: 0x6
72 # CHECK-NEXT: Addend: 64
73 # CHECK-NEXT: - Type: R_WASM_MEMORY_ADDR_I32
74 # CHECK-NEXT: Index: 0
75 # CHECK-NEXT: Offset: 0xF
76 # CHECK-NEXT: Addend: -16
80 # DIS-NEXT: i32.const 0
81 # DIS-NEXT: i32.load 26
83 # DIS-NEXT: i32.const 0
84 # DIS-NEXT: i32.load 6
86 # DIS-NEXT: i32.const 0
87 # TODO(sbc): We should probably error here rather than allowing u32 to wrap
88 # DIS-NEXT: i32.load 4294965264