1// RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %s -o %t.o 2// RUN: wasm-ld -O1 %t.o -o %t.wasm --no-gc-sections --no-entry 3// RUN: obj2yaml %t.wasm | FileCheck %s --check-prefixes=COMMON,MERGE 4 5// Check that the default is the same as -O1 (since we default to -O1) 6// RUN: wasm-ld %t.o -o %t.wasm --no-gc-sections --no-entry 7// RUN: obj2yaml %t.wasm | FileCheck %s --check-prefixes=COMMON,MERGE 8 9// Check that -O0 disables merging 10// RUN: wasm-ld -O0 %t.o -o %t2.wasm --no-gc-sections --no-entry 11// RUN: obj2yaml %t2.wasm | FileCheck --check-prefixes=COMMON,NOMERGE %s 12 13// Check relocatable 14// RUN: wasm-ld -r %t.o -o %t2.o 15// RUN: obj2yaml %t2.o | FileCheck --check-prefixes=RELOC %s 16 17 .section .rodata1,"S",@ 18 .asciz "abc" 19foo: 20 .ascii "a" 21 .size foo, 1 22bar: 23 .asciz "bc" 24 .asciz "bc" 25 .size bar, 6 26 27 .section .rodata_relocs,"",@ 28negative_addend: 29 .int32 foo-10 30 .size negative_addend, 4 31 32.globl foo 33.globl bar 34.export_name foo, foo 35.export_name bar, bar 36 37// COMMON: - Type: GLOBAL 38// COMMON-NEXT: Globals: 39// COMMON-NEXT: - Index: 0 40// COMMON-NEXT: Type: I32 41// COMMON-NEXT: Mutable: true 42// COMMON-NEXT: InitExpr: 43// COMMON-NEXT: Opcode: I32_CONST 44// COMMON-NEXT: Value: 66576 45// COMMON-NEXT: - Index: 1 46// COMMON-NEXT: Type: I32 47// COMMON-NEXT: Mutable: false 48// COMMON-NEXT: InitExpr: 49// COMMON-NEXT: Opcode: I32_CONST 50// MERGE-NEXT: Value: 1024 51// NOMERGE-NEXT: Value: 1028 52// COMMON-NEXT: - Index: 2 53// COMMON-NEXT: Type: I32 54// COMMON-NEXT: Mutable: false 55// COMMON-NEXT: InitExpr: 56// COMMON-NEXT: Opcode: I32_CONST 57// MERGE-NEXT: Value: 1025 58// NOMERGE-NEXT: Value: 1029 59// COMMON-NEXT: - Type: EXPORT 60// COMMON-NEXT: Exports: 61// COMMON-NEXT: - Name: memory 62// COMMON-NEXT: Kind: MEMORY 63// COMMON-NEXT: Index: 0 64// COMMON-NEXT: - Name: foo 65// COMMON-NEXT: Kind: GLOBAL 66// COMMON-NEXT: Index: 1 67// COMMON-NEXT: - Name: bar 68// COMMON-NEXT: Kind: GLOBAL 69// COMMON-NEXT: Index: 2 70 71// 72// COMMON: - Type: DATA 73// COMMON-NEXT: Segments: 74// COMMON-NEXT: - SectionOffset: 7 75// COMMON-NEXT: InitFlags: 0 76// COMMON-NEXT: Offset: 77// COMMON-NEXT: Opcode: I32_CONST 78// COMMON-NEXT: Value: 1024 79// MERGE-NEXT: Content: '61626300' 80// NOMERGE-NEXT: Content: '6162630061626300626300' 81 82 83// RELOC: - Type: DATA 84// RELOC-NEXT: Relocations: 85// RELOC-NEXT: - Type: R_WASM_MEMORY_ADDR_I32 86// RELOC-NEXT: Index: 0 87// RELOC-NEXT: Offset: 0xF 88// RELOC-NEXT: Addend: -10 89// RELOC-NEXT: Segments: 90// RELOC-NEXT: - SectionOffset: 6 91// RELOC-NEXT: InitFlags: 0 92// RELOC-NEXT: Offset: 93// RELOC-NEXT: Opcode: I32_CONST 94// RELOC-NEXT: Value: 0 95// RELOC-NEXT: Content: '61626300' 96// RELOC-NEXT: - SectionOffset: 15 97// RELOC-NEXT: InitFlags: 0 98// RELOC-NEXT: Offset: 99// RELOC-NEXT: Opcode: I32_CONST 100// RELOC-NEXT: Value: 4 101// RELOC-NEXT: Content: F6FFFFFF 102