
This change allows a WasmObjectFile to be created from a wasm file even if it uses typed funcrefs and GC types. It does not significantly change how lib/Object models its various internal types (e.g. WasmSignature, WasmElemSegment), so LLVM does not really "support" or understand such files, but it is sufficient to parse the type, global and element sections, discarding types that are not understood. This is useful for low-level binary tools such as nm and objcopy, which use only limited aspects of the binary (such as function definitions) or deal with sections as opaque blobs. This is done by allowing `WasmValType` to have a value of `OTHERREF` (representing any unmodeled reference type), and adding a field to `WasmSignature` indicating it's a placeholder for an unmodeled reference type (since there is a 1:1 correspondence between WasmSignature objects and types in the type section). Then the object file parsers for the type and element sections are expanded to parse encoded reference types and discard any unmodeled fields.
113 lines
4.0 KiB
Plaintext
113 lines
4.0 KiB
Plaintext
RUN: obj2yaml %p/Inputs/WASM/multi-table.wasm | FileCheck %s
|
|
|
|
|
|
# CHECK: - Type: TABLE
|
|
# CHECK: Tables:
|
|
# CHECK: - Index: 1
|
|
# CHECK: ElemType: FUNCREF
|
|
# CHECK: Limits:
|
|
# CHECK: Flags: [ HAS_MAX ]
|
|
# CHECK: Minimum: 0x3
|
|
# CHECK: Maximum: 0x3
|
|
# CHECK: - Index: 2
|
|
# CHECK: ElemType: FUNCREF
|
|
# CHECK: Limits:
|
|
# CHECK: Flags: [ HAS_MAX ]
|
|
# CHECK: Minimum: 0x4
|
|
# CHECK: Maximum: 0x4
|
|
# CHECK: - Index: 3
|
|
# CHECK: ElemType: EXTERNREF
|
|
# CHECK: Limits:
|
|
# CHECK: Minimum: 0x0
|
|
# CHECK: - Index: 4
|
|
# CHECK: ElemType: OTHERREF
|
|
# CHECK: Limits:
|
|
# CHECK: Flags: [ HAS_MAX ]
|
|
# CHECK: Minimum: 0x5
|
|
# CHECK: Maximum: 0x5
|
|
# CHECK: - Type: GLOBAL
|
|
# CHECK: Globals:
|
|
# CHECK: - Index: 0
|
|
# CHECK: Type: OTHERREF
|
|
# CHECK: Mutable: false
|
|
# CHECK: InitExpr:
|
|
# CHECK: Extended: true
|
|
# CHECK: Body: D2000B
|
|
# CHECK: - Index: 1
|
|
# CHECK: Type: I32
|
|
# CHECK: Mutable: false
|
|
# CHECK: InitExpr:
|
|
# CHECK: Opcode: I32_CONST
|
|
# CHECK: Value: 0
|
|
# CHECK: - Type: ELEM
|
|
# CHECK: Segments:
|
|
# CHECK: - Offset:
|
|
# CHECK: Opcode: I32_CONST
|
|
# CHECK: Value: 0
|
|
# CHECK: Functions: [ 0 ]
|
|
# CHECK: - Flags: 2
|
|
# CHECK: TableNumber: 1
|
|
# CHECK: ElemKind: FUNCREF
|
|
# CHECK: Offset:
|
|
# CHECK: Opcode: I32_CONST
|
|
# CHECK: Value: 0
|
|
# CHECK: Functions: [ 0 ]
|
|
# CHECK: - Flags: 2
|
|
# CHECK: TableNumber: 1
|
|
# CHECK: ElemKind: FUNCREF
|
|
# CHECK: Offset:
|
|
# CHECK: Opcode: I32_CONST
|
|
# CHECK: Value: 1
|
|
# CHECK: Functions: [ 0, 1 ]
|
|
# CHECK: - Flags: 6
|
|
# CHECK: TableNumber: 2
|
|
# CHECK: ElemKind: FUNCREF
|
|
# CHECK: Offset:
|
|
# CHECK: Opcode: GLOBAL_GET
|
|
# CHECK: Index: 1
|
|
# There are 2 funcions encoded with initexprs in this segment
|
|
# but initexprs in tables are unmodeled.
|
|
# CHECK: Functions: [ ]
|
|
# CHECK: - Flags: 6
|
|
# CHECK: TableNumber: 2
|
|
# This elemkind is OTHERREF because it's encoded as a typed funcref
|
|
# CHECK: ElemKind: OTHERREF
|
|
# CHECK: Offset:
|
|
# CHECK: Opcode: I32_CONST
|
|
# CHECK: Value: 2
|
|
# CHECK: Functions: [ ]
|
|
# CHECK: - Flags: 1
|
|
# CHECK: ElemKind: FUNCREF
|
|
# CHECK: Offset:
|
|
# CHECK: Opcode: I32_CONST
|
|
# CHECK: Value: 0
|
|
# CHECK: Functions: [ 0, 1 ]
|
|
# CHECK: - Flags: 5
|
|
# CHECK: ElemKind: FUNCREF
|
|
# CHECK: Offset:
|
|
# CHECK: Opcode: I32_CONST
|
|
# CHECK: Value: 0
|
|
# Empty function list, encoded with initexprs
|
|
# CHECK: Functions: [ ]
|
|
# CHECK: - Flags: 5
|
|
# CHECK: ElemKind: OTHERREF
|
|
# CHECK: Offset:
|
|
# CHECK: Opcode: I32_CONST
|
|
# CHECK: Value: 0
|
|
# Function list encoded with initexprs
|
|
# CHECK: Functions: [ ]
|
|
# CHECK: - Flags: 1
|
|
# CHECK: ElemKind: FUNCREF
|
|
# CHECK: Offset:
|
|
# CHECK: Opcode: I32_CONST
|
|
# CHECK: Value: 0
|
|
# CHECK: Functions: [ ]
|
|
# CHECK: - Flags: 6
|
|
# CHECK: TableNumber: 4
|
|
# CHECK: ElemKind: OTHERREF
|
|
# CHECK: Offset:
|
|
# CHECK: Opcode: I32_CONST
|
|
# CHECK: Value: 0
|
|
# Function list encoded with initexprs
|
|
# CHECK: Functions: [ ]
|