Index: llvm/trunk/test/Object/Inputs/trivial.ll =================================================================== --- llvm/trunk/test/Object/Inputs/trivial.ll +++ llvm/trunk/test/Object/Inputs/trivial.ll @@ -1,3 +1,6 @@ +; Input used for generating checked-in binaries (trivial-object-test.*) +; llc -mtriple=wasm32-unknown-unknown-wasm trivial.ll -filetype=obj -o trivial-object-test.wasm + @.str = private unnamed_addr constant [13 x i8] c"Hello World\0A\00", align 1 define i32 @main() nounwind { Index: llvm/trunk/test/Object/nm-trivial-object.test =================================================================== --- llvm/trunk/test/Object/nm-trivial-object.test +++ llvm/trunk/test/Object/nm-trivial-object.test @@ -2,6 +2,8 @@ RUN: | FileCheck %s -check-prefix COFF32 RUN: yaml2obj %p/Inputs/COFF/x86-64.yaml | llvm-nm -a -S - \ RUN: | FileCheck %s -check-prefix COFF64 +RUN: llvm-nm %p/Inputs/trivial-object-test.wasm \ +RUN: | FileCheck %s -check-prefix WASM RUN: llvm-nm %p/Inputs/trivial-object-test.elf-i386 \ RUN: | FileCheck %s -check-prefix ELF RUN: llvm-nm %p/Inputs/trivial-object-test.elf-i386 -S \ @@ -57,6 +59,11 @@ COFF32-NEXT: 00000000 T _main COFF32-NEXT: U _puts +WASM: U SomeOtherFunction +WASM-NEXT: 00000002 T main +WASM-NEXT: U puts +WASM-NEXT: 00000001 D var + COFF64: 00000000 d .data COFF64-NEXT: 00000000 t .text COFF64-NEXT: 00000000 r ??__Ex@@YAXXZ Index: llvm/trunk/test/Object/obj2yaml.test =================================================================== --- llvm/trunk/test/Object/obj2yaml.test +++ llvm/trunk/test/Object/obj2yaml.test @@ -4,8 +4,8 @@ RUN: obj2yaml %p/Inputs/trivial-object-test.elf-mips64el | FileCheck %s --check-prefix ELF-MIPS64EL RUN: obj2yaml %p/Inputs/trivial-object-test.elf-x86-64 | FileCheck %s --check-prefix ELF-X86-64 RUN: obj2yaml %p/Inputs/trivial-object-test.elf-avr | FileCheck %s --check-prefix ELF-AVR -RUN: obj2yaml %p/Inputs/unwind-section.elf-x86-64 \ -RUN: | FileCheck %s --check-prefix ELF-X86-64-UNWIND +RUN: obj2yaml %p/Inputs/trivial-object-test.wasm | FileCheck %s --check-prefix WASM +RUN: obj2yaml %p/Inputs/unwind-section.elf-x86-64 | FileCheck %s --check-prefix ELF-X86-64-UNWIND COFF-I386: header: COFF-I386-NEXT: Machine: IMAGE_FILE_MACHINE_I386 @@ -411,13 +411,13 @@ ELF-X86-64-NEXT: - Name: puts -ELF-AVR: FileHeader: +ELF-AVR: FileHeader: ELF-AVR-NEXT: Class: ELFCLASS32 ELF-AVR-NEXT: Data: ELFDATA2LSB ELF-AVR-NEXT: Type: ET_EXEC ELF-AVR-NEXT: Machine: EM_AVR ELF-AVR-NEXT: Flags: [ EF_AVR_ARCH_AVR2 ] -ELF-AVR-NEXT: Sections: +ELF-AVR-NEXT: Sections: ELF-AVR-NEXT: - Name: .text ELF-AVR-NEXT: Type: SHT_PROGBITS ELF-AVR-NEXT: Flags: [ SHF_ALLOC, SHF_EXECINSTR ] @@ -429,8 +429,8 @@ ELF-AVR-NEXT: Address: 0x0000000000800060 ELF-AVR-NEXT: AddressAlign: 0x0000000000000001 ELF-AVR-NEXT: Content: '' -ELF-AVR-NEXT: Symbols: -ELF-AVR-NEXT: Local: +ELF-AVR-NEXT: Symbols: +ELF-AVR-NEXT: Local: ELF-AVR-NEXT: - Type: STT_SECTION ELF-AVR-NEXT: Section: .text ELF-AVR-NEXT: - Type: STT_SECTION @@ -440,7 +440,7 @@ ELF-AVR-NEXT: Type: STT_FILE ELF-AVR-NEXT: - Name: main ELF-AVR-NEXT: Section: .text -ELF-AVR-NEXT: Global: +ELF-AVR-NEXT: Global: ELF-AVR-NEXT: - Name: __trampolines_start ELF-AVR-NEXT: Section: .text ELF-AVR-NEXT: - Name: _etext @@ -470,6 +470,17 @@ ELF-AVR-NEXT: Section: .data ELF-AVR-NEXT: Value: 0x0000000000800060 +WASM: --- !WASM +WASM-NEXT: FileHeader: +WASM-NEXT: Version: 0x00000001 +WASM: - Type: EXPORT +WASM-NEXT: Exports: +WASM-NEXT: - Name: main +WASM-NEXT: Kind: FUNCTION +WASM-NEXT: Index: 2 +WASM-NEXT: - Name: var +WASM-NEXT: Kind: GLOBAL +WASM-NEXT: Index: 1 ELF-X86-64-UNWIND: - Name: .eh_frame ELF-X86-64-UNWIND-NEXT: Type: SHT_X86_64_UNWIND Index: llvm/trunk/test/Object/objdump-relocations.test =================================================================== --- llvm/trunk/test/Object/objdump-relocations.test +++ llvm/trunk/test/Object/objdump-relocations.test @@ -12,6 +12,8 @@ RUN: | FileCheck %s -check-prefix ELF-MIPS64EL RUN: llvm-objdump -r %p/Inputs/trivial-object-test.elf-mipsel \ RUN: | FileCheck %s -check-prefix ELF-MIPSEL +RUN: llvm-objdump -r %p/Inputs/trivial-object-test.wasm \ +RUN: | FileCheck %s -check-prefix WASM RUN: llvm-objdump -r %p/Inputs/relocations.elf-x86-64 \ RUN: | FileCheck %s -check-prefix ELF-complex-x86-64 @@ -57,6 +59,11 @@ ELF-MIPSEL: R_MIPS_CALL16 puts ELF-MIPSEL: R_MIPS_CALL16 SomeOtherFunction +WASM: CODE +WASM-NEXT: R_WEBASSEMBLY_GLOBAL_ADDR_SLEB 0+0 +WASM-NEXT: R_WEBASSEMBLY_FUNCTION_INDEX_LEB 0+0 +WASM-NEXT: R_WEBASSEMBLY_FUNCTION_INDEX_LEB 1+0 + ELF-complex-x86-64: .text ELF-complex-x86-64-NEXT: R_X86_64_8 .data-4 ELF-complex-x86-64-NEXT: R_X86_64_16 .data-4 Index: llvm/trunk/test/tools/llvm-objdump/Inputs/trivial.ll =================================================================== --- llvm/trunk/test/tools/llvm-objdump/Inputs/trivial.ll +++ llvm/trunk/test/tools/llvm-objdump/Inputs/trivial.ll @@ -0,0 +1,19 @@ +; Input used for generating checked-in binaries (trivial.obj.*) +; llc -mtriple=wasm32-unknown-unknown-wasm trivial.ll -filetype=obj -o trivial.obj.wasm + +@.str = private unnamed_addr constant [13 x i8] c"Hello World\0A\00", align 1 + +define i32 @main() nounwind { +entry: + %call = tail call i32 @puts(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i32 0, i32 0)) nounwind + tail call void bitcast (void (...)* @SomeOtherFunction to void ()*)() nounwind + ret i32 0 +} + +declare i32 @puts(i8* nocapture) nounwind + +declare void @SomeOtherFunction(...) + +@var = global i32 0 +@llvm.used = appending global [1 x i8*] [i8* bitcast (i32* @var to i8*)], section "llvm.metadata" +@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* null, i8* null }] Index: llvm/trunk/test/tools/llvm-objdump/WebAssembly/symbol-table.test =================================================================== --- llvm/trunk/test/tools/llvm-objdump/WebAssembly/symbol-table.test +++ llvm/trunk/test/tools/llvm-objdump/WebAssembly/symbol-table.test @@ -1,8 +1,11 @@ -RUN: llvm-objdump -t %p/../Inputs/test.wasm | FileCheck %s +RUN: llvm-objdump -t %p/../Inputs/trivial.obj.wasm | FileCheck %s + +CHECK: SYMBOL TABLE: +CHECK-NEXT: 00000000 l F IMPORT puts +CHECK-NEXT: 00000000 l F IMPORT SomeOtherFunction +CHECK-NEXT: 00000002 g F EXPORT main +CHECK-NEXT: 00000001 g EXPORT var +CHECK-NEXT: 00000000 l F name puts +CHECK-NEXT: 00000001 l F name SomeOtherFunction +CHECK-NEXT: 00000002 l F name main -CHECK: SYMBOL TABLE: -CHECK: 00000000 l F IMPORT bar -CHECK: 00000000 g F EXPORT baz -CHECK: 00000001 g F EXPORT quux -CHECK: 00000000 l F name $import -CHECK: 00000001 l F name $func0 Index: llvm/trunk/test/tools/llvm-objdump/wasm.txt =================================================================== --- llvm/trunk/test/tools/llvm-objdump/wasm.txt +++ llvm/trunk/test/tools/llvm-objdump/wasm.txt @@ -1,24 +1,27 @@ -# RUN: llvm-objdump -h %p/Inputs/test.wasm | FileCheck %s +# RUN: llvm-objdump -h %p/Inputs/trivial.obj.wasm | FileCheck %s -# CHECK: Sections: -# CHECK: Idx Name Size Address Type -# CHECK: 0 TYPE 0000000f 0000000000000000 -# CHECK: 1 IMPORT 0000000b 0000000000000000 -# CHECK: 2 FUNCTION 00000003 0000000000000000 -# CHECK: 3 TABLE 00000005 0000000000000000 -# CHECK: 4 EXPORT 0000000e 0000000000000000 -# CHECK: 5 ELEM 00000007 0000000000000000 -# CHECK: 6 CODE 0000002a 0000000000000000 TEXT -# CHECK: 7 name 0000003c 0000000000000000 +# CHECK: Sections: +# CHECK-NEXT: Idx Name Size Address Type +# CHECK-NEXT: 0 TYPE 0000000e 0000000000000000 +# CHECK-NEXT: 1 IMPORT 00000024 0000000000000000 +# CHECK-NEXT: 2 FUNCTION 00000002 0000000000000000 +# CHECK-NEXT: 3 TABLE 00000004 0000000000000000 +# CHECK-NEXT: 4 MEMORY 00000003 0000000000000000 +# CHECK-NEXT: 5 GLOBAL 0000000b 0000000000000000 +# CHECK-NEXT: 6 EXPORT 0000000e 0000000000000000 +# CHECK-NEXT: 7 CODE 00000019 0000000000000000 TEXT +# CHECK-NEXT: 8 DATA 0000001a 0000000000000000 DATA +# CHECK-NEXT: 9 name 0000002b 0000000000000000 +# CHECK-NEXT: 10 reloc.CODE 00000017 0000000000000000 +# CHECK-NEXT: 11 linking 00000016 0000000000000000 -# RUN: llvm-objdump -p %p/Inputs/test.wasm | FileCheck %s -check-prefix CHECK-HEADER +# RUN: llvm-objdump -p %p/Inputs/trivial.obj.wasm | FileCheck %s -check-prefix CHECK-HEADER # CHECK-HEADER: Program Header: # CHECK-HEADER: Version: 0x1 -# RUN: llvm-objdump -s --section=CODE %p/Inputs/test.wasm | FileCheck %s -check-prefix CHECK-SECTIONS +# RUN: llvm-objdump -s --section=CODE %p/Inputs/trivial.obj.wasm | FileCheck %s -check-prefix CHECK-SECTIONS # CHECK-SECTIONS: Contents of section CODE: -# CHECK-SECTIONS: 0000 02070043 0000803f 0b200201 7d017c10 ...C...?. ..}.|. -# CHECK-SECTIONS: 0010 001a4100 10011a41 00410111 00001a20 ..A....A.A..... -# CHECK-SECTIONS: 0020 011a4300 00000021 020b ..C....!.. +# CHECK-SECTIONS: 0000 01170041 80808080 00108080 8080001a ...A............ +# CHECK-SECTIONS: 0010 10818080 80004100 0b ......A.. Index: llvm/trunk/test/tools/llvm-readobj/Inputs/trivial.ll =================================================================== --- llvm/trunk/test/tools/llvm-readobj/Inputs/trivial.ll +++ llvm/trunk/test/tools/llvm-readobj/Inputs/trivial.ll @@ -1,9 +1,11 @@ -; llc -mtriple=i386-pc-win32 trivial.ll -filetype=obj -o trivial-object-test.coff-i386 -; llc -mtriple=x86_64-pc-win32 trivial.ll -filetype=obj -o trivial-object-test.coff-x86-64 -; llc -mtriple=i386-linux-gnu trivial.ll -filetype=obj -o trivial-object-test.elf-i386 -relocation-model=pic -; llc -mtriple=x86_64-linux-gnu trivial.ll -filetype=obj -o trivial-object-test.elf-x86-64 -relocation-model=pic -; llc -mtriple=i386-apple-darwin10 trivial.ll -filetype=obj -o trivial-object-test.macho-i386 -relocation-model=pic -; llc -mtriple=x86_64-apple-darwin10 trivial.ll -filetype=obj -o trivial-object-test.macho-x86-64 -relocation-model=pic +; Input used for generating checked-in binaries (trivial.obj.*) +; llc -mtriple=i386-pc-win32 trivial.ll -filetype=obj -o trivial.obj.coff-i386 +; llc -mtriple=x86_64-pc-win32 trivial.ll -filetype=obj -o trivial.obj.coff-x86-64 +; llc -mtriple=i386-linux-gnu trivial.ll -filetype=obj -o trivial.obj.elf-i386 -relocation-model=pic +; llc -mtriple=x86_64-linux-gnu trivial.ll -filetype=obj -o trivial.obj.elf-x86-64 -relocation-model=pic +; llc -mtriple=i386-apple-darwin10 trivial.ll -filetype=obj -o trivial.obj.macho-i386 -relocation-model=pic +; llc -mtriple=x86_64-apple-darwin10 trivial.ll -filetype=obj -o trivial.obj.macho-x86-64 -relocation-model=pic +; llc -mtriple=wasm32-unknown-unknown-wasm trivial.ll -filetype=obj -o trivial.obj.wasm @.str = private unnamed_addr constant [13 x i8] c"Hello World\0A\00", align 1 Index: llvm/trunk/test/tools/llvm-readobj/file-headers.test =================================================================== --- llvm/trunk/test/tools/llvm-readobj/file-headers.test +++ llvm/trunk/test/tools/llvm-readobj/file-headers.test @@ -28,9 +28,6 @@ RUN: | FileCheck %s -check-prefix COFF-IMPORTLIB RUN: llvm-readobj -h %p/Inputs/trivial.obj.elf-lanai \ RUN: | FileCheck %s -check-prefix ELF-LANAI -# trivial.obj.wasm was generated using the following command: -# echo "extern int bar, baz; int foo() { return bar + baz + (int)&foo; }" | \ -# ./bin/clang -c -o trivial.obj.wasm -target wasm32-unknown-unknown-wasm -x c - RUN: llvm-readobj -h %p/Inputs/trivial.obj.wasm \ RUN: | FileCheck %s -check-prefix WASM Index: llvm/trunk/test/tools/llvm-readobj/relocations.test =================================================================== --- llvm/trunk/test/tools/llvm-readobj/relocations.test +++ llvm/trunk/test/tools/llvm-readobj/relocations.test @@ -289,21 +289,20 @@ WASM: Relocations [ WASM-NEXT: Section (8) CODE { WASM-NEXT: Relocation { -WASM-NEXT: Type: R_WEBASSEMBLY_TABLE_INDEX_SLEB (1) -WASM-NEXT: Offset: 0x6 +WASM-NEXT: Type: R_WEBASSEMBLY_GLOBAL_ADDR_SLEB (4) +WASM-NEXT: Offset: 0x4 WASM-NEXT: Index: 0x0 +WASM-NEXT: Addend: 0 WASM-NEXT: } WASM-NEXT: Relocation { -WASM-NEXT: Type: R_WEBASSEMBLY_GLOBAL_ADDR_LEB (3) -WASM-NEXT: Offset: 0x15 +WASM-NEXT: Type: R_WEBASSEMBLY_FUNCTION_INDEX_LEB (0) +WASM-NEXT: Offset: 0xA WASM-NEXT: Index: 0x0 -WASM-NEXT: Addend: 0 WASM-NEXT: } WASM-NEXT: Relocation { -WASM-NEXT: Type: R_WEBASSEMBLY_GLOBAL_ADDR_LEB (3) -WASM-NEXT: Offset: 0x24 +WASM-NEXT: Type: R_WEBASSEMBLY_FUNCTION_INDEX_LEB (0) +WASM-NEXT: Offset: 0x11 WASM-NEXT: Index: 0x1 -WASM-NEXT: Addend: 0 WASM-NEXT: } WASM-NEXT: } WASM-NEXT: ] Index: llvm/trunk/test/tools/llvm-readobj/sections.test =================================================================== --- llvm/trunk/test/tools/llvm-readobj/sections.test +++ llvm/trunk/test/tools/llvm-readobj/sections.test @@ -493,62 +493,73 @@ MACHO-ARM-NEXT: } MACHO-ARM-NEXT:] -WASM: Sections [ -WASM-NEXT: Section { -WASM-NEXT: Type: TYPE (0x1) -WASM-NEXT: Size: 5 -WASM-NEXT: Offset: 8 -WASM-NEXT: } -WASM-NEXT: Section { -WASM-NEXT: Type: IMPORT (0x2) -WASM-NEXT: Size: 23 -WASM-NEXT: Offset: 19 -WASM-NEXT: } -WASM-NEXT: Section { -WASM-NEXT: Type: FUNCTION (0x3) -WASM-NEXT: Size: 2 -WASM-NEXT: Offset: 48 -WASM-NEXT: } -WASM-NEXT: Section { -WASM-NEXT: Type: TABLE (0x4) -WASM-NEXT: Size: 4 -WASM-NEXT: Offset: 56 -WASM-NEXT: } -WASM-NEXT: Section { -WASM-NEXT: Type: MEMORY (0x5) -WASM-NEXT: Size: 3 -WASM-NEXT: Offset: 66 -WASM-NEXT: Memories [ -WASM-NEXT: Memory { -WASM-NEXT: InitialPages: 0 -WASM-NEXT: } -WASM-NEXT: ] -WASM-NEXT: } -WASM-NEXT: Section { -WASM-NEXT: Type: EXPORT (0x7) -WASM-NEXT: Size: 7 -WASM-NEXT: Offset: 75 -WASM-NEXT: } -WASM-NEXT: Section { -WASM-NEXT: Type: ELEM (0x9) -WASM-NEXT: Size: 7 -WASM-NEXT: Offset: 88 -WASM-NEXT: } -WASM-NEXT: Section { -WASM-NEXT: Type: CODE (0xA) -WASM-NEXT: Size: 61 -WASM-NEXT: Offset: 101 -WASM-NEXT: } -WASM-NEXT: Section { -WASM-NEXT: Type: CUSTOM (0x0) -WASM-NEXT: Size: 17 -WASM-NEXT: Offset: 168 -WASM-NEXT: Name: name -WASM-NEXT: } -WASM-NEXT: Section { -WASM-NEXT: Type: CUSTOM (0x0) -WASM-NEXT: Size: 24 -WASM-NEXT: Offset: 191 -WASM-NEXT: Name: reloc.CODE -WASM-NEXT: } -WASM-NEXT:] +WASM: Sections [ +WASM-NEXT: Section { +WASM-NEXT: Type: TYPE (0x1) +WASM-NEXT: Size: 14 +WASM-NEXT: Offset: 8 +WASM-NEXT: } +WASM-NEXT: Section { +WASM-NEXT: Type: IMPORT (0x2) +WASM-NEXT: Size: 36 +WASM-NEXT: Offset: 28 +WASM-NEXT: } +WASM-NEXT: Section { +WASM-NEXT: Type: FUNCTION (0x3) +WASM-NEXT: Size: 2 +WASM-NEXT: Offset: 70 +WASM-NEXT: } +WASM-NEXT: Section { +WASM-NEXT: Type: TABLE (0x4) +WASM-NEXT: Size: 4 +WASM-NEXT: Offset: 78 +WASM-NEXT: } +WASM-NEXT: Section { +WASM-NEXT: Type: MEMORY (0x5) +WASM-NEXT: Size: 3 +WASM-NEXT: Offset: 88 +WASM-NEXT: Memories [ +WASM-NEXT: Memory { +WASM-NEXT: InitialPages: 1 +WASM-NEXT: } +WASM-NEXT: ] +WASM-NEXT: } +WASM-NEXT: Section { +WASM-NEXT: Type: GLOBAL (0x6) +WASM-NEXT: Size: 6 +WASM-NEXT: Offset: 97 +WASM-NEXT: } +WASM-NEXT: Section { +WASM-NEXT: Type: EXPORT (0x7) +WASM-NEXT: Size: 8 +WASM-NEXT: Offset: 109 +WASM-NEXT: } +WASM-NEXT: Section { +WASM-NEXT: Type: CODE (0xA) +WASM-NEXT: Size: 25 +WASM-NEXT: Offset: 123 +WASM-NEXT: } +WASM-NEXT: Section { +WASM-NEXT: Type: DATA (0xB) +WASM-NEXT: Size: 19 +WASM-NEXT: Offset: 154 +WASM-NEXT: } +WASM-NEXT: Section { +WASM-NEXT: Type: CUSTOM (0x0) +WASM-NEXT: Size: 43 +WASM-NEXT: Offset: 179 +WASM-NEXT: Name: name +WASM-NEXT: } +WASM-NEXT: Section { +WASM-NEXT: Type: CUSTOM (0x0) +WASM-NEXT: Size: 23 +WASM-NEXT: Offset: 228 +WASM-NEXT: Name: reloc.CODE +WASM-NEXT: } +WASM-NEXT: Section { +WASM-NEXT: Type: CUSTOM (0x0) +WASM-NEXT: Size: 22 +WASM-NEXT: Offset: 257 +WASM-NEXT: Name: linking +WASM-NEXT: } +WASM-NEXT: ] Index: llvm/trunk/test/tools/llvm-readobj/symbols.test =================================================================== --- llvm/trunk/test/tools/llvm-readobj/symbols.test +++ llvm/trunk/test/tools/llvm-readobj/symbols.test @@ -73,22 +73,32 @@ WASM: Symbols [ WASM-NEXT: Symbol { -WASM-NEXT: Name: bar -WASM-NEXT: Type: GLOBAL_IMPORT (0x2) +WASM-NEXT: Name: puts +WASM-NEXT: Type: FUNCTION_IMPORT (0x0) WASM-NEXT: Flags: 0x0 WASM-NEXT: } WASM-NEXT: Symbol { -WASM-NEXT: Name: baz -WASM-NEXT: Type: GLOBAL_IMPORT (0x2) +WASM-NEXT: Name: SomeOtherFunction +WASM-NEXT: Type: FUNCTION_IMPORT (0x0) WASM-NEXT: Flags: 0x0 WASM-NEXT: } WASM-NEXT: Symbol { -WASM-NEXT: Name: foo +WASM-NEXT: Name: main WASM-NEXT: Type: FUNCTION_EXPORT (0x1) WASM-NEXT: Flags: 0x0 WASM-NEXT: } WASM-NEXT: Symbol { -WASM-NEXT: Name: foo +WASM-NEXT: Name: puts +WASM-NEXT: Type: DEBUG_FUNCTION_NAME (0x4) +WASM-NEXT: Flags: 0x0 +WASM-NEXT: } +WASM-NEXT: Symbol { +WASM-NEXT: Name: SomeOtherFunction +WASM-NEXT: Type: DEBUG_FUNCTION_NAME (0x4) +WASM-NEXT: Flags: 0x0 +WASM-NEXT: } +WASM-NEXT: Symbol { +WASM-NEXT: Name: main WASM-NEXT: Type: DEBUG_FUNCTION_NAME (0x4) WASM-NEXT: Flags: 0x0 WASM-NEXT: }