Index: test/Object/Inputs/ELF/BE32.yaml =================================================================== --- test/Object/Inputs/ELF/BE32.yaml +++ /dev/null @@ -1,6 +0,0 @@ -!ELF -FileHeader: !FileHeader - Class: ELFCLASS32 - Data: ELFDATA2MSB - Type: ET_EXEC - Machine: EM_PPC Index: test/Object/Inputs/ELF/BE64.yaml =================================================================== --- test/Object/Inputs/ELF/BE64.yaml +++ /dev/null @@ -1,6 +0,0 @@ -!ELF -FileHeader: !FileHeader - Class: ELFCLASS64 - Data: ELFDATA2MSB - Type: ET_EXEC - Machine: EM_PPC64 Index: test/Object/Inputs/ELF/LE32.yaml =================================================================== --- test/Object/Inputs/ELF/LE32.yaml +++ /dev/null @@ -1,6 +0,0 @@ -!ELF -FileHeader: !FileHeader - Class: ELFCLASS32 - Data: ELFDATA2LSB - Type: ET_EXEC - Machine: EM_386 Index: test/Object/Inputs/ELF/LE64.yaml =================================================================== --- test/Object/Inputs/ELF/LE64.yaml +++ /dev/null @@ -1,6 +0,0 @@ -!ELF -FileHeader: !FileHeader - Class: ELFCLASS64 - Data: ELFDATA2LSB - Type: ET_EXEC - Machine: EM_X86_64 Index: test/Object/yaml2obj-elf-alignment.yaml =================================================================== --- test/Object/yaml2obj-elf-alignment.yaml +++ /dev/null @@ -1,54 +0,0 @@ -# Check that yaml2obj takes in account section AddressAlign field. - -# RUN: yaml2obj %s > %t -# RUN: llvm-readobj -S %t | FileCheck %s - -# CHECK: Section { -# CHECK: Index: 2 -# CHECK-NEXT: Name: .data -# CHECK-NEXT: Type: SHT_PROGBITS -# CHECK-NEXT: Flags [ -# CHECK-NEXT: SHF_ALLOC -# CHECK-NEXT: SHF_WRITE -# CHECK-NEXT: ] -# CHECK-NEXT: Address: 0x0 -# CHECK-NEXT: Offset: 0x{{[0-9A-F]*}}00 -# CHECK-NEXT: Size: 4 -# CHECK-NEXT: Link: 0 -# CHECK-NEXT: Info: 0 -# CHECK-NEXT: AddressAlignment: 256 -# CHECK-NEXT: EntrySize: 0 -# CHECK-NEXT: } - ---- !ELF -FileHeader: - Class: ELFCLASS32 - Data: ELFDATA2LSB - Type: ET_REL - Machine: EM_MIPS - Flags: [ EF_MIPS_CPIC, EF_MIPS_ABI_O32, EF_MIPS_ARCH_32 ] - -Sections: - - Name: .text - Type: SHT_PROGBITS - Flags: [ SHF_ALLOC, SHF_EXECINSTR ] - AddressAlign: 8 - Size: 4 - - Name: .data - Type: SHT_PROGBITS - Flags: [ SHF_WRITE, SHF_ALLOC ] - AddressAlign: 256 - Size: 4 - -Symbols: - - Name: T0 - Type: STT_FUNC - Section: .text - Size: 4 - Binding: STB_GLOBAL - - Name: D0 - Type: STT_OBJECT - Section: .data - Size: 4 - Binding: STB_GLOBAL -... Index: test/Object/yaml2obj-elf-bits-endian.test =================================================================== --- test/Object/yaml2obj-elf-bits-endian.test +++ /dev/null @@ -1,16 +0,0 @@ -RUN: yaml2obj %p/Inputs/ELF/LE64.yaml | llvm-readobj --file-headers - | FileCheck %s --check-prefix LE64 -RUN: yaml2obj %p/Inputs/ELF/BE64.yaml | llvm-readobj --file-headers - | FileCheck %s --check-prefix BE64 -RUN: yaml2obj %p/Inputs/ELF/LE32.yaml | llvm-readobj --file-headers - | FileCheck %s --check-prefix LE32 -RUN: yaml2obj %p/Inputs/ELF/BE32.yaml | llvm-readobj --file-headers - | FileCheck %s --check-prefix BE32 - -LE64: Class: 64-bit (0x2) -LE64-NEXT: DataEncoding: LittleEndian (0x1) - -BE64: Class: 64-bit (0x2) -BE64-NEXT: DataEncoding: BigEndian (0x2) - -LE32: Class: 32-bit (0x1) -LE32-NEXT: DataEncoding: LittleEndian (0x1) - -BE32: Class: 32-bit (0x1) -BE32-NEXT: DataEncoding: BigEndian (0x2) Index: test/Object/yaml2obj-elf-file-headers.yaml =================================================================== --- test/Object/yaml2obj-elf-file-headers.yaml +++ /dev/null @@ -1,11 +0,0 @@ -# RUN: yaml2obj %s | llvm-readobj --file-headers - | FileCheck %s -!ELF -FileHeader: - Class: ELFCLASS64 - Data: ELFDATA2LSB - OSABI: ELFOSABI_GNU - Type: ET_REL - Machine: EM_X86_64 - -# CHECK: OS/ABI: GNU/Linux -# CHECK: Type: Relocatable Index: test/Object/yaml2obj-elf-multi-doc.test =================================================================== --- test/Object/yaml2obj-elf-multi-doc.test +++ /dev/null @@ -1,56 +0,0 @@ -# RUN: yaml2obj -docnum=1 %s \ -# RUN: | llvm-readobj --symbols - | FileCheck -check-prefix=DOC1 %s -# RUN: yaml2obj -docnum=2 %s \ -# RUN: | llvm-readobj --symbols - | FileCheck -check-prefix=DOC2 %s -# RUN: not yaml2obj -docnum=3 %s 2>&1 \ -# RUN: | FileCheck -check-prefix=DOC3 %s - -# DOC1: Name: T1 (1) -# DOC2: Name: T2 (1) -# DOC3: yaml2obj: Cannot find the 3rd document - ---- !ELF -FileHeader: !FileHeader - Class: ELFCLASS32 - Data: ELFDATA2LSB - Type: ET_REL - Machine: EM_MIPS - Flags: [EF_MIPS_CPIC] - -Sections: -- Name: .text - Type: SHT_PROGBITS - Content: "0000000000000000" - AddressAlign: 16 - Flags: [SHF_EXECINSTR, SHF_ALLOC] - -Symbols: -- Name: T1 - Section: .text - Type: STT_FUNC - Value: 0x0 - Size: 8 - Binding: STB_GLOBAL - ---- !ELF -FileHeader: !FileHeader - Class: ELFCLASS32 - Data: ELFDATA2LSB - Type: ET_REL - Machine: EM_MIPS - -Sections: -- Name: .text - Type: SHT_PROGBITS - Content: "00000000" - AddressAlign: 16 - Flags: [SHF_EXECINSTR, SHF_ALLOC] - -Symbols: -- Name: T2 - Section: .text - Type: STT_FUNC - Value: 0x0 - Size: 4 - Binding: STB_GLOBAL -... Index: test/Object/yaml2obj-elf-section-basic.yaml =================================================================== --- test/Object/yaml2obj-elf-section-basic.yaml +++ /dev/null @@ -1,79 +0,0 @@ -# RUN: yaml2obj %s | llvm-readobj --sections --section-data - | FileCheck %s -# RUN: yaml2obj -o %t %s -# RUN: llvm-readobj --sections --section-data %t | FileCheck %s - -!ELF -FileHeader: - Class: ELFCLASS64 - Data: ELFDATA2LSB - Type: ET_REL - Machine: EM_X86_64 -Sections: - - Name: .text - Type: SHT_PROGBITS - Flags: [ SHF_ALLOC, SHF_EXECINSTR ] - Address: 0xCAFEBABE - Link: .text # Doesn't make sense for SHT_PROGBITS, but good enough for test. - Content: EBFE - AddressAlign: 2 - - - Name: .data - Type: SHT_PROGBITS - Flags: [ SHF_ALLOC ] - Address: 0xCAFECAFE - Content: FEBF - Size: 8 - AddressAlign: 2 - -# CHECK: Section { -# CHECK: Index: 0 -# CHECK: Type: SHT_NULL (0x0) -# -# CHECK: Section { -# CHECK: Name: .text -# CHECK: Type: SHT_PROGBITS (0x1) -# CHECK-NEXT: Flags [ (0x6) -# CHECK-NEXT: SHF_ALLOC (0x2) -# CHECK-NEXT: SHF_EXECINSTR (0x4) -# CHECK-NEXT: ] -# CHECK-NEXT: Address: 0xCAFEBABE -# CHECK: Size: 2 -# Check that Link != 0. -# CHECK: Link: {{[1-9][0-9]*}} -# CHECK: AddressAlignment: 2 -# CHECK: SectionData ( -# CHECK-NEXT: 0000: EBFE -# CHECK-NEXT: ) -# -# CHECK: Section { -# CHECK: Name: .data -# CHECK-NEXT: Type: SHT_PROGBITS (0x1) -# CHECK-NEXT: Flags [ (0x2) -# CHECK-NEXT: SHF_ALLOC (0x2) -# CHECK-NEXT: ] -# CHECK-NEXT: Address: 0xCAFECAFE -# CHECK-NEXT: Offset: 0x{{[0-9A-F]+}} -# CHECK-NEXT: Size: 8 -# CHECK-NEXT: Link: 0 -# CHECK-NEXT: Info: 0 -# CHECK-NEXT: AddressAlignment: 2 -# CHECK-NEXT: EntrySize: 0 -# CHECK-NEXT: SectionData ( -# CHECK-NEXT: 0000: FEBF0000 00000000 |........| -# CHECK-NEXT: ) -# -# CHECK: Section { -# CHECK: Name: .symtab (25) -# CHECK: Type: SHT_SYMTAB (0x2) -# CHECK: AddressAlignment: 8 -# CHECK: } -# CHECK: Section { -# CHECK: Name: .strtab (17) -# CHECK: Type: SHT_STRTAB (0x3) -# CHECK: AddressAlignment: 1 -# CHECK: } -# CHECK: Section { -# CHECK: Name: .shstrtab (7) -# CHECK: Type: SHT_STRTAB (0x3) -# CHECK: AddressAlignment: 1 -# CHECK: } Index: test/Object/yaml2obj-elf-section-invalid-size.yaml =================================================================== --- test/Object/yaml2obj-elf-section-invalid-size.yaml +++ /dev/null @@ -1,26 +0,0 @@ -# RUN: not yaml2obj -o %t %s 2>&1 | FileCheck %s - -!ELF -FileHeader: - Class: ELFCLASS64 - Data: ELFDATA2LSB - Type: ET_REL - Machine: EM_X86_64 - -Sections: - - Name: .text - Type: SHT_PROGBITS - Flags: [ SHF_ALLOC, SHF_EXECINSTR ] - Content: EBFE - AddressAlign: 2 - - - Name: .data - Type: SHT_PROGBITS - Flags: [ SHF_ALLOC ] - Content: 0000000000000000 - Size: 2 - -# CHECK: YAML:17:5: error: Section size must be greater than or equal to the content size -# CHECK-NEXT: - Name: .data -# CHECK-NEXT: ^ -# CHECK-NEXT: yaml2obj: Failed to parse YAML file! Index: test/Object/yaml2obj-elf-symbol-basic.yaml =================================================================== --- test/Object/yaml2obj-elf-symbol-basic.yaml +++ /dev/null @@ -1,42 +0,0 @@ -# RUN: yaml2obj %s | llvm-readobj --symbols - | FileCheck %s -!ELF -FileHeader: - Class: ELFCLASS64 - Data: ELFDATA2LSB - Type: ET_REL - Machine: EM_X86_64 -Sections: - - Name: .text - Type: SHT_PROGBITS - Flags: [ SHF_ALLOC, SHF_EXECINSTR ] - AddressAlign: 0x4 - Content: "90EBFE" # x86 machine code - # NOP ; To make main's `Value` non-zero (for testing). - # main: - # JMP -2 ; (infloop) - # This YAML file is a valid relocatable object that, - # when linked and run on x86_64, will go into an - # infloop. -Symbols: - - Name: main - Type: STT_FUNC - Section: .text - Value: 0x1 - Size: 2 - Binding: STB_GLOBAL - - Name: undefined_symbol - Binding: STB_GLOBAL - -# CHECK: Symbols [ -# CHECK-NEXT: Symbol { -# CHECK-NEXT: Name: (0) -# CHECK: Symbol { -# CHECK-NEXT: Name: main -# CHECK-NEXT: Value: 0x1 -# CHECK-NEXT: Size: 2 -# CHECK: Binding: Global -# CHECK-NEXT: Type: Function -# CHECK: Section: .text -# CHECK: Symbol { -# CHECK: Name: undefined_symbol -# CHECK: Section: Undefined (0x0) Index: test/Object/yaml2obj-elf-symbol-visibility.yaml =================================================================== --- test/Object/yaml2obj-elf-symbol-visibility.yaml +++ /dev/null @@ -1,144 +0,0 @@ -# RUN: yaml2obj %s | llvm-readobj --symbols - | \ -# RUN: FileCheck --check-prefix OBJ %s -# RUN: yaml2obj %s | obj2yaml - | FileCheck --check-prefix YAML %s - -# OBJ: Symbol { -# OBJ: Name: default1 (36) -# OBJ-NEXT: Value: 0x0 -# OBJ-NEXT: Size: 4 -# OBJ-NEXT: Binding: Global (0x1) -# OBJ-NEXT: Type: Object (0x1) -# OBJ-NEXT: Other: 0 -# OBJ-NEXT: Section: .data (0x1) -# OBJ-NEXT: } -# OBJ-NEXT: Symbol { -# OBJ-NEXT: Name: default2 (27) -# OBJ-NEXT: Value: 0x4 -# OBJ-NEXT: Size: 4 -# OBJ-NEXT: Binding: Global (0x1) -# OBJ-NEXT: Type: Object (0x1) -# OBJ-NEXT: Other: 0 -# OBJ-NEXT: Section: .data (0x1) -# OBJ-NEXT: } -# OBJ-NEXT: Symbol { -# OBJ-NEXT: Name: internal (8) -# OBJ-NEXT: Value: 0x8 -# OBJ-NEXT: Size: 4 -# OBJ-NEXT: Binding: Global (0x1) -# OBJ-NEXT: Type: Object (0x1) -# OBJ-NEXT: Other [ (0x1) -# OBJ-NEXT: STV_INTERNAL -# OBJ-NEXT: ] -# OBJ-NEXT: Section: .data (0x1) -# OBJ-NEXT: } -# OBJ-NEXT: Symbol { -# OBJ-NEXT: Name: hidden (1) -# OBJ-NEXT: Value: 0xC -# OBJ-NEXT: Size: 4 -# OBJ-NEXT: Binding: Global (0x1) -# OBJ-NEXT: Type: Object (0x1) -# OBJ-NEXT: Other [ (0x2) -# OBJ-NEXT: STV_HIDDEN -# OBJ-NEXT: ] -# OBJ-NEXT: Section: .data (0x1) -# OBJ-NEXT: } -# OBJ-NEXT: Symbol { -# OBJ-NEXT: Name: protected (17) -# OBJ-NEXT: Value: 0x10 -# OBJ-NEXT: Size: 4 -# OBJ-NEXT: Binding: Global (0x1) -# OBJ-NEXT: Type: Object (0x1) -# OBJ-NEXT: Other [ (0xA3) -# OBJ-NEXT: STO_MIPS_MICROMIPS -# OBJ-NEXT: STO_MIPS_PIC -# OBJ-NEXT: STV_PROTECTED -# OBJ-NEXT: ] -# OBJ-NEXT: Section: .data (0x1) -# OBJ-NEXT: } - -# YAML: Symbols: -# YAML-NEXT: - Name: default1 -# YAML-NEXT: Type: STT_OBJECT -# YAML-NEXT: Section: .data -# YAML-NEXT: Binding: STB_GLOBAL -# YAML-NEXT: Size: 0x0000000000000004 -# YAML-NEXT: - Name: default2 -# YAML-NEXT: Type: STT_OBJECT -# YAML-NEXT: Section: .data -# YAML-NEXT: Binding: STB_GLOBAL -# YAML-NEXT: Value: 0x0000000000000004 -# YAML-NEXT: Size: 0x0000000000000004 -# YAML-NEXT: - Name: internal -# YAML-NEXT: Type: STT_OBJECT -# YAML-NEXT: Section: .data -# YAML-NEXT: Binding: STB_GLOBAL -# YAML-NEXT: Value: 0x0000000000000008 -# YAML-NEXT: Size: 0x0000000000000004 -# YAML-NEXT: Visibility: STV_INTERNAL -# YAML-NEXT: - Name: hidden -# YAML-NEXT: Type: STT_OBJECT -# YAML-NEXT: Section: .data -# YAML-NEXT: Binding: STB_GLOBAL -# YAML-NEXT: Value: 0x000000000000000C -# YAML-NEXT: Size: 0x0000000000000004 -# YAML-NEXT: Visibility: STV_HIDDEN -# YAML-NEXT: - Name: protected -# YAML-NEXT: Type: STT_OBJECT -# YAML-NEXT: Section: .data -# YAML-NEXT: Binding: STB_GLOBAL -# YAML-NEXT: Value: 0x0000000000000010 -# YAML-NEXT: Size: 0x0000000000000004 -# YAML-NEXT: Visibility: STV_PROTECTED -# YAML-NEXT: Other: [ STO_MIPS_PIC, STO_MIPS_MICROMIPS ] - ---- !ELF -FileHeader: - Class: ELFCLASS32 - Data: ELFDATA2LSB - Type: ET_REL - Machine: EM_MIPS - Flags: [ EF_MIPS_ABI_O32, EF_MIPS_ARCH_32 ] - -Sections: - - Name: .data - Type: SHT_PROGBITS - Flags: [ SHF_ALLOC, SHF_WRITE ] - AddressAlign: 0x04 - Size: 0x14 - -Symbols: - - Name: default1 - Type: STT_OBJECT - Visibility: STV_DEFAULT - Section: .data - Value: 0x00 - Size: 0x04 - Binding: STB_GLOBAL - - Name: default2 - Type: STT_OBJECT - Section: .data - Value: 0x04 - Size: 0x04 - Binding: STB_GLOBAL - - Name: internal - Type: STT_OBJECT - Visibility: STV_INTERNAL - Section: .data - Value: 0x08 - Size: 0x04 - Binding: STB_GLOBAL - - Name: hidden - Type: STT_OBJECT - Visibility: STV_HIDDEN - Section: .data - Value: 0x0C - Size: 0x04 - Binding: STB_GLOBAL - - Name: protected - Type: STT_OBJECT - Visibility: STV_PROTECTED - Other: [ STO_MIPS_MICROMIPS, STO_MIPS_PIC ] - Section: .data - Value: 0x10 - Size: 0x04 - Binding: STB_GLOBAL Index: test/Object/yaml2obj-readobj.test =================================================================== --- test/Object/yaml2obj-readobj.test +++ test/Object/yaml2obj-readobj.test @@ -1,31 +1,125 @@ -RUN: yaml2obj %p/Inputs/COFF/i386.yaml | llvm-readobj --file-headers -r --expand-relocs - | FileCheck %s --check-prefix COFF-I386 -RUN: yaml2obj -o %t %p/Inputs/COFF/i386.yaml -RUN: llvm-readobj --file-headers -r --expand-relocs %t \ -RUN: | FileCheck %s --check-prefix COFF-I386 - -// COFF-I386: Characteristics [ (0x200) -// COFF-I386-NEXT: IMAGE_FILE_DEBUG_STRIPPED (0x200) -// COFF-I386-NEXT: ] - -// COFF-I386: Relocations [ -// COFF-I386-NEXT: Section (1) .text { -// COFF-I386-NEXT: Relocation { -// COFF-I386-NEXT: Offset: 0xE -// COFF-I386-NEXT: Type: IMAGE_REL_I386_DIR32 (6) -// COFF-I386-NEXT: Symbol: L_.str -// COFF-I386-NEXT: SymbolIndex: 5 -// COFF-I386-NEXT: } -// COFF-I386-NEXT: Relocation { -// COFF-I386-NEXT: Offset: 0x13 -// COFF-I386-NEXT: Type: IMAGE_REL_I386_REL32 (20) -// COFF-I386-NEXT: Symbol: _puts -// COFF-I386-NEXT: SymbolIndex: 6 -// COFF-I386-NEXT: } -// COFF-I386-NEXT: Relocation { -// COFF-I386-NEXT: Offset: 0x18 -// COFF-I386-NEXT: Type: IMAGE_REL_I386_REL32 (20) -// COFF-I386-NEXT: Symbol: _SomeOtherFunction -// COFF-I386-NEXT: SymbolIndex: 7 -// COFF-I386-NEXT: } -// COFF-I386-NEXT: } -// COFF-I386-NEXT: ] +# RUN: yaml2obj %s | llvm-readobj --file-headers -r --expand-relocs - | FileCheck %s --check-prefix COFF-I386 +# RUN: yaml2obj -o %t %s +# RUN: llvm-readobj --file-headers -r --expand-relocs %t | FileCheck %s --check-prefix COFF-I386 + +# COFF-I386: Characteristics [ (0x200) +# COFF-I386-NEXT: IMAGE_FILE_DEBUG_STRIPPED (0x200) +# COFF-I386-NEXT: ] + +# COFF-I386: Relocations [ +# COFF-I386-NEXT: Section (1) .text { +# COFF-I386-NEXT: Relocation { +# COFF-I386-NEXT: Offset: 0xE +# COFF-I386-NEXT: Type: IMAGE_REL_I386_DIR32 (6) +# COFF-I386-NEXT: Symbol: L_.str +# COFF-I386-NEXT: SymbolIndex: 5 +# COFF-I386-NEXT: } +# COFF-I386-NEXT: Relocation { +# COFF-I386-NEXT: Offset: 0x13 +# COFF-I386-NEXT: Type: IMAGE_REL_I386_REL32 (20) +# COFF-I386-NEXT: Symbol: _puts +# COFF-I386-NEXT: SymbolIndex: 6 +# COFF-I386-NEXT: } +# COFF-I386-NEXT: Relocation { +# COFF-I386-NEXT: Offset: 0x18 +# COFF-I386-NEXT: Type: IMAGE_REL_I386_REL32 (20) +# COFF-I386-NEXT: Symbol: _SomeOtherFunction +# COFF-I386-NEXT: SymbolIndex: 7 +# COFF-I386-NEXT: } +# COFF-I386-NEXT: } +# COFF-I386-NEXT: ] + +!COFF +header: !Header + Machine: IMAGE_FILE_MACHINE_I386 # (0x14c) + Characteristics: [ IMAGE_FILE_DEBUG_STRIPPED ] + +sections: + - !Section + Name: .text + Alignment: 16 + Characteristics: [IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ, ] # 0x60500020 + SectionData: !hex "83EC0CC744240800000000C7042400000000E800000000E8000000008B44240883C40CC3" # |....D$.......$...............D$.....| + + Relocations: + - !Relocation + VirtualAddress: 0xe + SymbolName: L_.str + Type: IMAGE_REL_I386_DIR32 + + - !Relocation + VirtualAddress: 0x13 + SymbolName: _puts + Type: IMAGE_REL_I386_REL32 + + - !Relocation + VirtualAddress: 0x18 + SymbolName: _SomeOtherFunction + Type: IMAGE_REL_I386_REL32 + + - !Section + Name: .data + Alignment: 1 + Characteristics: [IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE, ] # 0xc0100040 + SectionData: !hex "48656C6C6F20576F726C642100" # |Hello World!.| + +symbols: + - !Symbol + Name: .text + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL # (0) + ComplexType: IMAGE_SYM_DTYPE_NULL # (0) + StorageClass: IMAGE_SYM_CLASS_STATIC # (3) + SectionDefinition: + Length: 36 + NumberOfRelocations: 3 + NumberOfLinenumbers: 0 + CheckSum: 0 + Number: 1 + + - !Symbol + Name: .data + Value: 0 + SectionNumber: 2 + SimpleType: IMAGE_SYM_TYPE_NULL # (0) + ComplexType: IMAGE_SYM_DTYPE_NULL # (0) + StorageClass: IMAGE_SYM_CLASS_STATIC # (3) + SectionDefinition: + Length: 13 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 0 + Number: 2 + + - !Symbol + Name: _main + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL # (0) + ComplexType: IMAGE_SYM_DTYPE_FUNCTION # (2) + StorageClass: IMAGE_SYM_CLASS_EXTERNAL # (2) + + - !Symbol + Name: L_.str + Value: 0 + SectionNumber: 2 + SimpleType: IMAGE_SYM_TYPE_NULL # (0) + ComplexType: IMAGE_SYM_DTYPE_NULL # (0) + StorageClass: IMAGE_SYM_CLASS_STATIC # (3) + + - !Symbol + Name: _puts + Value: 0 + SectionNumber: 0 + SimpleType: IMAGE_SYM_TYPE_NULL # (0) + ComplexType: IMAGE_SYM_DTYPE_NULL # (0) + StorageClass: IMAGE_SYM_CLASS_EXTERNAL # (2) + + - !Symbol + Name: _SomeOtherFunction + Value: 0 + SectionNumber: 0 + SimpleType: IMAGE_SYM_TYPE_NULL # (0) + ComplexType: IMAGE_SYM_DTYPE_NULL # (0) + StorageClass: IMAGE_SYM_CLASS_EXTERNAL # (2) Index: test/tools/obj2yaml/elf-symbol-visibility.yaml =================================================================== --- /dev/null +++ test/tools/obj2yaml/elf-symbol-visibility.yaml @@ -0,0 +1,35 @@ +## Check obj2yaml is able to dump the Visibility field correctly. + +# RUN: yaml2obj %s | obj2yaml - | FileCheck --check-prefix YAML %s + +# YAML: --- !ELF +# YAML-NEXT: FileHeader: +# YAML-NEXT: Class: ELFCLASS64 +# YAML-NEXT: Data: ELFDATA2LSB +# YAML-NEXT: Type: ET_REL +# YAML-NEXT: Machine: EM_X86_64 +# YAML-NEXT: Symbols: +# YAML-NEXT: - Name: default +# YAML-NEXT: - Name: internal +# YAML-NEXT: Visibility: STV_INTERNAL +# YAML-NEXT: - Name: hidden +# YAML-NEXT: Visibility: STV_HIDDEN +# YAML-NEXT: - Name: protected +# YAML-NEXT: Visibility: STV_PROTECTED +# YAML-NEXT: ... + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_X86_64 +Symbols: + - Name: default + Visibility: STV_DEFAULT + - Name: internal + Visibility: STV_INTERNAL + - Name: hidden + Visibility: STV_HIDDEN + - Name: protected + Visibility: STV_PROTECTED Index: test/tools/yaml2obj/coff-invalid-alignment.test =================================================================== --- test/tools/yaml2obj/coff-invalid-alignment.test +++ test/tools/yaml2obj/coff-invalid-alignment.test @@ -1,6 +1,6 @@ # RUN: not yaml2obj %s 2>&1 | FileCheck %s -# CHECK: Section alignment is too large +## CHECK: Section alignment is too large --- !COFF header: Index: test/tools/yaml2obj/elf-class-endianness.test =================================================================== --- /dev/null +++ test/tools/yaml2obj/elf-class-endianness.test @@ -0,0 +1,46 @@ +## Check we can produce 32/64 bits outputs with a different endianness. + +# RUN: yaml2obj %s --docnum=1 | llvm-readobj --file-headers - | FileCheck %s --check-prefix LE64 +# RUN: yaml2obj %s --docnum=2 | llvm-readobj --file-headers - | FileCheck %s --check-prefix BE64 +# RUN: yaml2obj %s --docnum=3 | llvm-readobj --file-headers - | FileCheck %s --check-prefix LE32 +# RUN: yaml2obj %s --docnum=4 | llvm-readobj --file-headers - | FileCheck %s --check-prefix BE32 + +# LE64: Class: 64-bit (0x2) +# LE64-NEXT: DataEncoding: LittleEndian (0x1) + +# BE64: Class: 64-bit (0x2) +# BE64-NEXT: DataEncoding: BigEndian (0x2) + +# LE32: Class: 32-bit (0x1) +# LE32-NEXT: DataEncoding: LittleEndian (0x1) + +# BE32: Class: 32-bit (0x1) +# BE32-NEXT: DataEncoding: BigEndian (0x2) + +--- !ELF +FileHeader: !FileHeader + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_X86_64 + +--- !ELF +FileHeader: !FileHeader + Class: ELFCLASS64 + Data: ELFDATA2MSB + Type: ET_EXEC + Machine: EM_PPC64 + +--- !ELF +FileHeader: !FileHeader + Class: ELFCLASS32 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_386 + +--- !ELF +FileHeader: !FileHeader + Class: ELFCLASS32 + Data: ELFDATA2MSB + Type: ET_EXEC + Machine: EM_PPC Index: test/tools/yaml2obj/elf-sh-addralign.yaml =================================================================== --- /dev/null +++ test/tools/yaml2obj/elf-sh-addralign.yaml @@ -0,0 +1,30 @@ +## Check that yaml2obj takes in account section AddressAlign field. + +# RUN: yaml2obj %s > %t +# RUN: llvm-readobj -S %t | FileCheck %s + +# CHECK: Section { +# CHECK: Index: +# CHECK: Name: .data +# CHECK-NEXT: Type: SHT_PROGBITS +# CHECK-NEXT: Flags [ +# CHECK-NEXT: ] +# CHECK-NEXT: Address: 0x0 +# CHECK-NEXT: Offset: 0x{{[0-9A-F]*}}00 +# CHECK-NEXT: Size: +# CHECK-NEXT: Link: +# CHECK-NEXT: Info: +# CHECK-NEXT: AddressAlignment: 256 +# CHECK-NEXT: EntrySize: +# CHECK-NEXT: } + +!ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_X86_64 +Sections: + - Name: .data + Type: SHT_PROGBITS + AddressAlign: 256 Index: test/tools/yaml2obj/elf-symbol-binding.yaml =================================================================== --- test/tools/yaml2obj/elf-symbol-binding.yaml +++ test/tools/yaml2obj/elf-symbol-binding.yaml @@ -1,26 +1,22 @@ +## Check we can set the different binding for symbols. + # RUN: yaml2obj %s | llvm-readobj --symbols - | FileCheck %s + !ELF FileHeader: - Class: ELFCLASS64 - Data: ELFDATA2LSB - Type: ET_REL + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_REL Machine: EM_X86_64 -Sections: - - Name: .data - Type: SHT_PROGBITS - Flags: [ SHF_ALLOC, SHF_WRITE ] - Content: "DEADBEEF" Symbols: - Name: local_symbol Type: STT_OBJECT - Section: .data + Binding: STB_LOCAL - Name: global_symbol Type: STT_OBJECT - Section: .data Binding: STB_GLOBAL - Name: weak_symbol Type: STT_OBJECT - Section: .data Binding: STB_WEAK # CHECK: Symbol { Index: test/tools/yaml2obj/elf-symbol-visibility.yaml =================================================================== --- /dev/null +++ test/tools/yaml2obj/elf-symbol-visibility.yaml @@ -0,0 +1,62 @@ +## Check yaml2obj is able to handle the Visibility field correctly. + +# RUN: yaml2obj %s | llvm-readobj --symbols - | FileCheck --check-prefix OBJ %s + +# OBJ: Symbol { +# OBJ: Name: default (1) +# OBJ-NEXT: Value: 0x0 +# OBJ-NEXT: Size: 0 +# OBJ-NEXT: Binding: Local (0x0) +# OBJ-NEXT: Type: None (0x0) +# OBJ-NEXT: Other: 0 +# OBJ-NEXT: Section: Undefined (0x0) +# OBJ-NEXT: } +# OBJ-NEXT: Symbol { +# OBJ-NEXT: Name: internal (16) +# OBJ-NEXT: Value: 0x0 +# OBJ-NEXT: Size: 0 +# OBJ-NEXT: Binding: Local (0x0) +# OBJ-NEXT: Type: None (0x0) +# OBJ-NEXT: Other [ (0x1) +# OBJ-NEXT: STV_INTERNAL (0x1) +# OBJ-NEXT: ] +# OBJ-NEXT: Section: Undefined (0x0) +# OBJ-NEXT: } +# OBJ-NEXT: Symbol { +# OBJ-NEXT: Name: hidden (9) +# OBJ-NEXT: Value: 0x0 +# OBJ-NEXT: Size: 0 +# OBJ-NEXT: Binding: Local (0x0) +# OBJ-NEXT: Type: None (0x0) +# OBJ-NEXT: Other [ (0x2) +# OBJ-NEXT: STV_HIDDEN (0x2) +# OBJ-NEXT: ] +# OBJ-NEXT: Section: Undefined (0x0) +# OBJ-NEXT: } +# OBJ-NEXT: Symbol { +# OBJ-NEXT: Name: protected (25) +# OBJ-NEXT: Value: 0x0 +# OBJ-NEXT: Size: 0 +# OBJ-NEXT: Binding: Local (0x0) +# OBJ-NEXT: Type: None (0x0) +# OBJ-NEXT: Other [ (0x3) +# OBJ-NEXT: STV_PROTECTED (0x3) +# OBJ-NEXT: ] +# OBJ-NEXT: Section: Undefined (0x0) +# OBJ-NEXT: } + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_X86_64 +Symbols: + - Name: default + Visibility: STV_DEFAULT + - Name: internal + Visibility: STV_INTERNAL + - Name: hidden + Visibility: STV_HIDDEN + - Name: protected + Visibility: STV_PROTECTED Index: test/tools/yaml2obj/invalid-yaml.yaml =================================================================== --- test/tools/yaml2obj/invalid-yaml.yaml +++ test/tools/yaml2obj/invalid-yaml.yaml @@ -1,4 +1,4 @@ -AAA: | BBB - # RUN: not yaml2obj %s 2>&1 | FileCheck %s # CHECK: Map value must not be empty + +AAA: | BBB Index: test/tools/yaml2obj/multi-doc.test =================================================================== --- test/tools/yaml2obj/multi-doc.test +++ test/tools/yaml2obj/multi-doc.test @@ -1,13 +1,41 @@ +## Check we are able to have multiple YAMLs in a file and switch between +## them using --docnum=x option. + # RUN: yaml2obj -docnum=1 %s \ # RUN: | llvm-readobj --symbols - | FileCheck -check-prefix=DOC1 %s # RUN: yaml2obj -docnum=2 %s \ # RUN: | llvm-readobj --symbols - | FileCheck -check-prefix=DOC2 %s -# RUN: not yaml2obj -docnum=3 %s 2>&1 \ -# RUN: | FileCheck -check-prefix=DOC3 %s +# RUN: yaml2obj -docnum=3 %s \ +# RUN: | llvm-readobj --symbols - | FileCheck -check-prefix=DOC3 %s +# RUN: yaml2obj -docnum=4 %s \ +# RUN: | llvm-readobj --symbols - | FileCheck -check-prefix=DOC4 %s +# RUN: not yaml2obj -docnum=5 %s 2>&1 \ +# RUN: | FileCheck -check-prefix=DOC5 %s # DOC1: Name: _sym1 # DOC2: Name: _sym2 -# DOC3: yaml2obj: Cannot find the 3rd document +# DOC3: Name: _sym3 +# DOC4: Name: _sym4 +# DOC5: yaml2obj: Cannot find the 5th document + +--- !ELF +FileHeader: !FileHeader + Class: ELFCLASS32 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_MIPS + Flags: [EF_MIPS_CPIC] +Symbols: +- Name: _sym1 + +--- !ELF +FileHeader: !FileHeader + Class: ELFCLASS32 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_386 +Symbols: +- Name: _sym2 --- !COFF header: @@ -20,7 +48,6 @@ Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] SectionData: "00000000" - symbols: - Name: .text Value: 0 @@ -34,15 +61,7 @@ NumberOfLinenumbers: 0 CheckSum: 0 Number: 1 - - - Name: _main - Value: 0 - SectionNumber: 1 - SimpleType: IMAGE_SYM_TYPE_NULL - ComplexType: IMAGE_SYM_DTYPE_FUNCTION - StorageClass: IMAGE_SYM_CLASS_EXTERNAL - - - Name: _sym1 + - Name: _sym3 Value: 0 SectionNumber: 0 SimpleType: IMAGE_SYM_TYPE_NULL @@ -60,7 +79,6 @@ Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] SectionData: "00000000" - symbols: - Name: .text Value: 0 @@ -74,18 +92,9 @@ NumberOfLinenumbers: 0 CheckSum: 0 Number: 1 - - - Name: _main - Value: 0 - SectionNumber: 1 - SimpleType: IMAGE_SYM_TYPE_NULL - ComplexType: IMAGE_SYM_DTYPE_FUNCTION - StorageClass: IMAGE_SYM_CLASS_EXTERNAL - - - Name: _sym2 + - Name: _sym4 Value: 0 SectionNumber: 0 SimpleType: IMAGE_SYM_TYPE_NULL ComplexType: IMAGE_SYM_DTYPE_NULL StorageClass: IMAGE_SYM_CLASS_EXTERNAL -... Index: test/tools/yaml2obj/section-size-content.yaml =================================================================== --- test/tools/yaml2obj/section-size-content.yaml +++ test/tools/yaml2obj/section-size-content.yaml @@ -156,3 +156,23 @@ Sections: - Name: .foo Type: SHT_PROGBITS + +# RUN: not yaml2obj --docnum=7 %s 2>&1 | FileCheck %s --check-prefix=ERR2 + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_X86_64 +Sections: + - Name: .data + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC ] + Content: 0000000000000000 + Size: 2 + +# ERR2: error: Section size must be greater than or equal to the content size +# ERR2-NEXT: - Name: .data +# ERR2-NEXT: ^ +# ERR2-NEXT: yaml2obj: Failed to parse YAML file!