blob: f64a4a318cfc4694be81abf7f6f758d0ade809f9 [file] [edit]
# REQUIRES: webassembly
# An export cannot name a location in linear memory, so a variable in linear
# memory is exported as an immutable global that holds its address. Such an
# export becomes a data symbol at that address.
# RUN: yaml2obj %s -o %t.wasm
# RUN: %lldb %t.wasm \
# RUN: -o "target modules dump symtab" \
# RUN: -o "image lookup -s g_data" \
# RUN: -o "image lookup -s g_bss" \
# RUN: -o "image lookup -s g_data64" \
# RUN: -o exit 2>&1 | FileCheck %s \
# RUN: --implicit-check-not=g_mutable --implicit-check-not=g_named_export \
# RUN: --implicit-check-not=g_outside --implicit-check-not=g_float \
# RUN: --implicit-check-not=g_imported
# CHECK: Dumping symbol table
# CHECK: Code {{.*}}get_42
# CHECK: Data 0x8000000000000004 0x0000000000000001 {{.*}}g_named
# CHECK: Data 0x0000000000000400 0x0000000000000001 {{.*}}g_data
# CHECK: Data 0x0000000000000800 0x0000000000000001 {{.*}}g_bss
# CHECK: Data 0x0000000000000404 0x0000000000000001 {{.*}}g_data64
# CHECK: 1 symbols match 'g_data'
# CHECK: (wasm-export-data-symbols.yaml.tmp.wasm..data + 0)
# CHECK: 1 symbols match 'g_bss'
# CHECK: (wasm-export-data-symbols.yaml.tmp.wasm..bss + 1016)
# CHECK: 1 symbols match 'g_data64'
# CHECK: (wasm-export-data-symbols.yaml.tmp.wasm..data + 4)
--- !WASM
FileHeader:
Version: 0x1
Sections:
- Type: TYPE
Signatures:
- Index: 0
ParamTypes: []
ReturnTypes:
- I32
- Type: IMPORT
Imports:
# Not a variable of this module. Global indices count it, so the globals
# below start at index 1.
- Module: env
Field: g_imp
Kind: GLOBAL
GlobalType: I32
GlobalMutable: false
- Type: FUNCTION
FunctionTypes: [ 0 ]
- Type: MEMORY
Memories:
- Minimum: 0x1
- Type: GLOBAL
Globals:
# In the data segment.
- Index: 1
Type: I32
Mutable: false
InitExpr:
Opcode: I32_CONST
Value: 1024
# Past the data segment, in the zero-fill rest of linear memory.
- Index: 2
Type: I32
Mutable: false
InitExpr:
Opcode: I32_CONST
Value: 2048
# A global the program writes to does not hold an address.
- Index: 3
Type: I32
Mutable: true
InitExpr:
Opcode: I32_CONST
Value: 1024
# Named by the name section, so a wasm global in its own right.
- Index: 4
Type: I32
Mutable: false
InitExpr:
Opcode: I32_CONST
Value: 1028
# Outside linear memory.
- Index: 5
Type: I32
Mutable: false
InitExpr:
Opcode: I32_CONST
Value: 131072
# The bits of a float, not an address.
- Index: 6
Type: F32
Mutable: false
InitExpr:
Opcode: F32_CONST
Value: 1024
# An address can be an i64 value too.
- Index: 7
Type: I64
Mutable: false
InitExpr:
Opcode: I64_CONST
Value: 1028
- Type: EXPORT
Exports:
- Name: memory
Kind: MEMORY
Index: 0
- Name: get_42
Kind: FUNCTION
Index: 0
- Name: g_imported
Kind: GLOBAL
Index: 0
- Name: g_data
Kind: GLOBAL
Index: 1
- Name: g_bss
Kind: GLOBAL
Index: 2
- Name: g_mutable
Kind: GLOBAL
Index: 3
- Name: g_named_export
Kind: GLOBAL
Index: 4
- Name: g_outside
Kind: GLOBAL
Index: 5
- Name: g_float
Kind: GLOBAL
Index: 6
- Name: g_data64
Kind: GLOBAL
Index: 7
- Type: CODE
Functions:
- Index: 0
Locals: []
Body: 412A0F0B
- Type: DATA
Segments:
- SectionOffset: 6
InitFlags: 0
Offset:
Opcode: I32_CONST
Value: 1024
Content: 'DEADBEEFCAFEF00D'
- Type: CUSTOM
Name: name
FunctionNames:
- Index: 0
Name: get_42
GlobalNames:
- Index: 4
Name: g_named
DataSegmentNames:
- Index: 0
Name: .data
...