llvm.org GIT mirror llvm / 3ba6566
[WebAssembly] Be consistent in generating trivial test input files For each checked-in wasm file, make sure the there is corresponding .ll file that can be used to regenerate it if needed. Add test/Object/Inputs/trivial-object-test.wasm to match other formats and add some new wasm tests in test/Object. Differential Revision: https://reviews.llvm.org/D35213 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307585 91177308-0d34-0410-b5e6-96231b3b80d8 Sam Clegg 2 years ago
16 changed file(s) with 186 addition(s) and 114 deletion(s). Raw diff Collapse all Expand all
0 ; Input used for generating checked-in binaries (trivial-object-test.*)
1 ; llc -mtriple=wasm32-unknown-unknown-wasm trivial.ll -filetype=obj -o trivial-object-test.wasm
2
3 @.str = private unnamed_addr constant [13 x i8] c"Hello World\0A\00", align 1
14
25 define i32 @main() nounwind {
11 RUN: | FileCheck %s -check-prefix COFF32
22 RUN: yaml2obj %p/Inputs/COFF/x86-64.yaml | llvm-nm -a -S - \
33 RUN: | FileCheck %s -check-prefix COFF64
4 RUN: llvm-nm %p/Inputs/trivial-object-test.wasm \
5 RUN: | FileCheck %s -check-prefix WASM
46 RUN: llvm-nm %p/Inputs/trivial-object-test.elf-i386 \
57 RUN: | FileCheck %s -check-prefix ELF
68 RUN: llvm-nm %p/Inputs/trivial-object-test.elf-i386 -S \
5557 COFF32-NEXT: U _SomeOtherFunction
5658 COFF32-NEXT: 00000000 T _main
5759 COFF32-NEXT: U _puts
60
61 WASM: U SomeOtherFunction
62 WASM-NEXT: 00000002 T main
63 WASM-NEXT: U puts
64 WASM-NEXT: 00000001 D var
5865
5966 COFF64: 00000000 d .data
6067 COFF64-NEXT: 00000000 t .text
33 RUN: obj2yaml %p/Inputs/trivial-object-test.elf-mips64el | FileCheck %s --check-prefix ELF-MIPS64EL
44 RUN: obj2yaml %p/Inputs/trivial-object-test.elf-x86-64 | FileCheck %s --check-prefix ELF-X86-64
55 RUN: obj2yaml %p/Inputs/trivial-object-test.elf-avr | FileCheck %s --check-prefix ELF-AVR
6 RUN: obj2yaml %p/Inputs/unwind-section.elf-x86-64 \
7 RUN: | FileCheck %s --check-prefix ELF-X86-64-UNWIND
6 RUN: obj2yaml %p/Inputs/trivial-object-test.wasm | FileCheck %s --check-prefix WASM
7 RUN: obj2yaml %p/Inputs/unwind-section.elf-x86-64 | FileCheck %s --check-prefix ELF-X86-64-UNWIND
88
99 COFF-I386: header:
1010 COFF-I386-NEXT: Machine: IMAGE_FILE_MACHINE_I386
410410 ELF-X86-64-NEXT: - Name: puts
411411
412412
413 ELF-AVR: FileHeader:
413 ELF-AVR: FileHeader:
414414 ELF-AVR-NEXT: Class: ELFCLASS32
415415 ELF-AVR-NEXT: Data: ELFDATA2LSB
416416 ELF-AVR-NEXT: Type: ET_EXEC
417417 ELF-AVR-NEXT: Machine: EM_AVR
418418 ELF-AVR-NEXT: Flags: [ EF_AVR_ARCH_AVR2 ]
419 ELF-AVR-NEXT: Sections:
419 ELF-AVR-NEXT: Sections:
420420 ELF-AVR-NEXT: - Name: .text
421421 ELF-AVR-NEXT: Type: SHT_PROGBITS
422422 ELF-AVR-NEXT: Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
428428 ELF-AVR-NEXT: Address: 0x0000000000800060
429429 ELF-AVR-NEXT: AddressAlign: 0x0000000000000001
430430 ELF-AVR-NEXT: Content: ''
431 ELF-AVR-NEXT: Symbols:
432 ELF-AVR-NEXT: Local:
431 ELF-AVR-NEXT: Symbols:
432 ELF-AVR-NEXT: Local:
433433 ELF-AVR-NEXT: - Type: STT_SECTION
434434 ELF-AVR-NEXT: Section: .text
435435 ELF-AVR-NEXT: - Type: STT_SECTION
439439 ELF-AVR-NEXT: Type: STT_FILE
440440 ELF-AVR-NEXT: - Name: main
441441 ELF-AVR-NEXT: Section: .text
442 ELF-AVR-NEXT: Global:
442 ELF-AVR-NEXT: Global:
443443 ELF-AVR-NEXT: - Name: __trampolines_start
444444 ELF-AVR-NEXT: Section: .text
445445 ELF-AVR-NEXT: - Name: _etext
469469 ELF-AVR-NEXT: Section: .data
470470 ELF-AVR-NEXT: Value: 0x0000000000800060
471471
472 WASM: --- !WASM
473 WASM-NEXT: FileHeader:
474 WASM-NEXT: Version: 0x00000001
475 WASM: - Type: EXPORT
476 WASM-NEXT: Exports:
477 WASM-NEXT: - Name: main
478 WASM-NEXT: Kind: FUNCTION
479 WASM-NEXT: Index: 2
480 WASM-NEXT: - Name: var
481 WASM-NEXT: Kind: GLOBAL
482 WASM-NEXT: Index: 1
472483
473484 ELF-X86-64-UNWIND: - Name: .eh_frame
474485 ELF-X86-64-UNWIND-NEXT: Type: SHT_X86_64_UNWIND
1111 RUN: | FileCheck %s -check-prefix ELF-MIPS64EL
1212 RUN: llvm-objdump -r %p/Inputs/trivial-object-test.elf-mipsel \
1313 RUN: | FileCheck %s -check-prefix ELF-MIPSEL
14 RUN: llvm-objdump -r %p/Inputs/trivial-object-test.wasm \
15 RUN: | FileCheck %s -check-prefix WASM
1416
1517 RUN: llvm-objdump -r %p/Inputs/relocations.elf-x86-64 \
1618 RUN: | FileCheck %s -check-prefix ELF-complex-x86-64
5658 ELF-MIPSEL: R_MIPS_CALL16 puts
5759 ELF-MIPSEL: R_MIPS_CALL16 SomeOtherFunction
5860
61 WASM: CODE
62 WASM-NEXT: R_WEBASSEMBLY_GLOBAL_ADDR_SLEB 0+0
63 WASM-NEXT: R_WEBASSEMBLY_FUNCTION_INDEX_LEB 0+0
64 WASM-NEXT: R_WEBASSEMBLY_FUNCTION_INDEX_LEB 1+0
65
5966 ELF-complex-x86-64: .text
6067 ELF-complex-x86-64-NEXT: R_X86_64_8 .data-4
6168 ELF-complex-x86-64-NEXT: R_X86_64_16 .data-4
test/tools/llvm-objdump/Inputs/test.wasm less more
Binary diff not shown
0 ; Input used for generating checked-in binaries (trivial.obj.*)
1 ; llc -mtriple=wasm32-unknown-unknown-wasm trivial.ll -filetype=obj -o trivial.obj.wasm
2
3 @.str = private unnamed_addr constant [13 x i8] c"Hello World\0A\00", align 1
4
5 define i32 @main() nounwind {
6 entry:
7 %call = tail call i32 @puts(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i32 0, i32 0)) nounwind
8 tail call void bitcast (void (...)* @SomeOtherFunction to void ()*)() nounwind
9 ret i32 0
10 }
11
12 declare i32 @puts(i8* nocapture) nounwind
13
14 declare void @SomeOtherFunction(...)
15
16 @var = global i32 0
17 @llvm.used = appending global [1 x i8*] [i8* bitcast (i32* @var to i8*)], section "llvm.metadata"
18 @llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* null, i8* null }]
None RUN: llvm-objdump -t %p/../Inputs/test.wasm | FileCheck %s
0 RUN: llvm-objdump -t %p/../Inputs/trivial.obj.wasm | FileCheck %s
11
2 CHECK: SYMBOL TABLE:
3 CHECK: 00000000 l F IMPORT bar
4 CHECK: 00000000 g F EXPORT baz
5 CHECK: 00000001 g F EXPORT quux
6 CHECK: 00000000 l F name $import
7 CHECK: 00000001 l F name $func0
2 CHECK: SYMBOL TABLE:
3 CHECK-NEXT: 00000000 l F IMPORT puts
4 CHECK-NEXT: 00000000 l F IMPORT SomeOtherFunction
5 CHECK-NEXT: 00000002 g F EXPORT main
6 CHECK-NEXT: 00000001 g EXPORT var
7 CHECK-NEXT: 00000000 l F name puts
8 CHECK-NEXT: 00000001 l F name SomeOtherFunction
9 CHECK-NEXT: 00000002 l F name main
10
None # RUN: llvm-objdump -h %p/Inputs/test.wasm | FileCheck %s
0 # RUN: llvm-objdump -h %p/Inputs/trivial.obj.wasm | FileCheck %s
11
2 # CHECK: Sections:
3 # CHECK: Idx Name Size Address Type
4 # CHECK: 0 TYPE 0000000f 0000000000000000
5 # CHECK: 1 IMPORT 0000000b 0000000000000000
6 # CHECK: 2 FUNCTION 00000003 0000000000000000
7 # CHECK: 3 TABLE 00000005 0000000000000000
8 # CHECK: 4 EXPORT 0000000e 0000000000000000
9 # CHECK: 5 ELEM 00000007 0000000000000000
10 # CHECK: 6 CODE 0000002a 0000000000000000 TEXT
11 # CHECK: 7 name 0000003c 0000000000000000
2 # CHECK: Sections:
3 # CHECK-NEXT: Idx Name Size Address Type
4 # CHECK-NEXT: 0 TYPE 0000000e 0000000000000000
5 # CHECK-NEXT: 1 IMPORT 00000024 0000000000000000
6 # CHECK-NEXT: 2 FUNCTION 00000002 0000000000000000
7 # CHECK-NEXT: 3 TABLE 00000004 0000000000000000
8 # CHECK-NEXT: 4 MEMORY 00000003 0000000000000000
9 # CHECK-NEXT: 5 GLOBAL 0000000b 0000000000000000
10 # CHECK-NEXT: 6 EXPORT 0000000e 0000000000000000
11 # CHECK-NEXT: 7 CODE 00000019 0000000000000000 TEXT
12 # CHECK-NEXT: 8 DATA 0000001a 0000000000000000 DATA
13 # CHECK-NEXT: 9 name 0000002b 0000000000000000
14 # CHECK-NEXT: 10 reloc.CODE 00000017 0000000000000000
15 # CHECK-NEXT: 11 linking 00000016 0000000000000000
1216
13 # RUN: llvm-objdump -p %p/Inputs/test.wasm | FileCheck %s -check-prefix CHECK-HEADER
17 # RUN: llvm-objdump -p %p/Inputs/trivial.obj.wasm | FileCheck %s -check-prefix CHECK-HEADER
1418
1519 # CHECK-HEADER: Program Header:
1620 # CHECK-HEADER: Version: 0x1
1721
18 # RUN: llvm-objdump -s --section=CODE %p/Inputs/test.wasm | FileCheck %s -check-prefix CHECK-SECTIONS
22 # RUN: llvm-objdump -s --section=CODE %p/Inputs/trivial.obj.wasm | FileCheck %s -check-prefix CHECK-SECTIONS
1923
2024 # CHECK-SECTIONS: Contents of section CODE:
21 # CHECK-SECTIONS: 0000 02070043 0000803f 0b200201 7d017c10 ...C...?. ..}.|.
22 # CHECK-SECTIONS: 0010 001a4100 10011a41 00410111 00001a20 ..A....A.A.....
23 # CHECK-SECTIONS: 0020 011a4300 00000021 020b ..C....!..
25 # CHECK-SECTIONS: 0000 01170041 80808080 00108080 8080001a ...A............
26 # CHECK-SECTIONS: 0010 10818080 80004100 0b ......A..
None ; llc -mtriple=i386-pc-win32 trivial.ll -filetype=obj -o trivial-object-test.coff-i386
1 ; llc -mtriple=x86_64-pc-win32 trivial.ll -filetype=obj -o trivial-object-test.coff-x86-64
2 ; llc -mtriple=i386-linux-gnu trivial.ll -filetype=obj -o trivial-object-test.elf-i386 -relocation-model=pic
3 ; llc -mtriple=x86_64-linux-gnu trivial.ll -filetype=obj -o trivial-object-test.elf-x86-64 -relocation-model=pic
4 ; llc -mtriple=i386-apple-darwin10 trivial.ll -filetype=obj -o trivial-object-test.macho-i386 -relocation-model=pic
5 ; llc -mtriple=x86_64-apple-darwin10 trivial.ll -filetype=obj -o trivial-object-test.macho-x86-64 -relocation-model=pic
0 ; Input used for generating checked-in binaries (trivial.obj.*)
1 ; llc -mtriple=i386-pc-win32 trivial.ll -filetype=obj -o trivial.obj.coff-i386
2 ; llc -mtriple=x86_64-pc-win32 trivial.ll -filetype=obj -o trivial.obj.coff-x86-64
3 ; llc -mtriple=i386-linux-gnu trivial.ll -filetype=obj -o trivial.obj.elf-i386 -relocation-model=pic
4 ; llc -mtriple=x86_64-linux-gnu trivial.ll -filetype=obj -o trivial.obj.elf-x86-64 -relocation-model=pic
5 ; llc -mtriple=i386-apple-darwin10 trivial.ll -filetype=obj -o trivial.obj.macho-i386 -relocation-model=pic
6 ; llc -mtriple=x86_64-apple-darwin10 trivial.ll -filetype=obj -o trivial.obj.macho-x86-64 -relocation-model=pic
7 ; llc -mtriple=wasm32-unknown-unknown-wasm trivial.ll -filetype=obj -o trivial.obj.wasm
68
79 @.str = private unnamed_addr constant [13 x i8] c"Hello World\0A\00", align 1
810
2727 RUN: | FileCheck %s -check-prefix COFF-IMPORTLIB
2828 RUN: llvm-readobj -h %p/Inputs/trivial.obj.elf-lanai \
2929 RUN: | FileCheck %s -check-prefix ELF-LANAI
30 # trivial.obj.wasm was generated using the following command:
31 # echo "extern int bar, baz; int foo() { return bar + baz + (int)&foo; }" | \
32 # ./bin/clang -c -o trivial.obj.wasm -target wasm32-unknown-unknown-wasm -x c -
3330 RUN: llvm-readobj -h %p/Inputs/trivial.obj.wasm \
3431 RUN: | FileCheck %s -check-prefix WASM
3532
288288 WASM: Relocations [
289289 WASM-NEXT: Section (8) CODE {
290290 WASM-NEXT: Relocation {
291 WASM-NEXT: Type: R_WEBASSEMBLY_TABLE_INDEX_SLEB (1)
292 WASM-NEXT: Offset: 0x6
293 WASM-NEXT: Index: 0x0
294 WASM-NEXT: }
295 WASM-NEXT: Relocation {
296 WASM-NEXT: Type: R_WEBASSEMBLY_GLOBAL_ADDR_LEB (3)
297 WASM-NEXT: Offset: 0x15
291 WASM-NEXT: Type: R_WEBASSEMBLY_GLOBAL_ADDR_SLEB (4)
292 WASM-NEXT: Offset: 0x4
298293 WASM-NEXT: Index: 0x0
299294 WASM-NEXT: Addend: 0
300295 WASM-NEXT: }
301296 WASM-NEXT: Relocation {
302 WASM-NEXT: Type: R_WEBASSEMBLY_GLOBAL_ADDR_LEB (3)
303 WASM-NEXT: Offset: 0x24
297 WASM-NEXT: Type: R_WEBASSEMBLY_FUNCTION_INDEX_LEB (0)
298 WASM-NEXT: Offset: 0xA
299 WASM-NEXT: Index: 0x0
300 WASM-NEXT: }
301 WASM-NEXT: Relocation {
302 WASM-NEXT: Type: R_WEBASSEMBLY_FUNCTION_INDEX_LEB (0)
303 WASM-NEXT: Offset: 0x11
304304 WASM-NEXT: Index: 0x1
305 WASM-NEXT: Addend: 0
306305 WASM-NEXT: }
307306 WASM-NEXT: }
308307 WASM-NEXT: ]
492492 MACHO-ARM-NEXT: }
493493 MACHO-ARM-NEXT:]
494494
495 WASM: Sections [
496 WASM-NEXT: Section {
497 WASM-NEXT: Type: TYPE (0x1)
498 WASM-NEXT: Size: 5
499 WASM-NEXT: Offset: 8
500 WASM-NEXT: }
501 WASM-NEXT: Section {
502 WASM-NEXT: Type: IMPORT (0x2)
503 WASM-NEXT: Size: 23
504 WASM-NEXT: Offset: 19
505 WASM-NEXT: }
506 WASM-NEXT: Section {
507 WASM-NEXT: Type: FUNCTION (0x3)
508 WASM-NEXT: Size: 2
509 WASM-NEXT: Offset: 48
510 WASM-NEXT: }
511 WASM-NEXT: Section {
512 WASM-NEXT: Type: TABLE (0x4)
513 WASM-NEXT: Size: 4
514 WASM-NEXT: Offset: 56
515 WASM-NEXT: }
516 WASM-NEXT: Section {
517 WASM-NEXT: Type: MEMORY (0x5)
518 WASM-NEXT: Size: 3
519 WASM-NEXT: Offset: 66
520 WASM-NEXT: Memories [
521 WASM-NEXT: Memory {
522 WASM-NEXT: InitialPages: 0
523 WASM-NEXT: }
524 WASM-NEXT: ]
525 WASM-NEXT: }
526 WASM-NEXT: Section {
527 WASM-NEXT: Type: EXPORT (0x7)
528 WASM-NEXT: Size: 7
529 WASM-NEXT: Offset: 75
530 WASM-NEXT: }
531 WASM-NEXT: Section {
532 WASM-NEXT: Type: ELEM (0x9)
533 WASM-NEXT: Size: 7
534 WASM-NEXT: Offset: 88
535 WASM-NEXT: }
536 WASM-NEXT: Section {
537 WASM-NEXT: Type: CODE (0xA)
538 WASM-NEXT: Size: 61
539 WASM-NEXT: Offset: 101
540 WASM-NEXT: }
541 WASM-NEXT: Section {
542 WASM-NEXT: Type: CUSTOM (0x0)
543 WASM-NEXT: Size: 17
544 WASM-NEXT: Offset: 168
545 WASM-NEXT: Name: name
546 WASM-NEXT: }
547 WASM-NEXT: Section {
548 WASM-NEXT: Type: CUSTOM (0x0)
549 WASM-NEXT: Size: 24
550 WASM-NEXT: Offset: 191
551 WASM-NEXT: Name: reloc.CODE
552 WASM-NEXT: }
553 WASM-NEXT:]
495 WASM: Sections [
496 WASM-NEXT: Section {
497 WASM-NEXT: Type: TYPE (0x1)
498 WASM-NEXT: Size: 14
499 WASM-NEXT: Offset: 8
500 WASM-NEXT: }
501 WASM-NEXT: Section {
502 WASM-NEXT: Type: IMPORT (0x2)
503 WASM-NEXT: Size: 36
504 WASM-NEXT: Offset: 28
505 WASM-NEXT: }
506 WASM-NEXT: Section {
507 WASM-NEXT: Type: FUNCTION (0x3)
508 WASM-NEXT: Size: 2
509 WASM-NEXT: Offset: 70
510 WASM-NEXT: }
511 WASM-NEXT: Section {
512 WASM-NEXT: Type: TABLE (0x4)
513 WASM-NEXT: Size: 4
514 WASM-NEXT: Offset: 78
515 WASM-NEXT: }
516 WASM-NEXT: Section {
517 WASM-NEXT: Type: MEMORY (0x5)
518 WASM-NEXT: Size: 3
519 WASM-NEXT: Offset: 88
520 WASM-NEXT: Memories [
521 WASM-NEXT: Memory {
522 WASM-NEXT: InitialPages: 1
523 WASM-NEXT: }
524 WASM-NEXT: ]
525 WASM-NEXT: }
526 WASM-NEXT: Section {
527 WASM-NEXT: Type: GLOBAL (0x6)
528 WASM-NEXT: Size: 6
529 WASM-NEXT: Offset: 97
530 WASM-NEXT: }
531 WASM-NEXT: Section {
532 WASM-NEXT: Type: EXPORT (0x7)
533 WASM-NEXT: Size: 8
534 WASM-NEXT: Offset: 109
535 WASM-NEXT: }
536 WASM-NEXT: Section {
537 WASM-NEXT: Type: CODE (0xA)
538 WASM-NEXT: Size: 25
539 WASM-NEXT: Offset: 123
540 WASM-NEXT: }
541 WASM-NEXT: Section {
542 WASM-NEXT: Type: DATA (0xB)
543 WASM-NEXT: Size: 19
544 WASM-NEXT: Offset: 154
545 WASM-NEXT: }
546 WASM-NEXT: Section {
547 WASM-NEXT: Type: CUSTOM (0x0)
548 WASM-NEXT: Size: 43
549 WASM-NEXT: Offset: 179
550 WASM-NEXT: Name: name
551 WASM-NEXT: }
552 WASM-NEXT: Section {
553 WASM-NEXT: Type: CUSTOM (0x0)
554 WASM-NEXT: Size: 23
555 WASM-NEXT: Offset: 228
556 WASM-NEXT: Name: reloc.CODE
557 WASM-NEXT: }
558 WASM-NEXT: Section {
559 WASM-NEXT: Type: CUSTOM (0x0)
560 WASM-NEXT: Size: 22
561 WASM-NEXT: Offset: 257
562 WASM-NEXT: Name: linking
563 WASM-NEXT: }
564 WASM-NEXT: ]
7272
7373 WASM: Symbols [
7474 WASM-NEXT: Symbol {
75 WASM-NEXT: Name: bar
76 WASM-NEXT: Type: GLOBAL_IMPORT (0x2)
75 WASM-NEXT: Name: puts
76 WASM-NEXT: Type: FUNCTION_IMPORT (0x0)
7777 WASM-NEXT: Flags: 0x0
7878 WASM-NEXT: }
7979 WASM-NEXT: Symbol {
80 WASM-NEXT: Name: baz
81 WASM-NEXT: Type: GLOBAL_IMPORT (0x2)
80 WASM-NEXT: Name: SomeOtherFunction
81 WASM-NEXT: Type: FUNCTION_IMPORT (0x0)
8282 WASM-NEXT: Flags: 0x0
8383 WASM-NEXT: }
8484 WASM-NEXT: Symbol {
85 WASM-NEXT: Name: foo
85 WASM-NEXT: Name: main
8686 WASM-NEXT: Type: FUNCTION_EXPORT (0x1)
8787 WASM-NEXT: Flags: 0x0
8888 WASM-NEXT: }
8989 WASM-NEXT: Symbol {
90 WASM-NEXT: Name: foo
90 WASM-NEXT: Name: puts
91 WASM-NEXT: Type: DEBUG_FUNCTION_NAME (0x4)
92 WASM-NEXT: Flags: 0x0
93 WASM-NEXT: }
94 WASM-NEXT: Symbol {
95 WASM-NEXT: Name: SomeOtherFunction
96 WASM-NEXT: Type: DEBUG_FUNCTION_NAME (0x4)
97 WASM-NEXT: Flags: 0x0
98 WASM-NEXT: }
99 WASM-NEXT: Symbol {
100 WASM-NEXT: Name: main
91101 WASM-NEXT: Type: DEBUG_FUNCTION_NAME (0x4)
92102 WASM-NEXT: Flags: 0x0
93103 WASM-NEXT: }