mirror of
https://github.com/intel/llvm.git
synced 2026-01-22 15:41:35 +08:00
This change adds support for a new WASM_SEG_FLAG_STRINGS flag in
the object format which works in a similar fashion to SHF_STRINGS
in the ELF world.
Unlike the ELF linker this support is currently limited:
- No support for SHF_MERGE (non-string merging)
- Always do full tail merging ("lo" can be merged with "hello")
- Only support single byte strings (p2align 0)
Like the ELF linker merging is only performed at `-O1` and above.
This fixes part of https://bugs.llvm.org/show_bug.cgi?id=48828,
although crucially it doesn't not currently support debug sections
because they are not represented by data segments (they are custom
sections)
Differential Revision: https://reviews.llvm.org/D97657
66 lines
2.4 KiB
ArmAsm
66 lines
2.4 KiB
ArmAsm
// RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %s -o %t.o
|
|
// RUN: wasm-ld -O2 %t.o -o %t.wasm --no-gc-sections --no-entry
|
|
// RUN: obj2yaml %t.wasm | FileCheck %s --check-prefixes=COMMON,MERGE
|
|
// RUN: wasm-ld -O0 %t.o -o %t2.wasm --no-gc-sections --no-entry
|
|
// RUN: obj2yaml %t2.wasm | FileCheck --check-prefixes=COMMON,NOMERGE %s
|
|
|
|
.section .rodata1,"S",@
|
|
.asciz "abc"
|
|
foo:
|
|
.ascii "a"
|
|
.size foo, 1
|
|
bar:
|
|
.asciz "bc"
|
|
.asciz "bc"
|
|
.size bar, 4
|
|
|
|
.globl foo
|
|
.globl bar
|
|
.export_name foo, foo
|
|
.export_name bar, bar
|
|
|
|
// COMMON: - Type: GLOBAL
|
|
// COMMON-NEXT: Globals:
|
|
// COMMON-NEXT: - Index: 0
|
|
// COMMON-NEXT: Type: I32
|
|
// COMMON-NEXT: Mutable: true
|
|
// COMMON-NEXT: InitExpr:
|
|
// COMMON-NEXT: Opcode: I32_CONST
|
|
// COMMON-NEXT: Value: 66576
|
|
// COMMON-NEXT: - Index: 1
|
|
// COMMON-NEXT: Type: I32
|
|
// COMMON-NEXT: Mutable: false
|
|
// COMMON-NEXT: InitExpr:
|
|
// COMMON-NEXT: Opcode: I32_CONST
|
|
// MERGE-NEXT: Value: 1024
|
|
// NOMERGE-NEXT: Value: 1028
|
|
// COMMON-NEXT: - Index: 2
|
|
// COMMON-NEXT: Type: I32
|
|
// COMMON-NEXT: Mutable: false
|
|
// COMMON-NEXT: InitExpr:
|
|
// COMMON-NEXT: Opcode: I32_CONST
|
|
// MERGE-NEXT: Value: 1025
|
|
// NOMERGE-NEXT: Value: 1029
|
|
// COMMON-NEXT: - Type: EXPORT
|
|
// COMMON-NEXT: Exports:
|
|
// COMMON-NEXT: - Name: memory
|
|
// COMMON-NEXT: Kind: MEMORY
|
|
// COMMON-NEXT: Index: 0
|
|
// COMMON-NEXT: - Name: foo
|
|
// COMMON-NEXT: Kind: GLOBAL
|
|
// COMMON-NEXT: Index: 1
|
|
// COMMON-NEXT: - Name: bar
|
|
// COMMON-NEXT: Kind: GLOBAL
|
|
// COMMON-NEXT: Index: 2
|
|
|
|
//
|
|
// COMMON: - Type: DATA
|
|
// COMMON-NEXT: Segments:
|
|
// COMMON-NEXT: - SectionOffset: 7
|
|
// COMMON-NEXT: InitFlags: 0
|
|
// COMMON-NEXT: Offset:
|
|
// COMMON-NEXT: Opcode: I32_CONST
|
|
// COMMON-NEXT: Value: 1024
|
|
// MERGE-NEXT: Content: '61626300'
|
|
// NOMERGE-NEXT: Content: '6162630061626300626300'
|