xref: /llvm-project/llvm/test/MC/WebAssembly/data-section.s (revision 9ac5620cb8548c0bd0150f0da68219dd3a5a657a)
1# RUN: llvm-mc -triple=wasm32-unknown-unknown -mattr=+simd128,+nontrapping-fptoint,+exception-handling < %s | FileCheck %s
2# Check that it converts to .o without errors:
3# RUN: llvm-mc -triple=wasm32-unknown-unknown -filetype=obj -mattr=+simd128,+nontrapping-fptoint,+exception-handling < %s | obj2yaml | FileCheck -check-prefixes=BIN,BIN32 %s
4
5# Same again for wasm64
6
7# RUN: llvm-mc -triple=wasm64-unknown-unknown -mattr=+simd128,+nontrapping-fptoint,+exception-handling < %s | FileCheck %s
8# Check that it converts to .o without errors:
9# RUN: llvm-mc -triple=wasm64-unknown-unknown -filetype=obj -mattr=+simd128,+nontrapping-fptoint,+exception-handling < %s | obj2yaml | FileCheck -check-prefixes=BIN,BIN64 %s
10
11# Minimal test for data sections.
12
13test0:
14    .functype   test0 () -> (i32)
15    i32.const .L.str
16.Ltestlabel:
17    end_function
18
19    .section	.rodata..L.str,"",@
20.L.str:
21    .int8	100
22    .size	.L.str, 1
23
24
25# CHECK:           .text
26# CHECK-LABEL: test0:
27# CHECK-NEXT:      .functype test0 () -> (i32)
28# CHECK-NEXT:      i32.const .L.str
29# CHECK-NEXT:  .Ltestlabel:
30# CHECK-NEXT:      end_function
31
32# CHECK:	    .section	.rodata..L.str,"",@
33# CHECK-NEXT:.L.str:
34# CHECK-NEXT:	.int8	100
35
36
37# BIN:      --- !WASM
38# BIN-NEXT: FileHeader:
39# BIN-NEXT:   Version:         0x1
40# BIN-NEXT: Sections:
41# BIN-NEXT:   - Type:            TYPE
42# BIN-NEXT:     Signatures:
43# BIN-NEXT:       - Index:           0
44# BIN-NEXT:         ParamTypes:      []
45# BIN-NEXT:         ReturnTypes:
46# BIN-NEXT:           - I32
47# BIN-NEXT:   - Type:            IMPORT
48# BIN-NEXT:     Imports:
49# BIN-NEXT:       - Module:          env
50# BIN-NEXT:         Field:           __linear_memory
51# BIN-NEXT:         Kind:            MEMORY
52# BIN-NEXT:         Memory:
53# BIN64-NEXT:         Flags:           [ IS_64 ]
54# BIN-NEXT:           Minimum:         0x1
55# BIN-NEXT:   - Type:            FUNCTION
56# BIN-NEXT:     FunctionTypes:   [ 0 ]
57# BIN-NEXT:   - Type:            DATACOUNT
58# BIN-NEXT:     Count:           1
59# BIN-NEXT:   - Type:            CODE
60# BIN-NEXT:     Relocations:
61# BIN-NEXT:       - Type:            R_WASM_MEMORY_ADDR_SLEB
62# BIN-NEXT:         Index:           1
63# BIN-NEXT:         Offset:          0x4
64# BIN-NEXT:     Functions:
65# BIN-NEXT:       - Index:           0
66# BIN-NEXT:         Locals:          []
67# BIN-NEXT:         Body:            4180808080000B
68# BIN-NEXT:   - Type:            DATA
69# BIN-NEXT:     Segments:
70# BIN-NEXT:       - SectionOffset:   6
71# BIN-NEXT:         InitFlags:       0
72# BIN-NEXT:         Offset:
73# BIN32-NEXT:         Opcode:          I32_CONST
74# BIN64-NEXT:         Opcode:          I64_CONST
75# BIN-NEXT:           Value:           0
76# BIN-NEXT:         Content:         '64'
77# BIN-NEXT:   - Type:            CUSTOM
78# BIN-NEXT:     Name:            linking
79# BIN-NEXT:     Version:         2
80# BIN-NEXT:     SymbolTable:
81# BIN-NEXT:       - Index:           0
82# BIN-NEXT:         Kind:            FUNCTION
83# BIN-NEXT:         Name:            test0
84# BIN-NEXT:         Flags:           [ BINDING_LOCAL ]
85# BIN-NEXT:         Function:        0
86# BIN-NEXT:       - Index:           1
87# BIN-NEXT:         Kind:            DATA
88# BIN-NEXT:         Name:            .L.str
89# BIN-NEXT:         Flags:           [ BINDING_LOCAL ]
90# BIN-NEXT:         Segment:         0
91# BIN-NEXT:         Size:            1
92# BIN-NEXT:     SegmentInfo:
93# BIN-NEXT:       - Index:           0
94# BIN-NEXT:         Name:            .rodata..L.str
95# BIN-NEXT:         Alignment:       0
96# BIN-NEXT:         Flags:           [  ]
97# BIN-NEXT: ...
98