diff options
| author | Adrian Prantl <aprantl@apple.com> | 2019-10-09 17:35:43 +0000 |
|---|---|---|
| committer | Adrian Prantl <aprantl@apple.com> | 2019-10-09 17:35:43 +0000 |
| commit | 0115c10328281567391855766fef8fbe57a1d4cc (patch) | |
| tree | f5c3232c37e50caaf5a2043e22fcebccee668bdd /lldb/lit/ObjectFile/ELF | |
| parent | 44e988ab14cb387eddfeacd1493792a6aa6aee81 (diff) | |
| download | bcm5719-llvm-0115c10328281567391855766fef8fbe57a1d4cc.tar.gz bcm5719-llvm-0115c10328281567391855766fef8fbe57a1d4cc.zip | |
Revert [test] Split LLDB tests into API, Shell & Unit
as it appears to have broken check-lldb.
This reverts r374184 (git commit 22314179f0660c172514b397060fd8f34b586e82)
llvm-svn: 374187
Diffstat (limited to 'lldb/lit/ObjectFile/ELF')
30 files changed, 1283 insertions, 0 deletions
diff --git a/lldb/lit/ObjectFile/ELF/Inputs/PT_LOAD-overlap-section.elf b/lldb/lit/ObjectFile/ELF/Inputs/PT_LOAD-overlap-section.elf Binary files differnew file mode 100644 index 00000000000..d5fd2d1fa91 --- /dev/null +++ b/lldb/lit/ObjectFile/ELF/Inputs/PT_LOAD-overlap-section.elf diff --git a/lldb/lit/ObjectFile/ELF/Inputs/minidebuginfo-main.c b/lldb/lit/ObjectFile/ELF/Inputs/minidebuginfo-main.c new file mode 100644 index 00000000000..8f11dafece6 --- /dev/null +++ b/lldb/lit/ObjectFile/ELF/Inputs/minidebuginfo-main.c @@ -0,0 +1,12 @@ +// This function will be embedded within the .symtab section of the +// .gnu_debugdata section. +int multiplyByFour(int num) { return num * 4; } + +// This function will be embedded within the .dynsym section of the main binary. +int multiplyByThree(int num) { return num * 3; } + +int main(int argc, char *argv[]) { + int x = multiplyByThree(argc); + int y = multiplyByFour(x); + return y; +} diff --git a/lldb/lit/ObjectFile/ELF/Inputs/netbsd-amd64.core b/lldb/lit/ObjectFile/ELF/Inputs/netbsd-amd64.core Binary files differnew file mode 100644 index 00000000000..bf647fdd792 --- /dev/null +++ b/lldb/lit/ObjectFile/ELF/Inputs/netbsd-amd64.core diff --git a/lldb/lit/ObjectFile/ELF/PT_LOAD-empty.yaml b/lldb/lit/ObjectFile/ELF/PT_LOAD-empty.yaml new file mode 100644 index 00000000000..9f1cb074572 --- /dev/null +++ b/lldb/lit/ObjectFile/ELF/PT_LOAD-empty.yaml @@ -0,0 +1,26 @@ +# Test behavior on unusual (and probably corrupt) files. Test that we drop an +# empty PT_LOAD segment. + +# RUN: yaml2obj %s > %t +# RUN: lldb-test object-file %t | FileCheck %s +# +# CHECK-NOT: container + +!ELF +FileHeader: + Class: ELFCLASS32 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_ARM +Sections: + - Name: .text + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Address: 0x1000 + AddressAlign: 0x4 + Content: DEADBEEFBAADF00D +ProgramHeaders: + - Type: PT_LOAD + Flags: [ PF_X, PF_R ] + VAddr: 0x1000 + Align: 0x4 diff --git a/lldb/lit/ObjectFile/ELF/PT_LOAD-overlap-PT_INTERP.yaml b/lldb/lit/ObjectFile/ELF/PT_LOAD-overlap-PT_INTERP.yaml new file mode 100644 index 00000000000..e97afe9070c --- /dev/null +++ b/lldb/lit/ObjectFile/ELF/PT_LOAD-overlap-PT_INTERP.yaml @@ -0,0 +1,50 @@ +# Test that an overlapping PT_INTERP segment does not cause us to drop the +# subsequent PT_LOAD segment. + +# RUN: yaml2obj %s > %t +# RUN: lldb-test object-file %t | FileCheck %s + +# CHECK: Index: 0 +# CHECK-NEXT: ID: 0xfffffffffffffffe +# CHECK-NEXT: Name: PT_LOAD[0] +# CHECK-NEXT: Type: container +# CHECK-NEXT: Permissions: rwx +# CHECK-NEXT: Thread specific: no +# CHECK-NEXT: VM address: 0x1000 +# CHECK-NEXT: VM size: 12 +# CHECK-NEXT: File size: 12 +# CHECK-NEXT: Showing 2 subsections + +!ELF +FileHeader: + Class: ELFCLASS32 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_ARM +Sections: + - Name: .interp + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC ] + Address: 0x1000 + AddressAlign: 0x4 + Content: 3232 + - Name: .text + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Address: 0x1004 + AddressAlign: 0x4 + Content: DEADBEEFBAADF00D +ProgramHeaders: + - Type: PT_INTERP + Flags: [ PF_R ] + VAddr: 0x1000 + Align: 0x4 + Sections: + - Section: .interp + - Type: PT_LOAD + Flags: [ PF_X, PF_W, PF_R ] + VAddr: 0x1000 + Align: 0x4 + Sections: + - Section: .interp + - Section: .text diff --git a/lldb/lit/ObjectFile/ELF/PT_LOAD-overlap-PT_TLS.yaml b/lldb/lit/ObjectFile/ELF/PT_LOAD-overlap-PT_TLS.yaml new file mode 100644 index 00000000000..d6844666804 --- /dev/null +++ b/lldb/lit/ObjectFile/ELF/PT_LOAD-overlap-PT_TLS.yaml @@ -0,0 +1,63 @@ +# Overlapping PT_LOAD and PT_TLS segments should be able to exist side by side. + +# RUN: yaml2obj %s > %t +# RUN: lldb-test object-file %t | FileCheck %s +# RUN: lldb %t -o "image lookup -a 0x1000" -b | FileCheck --check-prefix=LOOKUP %s + +# CHECK: Index: 0 +# CHECK-NEXT: ID: 0xffffffffffffffff +# CHECK-NEXT: Name: PT_TLS[0] +# CHECK-NEXT: Type: container +# CHECK-NEXT: Permissions: rw- +# CHECK-NEXT: Thread specific: yes +# CHECK-NEXT: VM address: 0x1000 +# CHECK-NEXT: VM size: 16 +# CHECK-NEXT: File size: 0 +# CHECK-NEXT: Showing 1 subsections + +# CHECK: Index: 1 +# CHECK-NEXT: ID: 0xfffffffffffffffe +# CHECK-NEXT: Name: PT_LOAD[0] +# CHECK-NEXT: Type: container +# CHECK-NEXT: Permissions: rw- +# CHECK-NEXT: Thread specific: no +# CHECK-NEXT: VM address: 0x1000 +# CHECK-NEXT: VM size: 16 +# CHECK-NEXT: File size: 16 +# CHECK-NEXT: Showing 1 subsections + +# LOOKUP-LABEL: image lookup -a 0x1000 +# LOOKUP: Address: {{.*}}.PT_LOAD[0]..data + 0) + +!ELF +FileHeader: + Class: ELFCLASS32 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_ARM +Sections: + - Name: .tbss + Type: SHT_NOBITS + Flags: [ SHF_ALLOC, SHF_WRITE, SHF_TLS ] + Address: 0x1000 + AddressAlign: 0x4 + Size: 0x10 + - Name: .data + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_WRITE ] + Address: 0x1000 + AddressAlign: 0x4 + Size: 0x10 +ProgramHeaders: + - Type: PT_TLS + Flags: [ PF_R, PF_W ] + VAddr: 0x1000 + Align: 0x4 + Sections: + - Section: .tbss + - Type: PT_LOAD + Flags: [ PF_W, PF_R ] + VAddr: 0x1000 + Align: 0x4 + Sections: + - Section: .data diff --git a/lldb/lit/ObjectFile/ELF/PT_LOAD-overlap-section.yaml b/lldb/lit/ObjectFile/ELF/PT_LOAD-overlap-section.yaml new file mode 100644 index 00000000000..3b7bde802ce --- /dev/null +++ b/lldb/lit/ObjectFile/ELF/PT_LOAD-overlap-section.yaml @@ -0,0 +1,66 @@ +# Test behavior on strange (invalid?) elf files where the sections cross segment +# boundary. The test input was generated from this yaml file, but the program +# header was modified by hand, so this input is here for reference only. +# +# Right now lldb shortens sections to make sure every section is fully contained +# within a segment, but other behaviors are possible too (including outright +# rejecting such files). + +# RUN: lldb-test object-file %S/Inputs/PT_LOAD-overlap-section.elf | FileCheck %s + +# CHECK: Index: 0 +# CHECK-NEXT: ID: 0xffffffffffffffff +# CHECK-NEXT: Name: PT_LOAD[0] +# CHECK-NEXT: Type: container +# CHECK-NEXT: Permissions: rwx +# CHECK-NEXT: Thread specific: no +# CHECK-NEXT: VM address: 0x1006 +# CHECK-NEXT: VM size: 8 +# CHECK-NEXT: File size: 8 +# CHECK-NEXT: Showing 1 subsections +# CHECK-NEXT: Index: 0 +# CHECK-NEXT: ID: 0x2 +# CHECK-NEXT: Name: .text +# CHECK-NEXT: Type: code +# CHECK-NEXT: Permissions: r-x +# CHECK-NEXT: Thread specific: no +# CHECK-NEXT: VM address: 0x1008 +# CHECK-NEXT: VM size: 6 +# CHECK-NEXT: File size: 8 + +# CHECK: Index: 1 +# CHECK-NEXT: ID: 0x1 +# CHECK-NEXT: Name: .interp +# CHECK-NEXT: Type: regular +# CHECK-NEXT: Permissions: r-- +# CHECK-NEXT: Thread specific: no +# CHECK-NEXT: VM address: 0x1000 +# CHECK-NEXT: VM size: 6 +# CHECK-NEXT: File size: 8 + +!ELF +FileHeader: + Class: ELFCLASS32 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_ARM +Sections: + - Name: .interp + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC ] + Address: 0x1000 + AddressAlign: 0x4 + Content: DEADBEEFBAADF00D + - Name: .text + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Address: 0x1008 + AddressAlign: 0x4 + Content: DEADBEEFBAADF00D +ProgramHeaders: + - Type: PT_LOAD + Flags: [ PF_X, PF_W, PF_R ] + VAddr: 0x1008 # Modified by hand to start at 0x1006 + Align: 0x4 + Sections: + - Section: .text diff --git a/lldb/lit/ObjectFile/ELF/PT_LOAD-overlap.yaml b/lldb/lit/ObjectFile/ELF/PT_LOAD-overlap.yaml new file mode 100644 index 00000000000..1315f54e6c0 --- /dev/null +++ b/lldb/lit/ObjectFile/ELF/PT_LOAD-overlap.yaml @@ -0,0 +1,42 @@ +# Test behavior on unusual (and probably corrupt) object files. Check that we +# drop the second PT_LOAD segment which overlaps with the first one. + +# RUN: yaml2obj %s > %t +# RUN: lldb-test object-file %t | FileCheck %s + +# CHECK: Type: container +# CHECK-NOT: Type: container + +!ELF +FileHeader: + Class: ELFCLASS32 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_ARM +Sections: + - Name: .text + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Address: 0x1000 + AddressAlign: 0x4 + Content: DEADBEEFBAADF00D + - Name: .data + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC ] + Address: 0x1008 + AddressAlign: 0x4 + Content: 3232 +ProgramHeaders: + - Type: PT_LOAD + Flags: [ PF_X, PF_W, PF_R ] + VAddr: 0x1000 + Align: 0x4 + Sections: + - Section: .text + - Section: .data + - Type: PT_LOAD + Flags: [ PF_R, PF_W ] + VAddr: 0x1008 + Align: 0x4 + Sections: + - Section: .data diff --git a/lldb/lit/ObjectFile/ELF/PT_LOAD.yaml b/lldb/lit/ObjectFile/ELF/PT_LOAD.yaml new file mode 100644 index 00000000000..d673a69c8cd --- /dev/null +++ b/lldb/lit/ObjectFile/ELF/PT_LOAD.yaml @@ -0,0 +1,79 @@ +# Test that sections are made child-sections of the PT_LOAD segments/sections. + +# RUN: yaml2obj %s > %t +# RUN: lldb-test object-file %t | FileCheck %s + +# CHECK: Index: 0 +# CHECK-NEXT: ID: 0xffffffffffffffff +# CHECK-NEXT: Name: PT_LOAD[0] +# CHECK-NEXT: Type: container +# CHECK-NEXT: Permissions: rwx +# CHECK-NEXT: Thread specific: no +# CHECK-NEXT: VM address: 0x1000 +# CHECK-NEXT: VM size: 10 +# CHECK-NEXT: File size: 10 +# CHECK-NEXT: Showing 2 subsections +# CHECK-NEXT: Index: 0 +# CHECK-NEXT: ID: 0x1 +# CHECK-NEXT: Name: .text +# CHECK-NEXT: Type: code +# CHECK-NEXT: Permissions: r-x +# CHECK-NEXT: Thread specific: no +# CHECK-NEXT: VM address: 0x1000 +# CHECK-NEXT: VM size: 8 +# CHECK-NEXT: File size: 8 +# CHECK-EMPTY: +# CHECK-NEXT: Index: 1 +# CHECK-NEXT: ID: 0x2 +# CHECK-NEXT: Name: .data +# CHECK-NEXT: Type: data +# CHECK-NEXT: Permissions: r-- +# CHECK-NEXT: Thread specific: no +# CHECK-NEXT: VM address: 0x1008 +# CHECK-NEXT: VM size: 2 +# CHECK-NEXT: File size: 2 +# CHECK-EMPTY: +# CHECK-EMPTY: +# CHECK-NEXT: Index: 1 +# CHECK-NEXT: ID: 0x3 +# CHECK-NEXT: Name: .data_outside +# CHECK-NEXT: Type: regular +# CHECK-NEXT: Permissions: r-- +# CHECK-NEXT: Thread specific: no +# CHECK-NEXT: VM address: 0x2000 +# CHECK-NEXT: VM size: 2 +# CHECK-NEXT: File size: 2 + +!ELF +FileHeader: + Class: ELFCLASS32 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_ARM +Sections: + - Name: .text + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Address: 0x1000 + AddressAlign: 0x4 + Content: DEADBEEFBAADF00D + - Name: .data + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC ] + Address: 0x1008 + AddressAlign: 0x4 + Content: 3232 + - Name: .data_outside + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC ] + Address: 0x2000 + AddressAlign: 0x4 + Content: 3232 +ProgramHeaders: + - Type: PT_LOAD + Flags: [ PF_X, PF_W, PF_R ] + VAddr: 0x1000 + Align: 0x4 + Sections: + - Section: .text + - Section: .data diff --git a/lldb/lit/ObjectFile/ELF/PT_TLS-overlap-PT_LOAD.yaml b/lldb/lit/ObjectFile/ELF/PT_TLS-overlap-PT_LOAD.yaml new file mode 100644 index 00000000000..cd3939e0541 --- /dev/null +++ b/lldb/lit/ObjectFile/ELF/PT_TLS-overlap-PT_LOAD.yaml @@ -0,0 +1,63 @@ +# Overlapping PT_LOAD and PT_TLS segments should be able to exist side by side. + +# RUN: yaml2obj %s > %t +# RUN: lldb-test object-file %t | FileCheck %s +# RUN: lldb %t -o "image lookup -a 0x1000" -b | FileCheck --check-prefix=LOOKUP %s + +# CHECK: Index: 0 +# CHECK-NEXT: ID: 0xffffffffffffffff +# CHECK-NEXT: Name: PT_LOAD[0] +# CHECK-NEXT: Type: container +# CHECK-NEXT: Permissions: rw- +# CHECK-NEXT: Thread specific: no +# CHECK-NEXT: VM address: 0x1000 +# CHECK-NEXT: VM size: 16 +# CHECK-NEXT: File size: 16 +# CHECK-NEXT: Showing 1 subsections + +# CHECK: Index: 1 +# CHECK-NEXT: ID: 0xfffffffffffffffe +# CHECK-NEXT: Name: PT_TLS[0] +# CHECK-NEXT: Type: container +# CHECK-NEXT: Permissions: rw- +# CHECK-NEXT: Thread specific: yes +# CHECK-NEXT: VM address: 0x1000 +# CHECK-NEXT: VM size: 16 +# CHECK-NEXT: File size: 0 +# CHECK-NEXT: Showing 1 subsections + +# LOOKUP-LABEL: image lookup -a 0x1000 +# LOOKUP: Address: {{.*}}.PT_LOAD[0]..data + 0) + +!ELF +FileHeader: + Class: ELFCLASS32 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_ARM +Sections: + - Name: .data + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_WRITE ] + Address: 0x1000 + AddressAlign: 0x4 + Size: 0x10 + - Name: .tbss + Type: SHT_NOBITS + Flags: [ SHF_ALLOC, SHF_WRITE, SHF_TLS ] + Address: 0x1000 + AddressAlign: 0x4 + Size: 0x10 +ProgramHeaders: + - Type: PT_LOAD + Flags: [ PF_W, PF_R ] + VAddr: 0x1000 + Align: 0x4 + Sections: + - Section: .data + - Type: PT_TLS + Flags: [ PF_R, PF_W ] + VAddr: 0x1000 + Align: 0x4 + Sections: + - Section: .tbss diff --git a/lldb/lit/ObjectFile/ELF/aarch64-relocations.yaml b/lldb/lit/ObjectFile/ELF/aarch64-relocations.yaml new file mode 100644 index 00000000000..b9433a0ef5a --- /dev/null +++ b/lldb/lit/ObjectFile/ELF/aarch64-relocations.yaml @@ -0,0 +1,93 @@ +# RUN: yaml2obj %s > %t +# RUN: lldb-test object-file -contents %t | FileCheck %s + +# CHECK: Name: .debug_info +# CHECK: Data: ( +# CHECK-NEXT: 0000: 47000000 04000000 00000801 00000000 0C002D00 00000000 00003700 00000000 +# CHECK-NEXT: 0020: 00000000 00000800 00000200 00000000 00000008 00000001 6F490000 00010243 +# CHECK-NEXT: 0040: 00000003 4B000000 050400 +# CHECK-NEXT: ) + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_AARCH64 +Sections: + - Name: .text + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + AddressAlign: 0x0000000000000004 + Content: E0031B32C0035FD6 + - Name: .debug_str + Type: SHT_PROGBITS + Flags: [ SHF_MERGE, SHF_STRINGS ] + AddressAlign: 0x0000000000000001 + Size: 0x50 + - Name: .debug_abbrev + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Size: 0x10 + - Name: .debug_info + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: 470000000400000000000801000000000C0000000000000000000000000000000000000000000800000002000000000000000008000000016F000000000102430000000300000000050400 + - Name: .rela.debug_info + Type: SHT_RELA + Link: .symtab + AddressAlign: 0x0000000000000008 + Info: .debug_info + Relocations: + - Offset: 0x0000000000000006 + Symbol: .debug_abbrev + Type: R_AARCH64_ABS32 + - Offset: 0x000000000000000C + Symbol: .debug_str + Type: R_AARCH64_ABS32 + - Offset: 0x0000000000000012 + Symbol: .debug_str + Type: R_AARCH64_ABS32 + Addend: 45 + - Offset: 0x0000000000000016 + Symbol: .debug_line + Type: R_AARCH64_ABS32 + - Offset: 0x000000000000001A + Symbol: .debug_str + Type: R_AARCH64_ABS32 + Addend: 55 + - Offset: 0x000000000000001E + Symbol: .text + Type: R_AARCH64_ABS64 + - Offset: 0x000000000000002B + Symbol: .text + Type: R_AARCH64_ABS64 + - Offset: 0x0000000000000039 + Symbol: .debug_str + Type: R_AARCH64_ABS32 + Addend: 73 + - Offset: 0x0000000000000044 + Symbol: .debug_str + Type: R_AARCH64_ABS32 + Addend: 75 + - Name: .debug_line + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Size: 0x20 +Symbols: + - Name: .text + Type: STT_SECTION + Section: .text + - Name: .debug_str + Type: STT_SECTION + Section: .debug_str + - Name: .debug_abbrev + Type: STT_SECTION + Section: .debug_abbrev + - Name: .debug_info + Type: STT_SECTION + Section: .debug_info + - Name: .debug_line + Type: STT_SECTION + Section: .debug_line +... diff --git a/lldb/lit/ObjectFile/ELF/base-address.yaml b/lldb/lit/ObjectFile/ELF/base-address.yaml new file mode 100644 index 00000000000..68f11770835 --- /dev/null +++ b/lldb/lit/ObjectFile/ELF/base-address.yaml @@ -0,0 +1,34 @@ +# RUN: yaml2obj %s > %t +# RUN: lldb-test object-file %t | FileCheck %s + +# CHECK: Base VM address: 0x400000 + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_X86_64 + Entry: 0x0000000000400078 +Sections: + - Name: .pad + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC ] + Address: 0x0000000000400000 + AddressAlign: 0x0000000000001000 + Size: 0x78 + - Name: .text + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Address: 0x0000000000400078 + AddressAlign: 0x0000000000000001 + Content: 48C7C0E700000048C7C72F0000000F05CC +ProgramHeaders: + - Type: PT_LOAD + Flags: [ PF_X, PF_R ] + VAddr: 0x400000 + Align: 0x200000 + Sections: + - Section: .pad + - Section: .text +... diff --git a/lldb/lit/ObjectFile/ELF/basic-info.yaml b/lldb/lit/ObjectFile/ELF/basic-info.yaml new file mode 100644 index 00000000000..0e1db67e9d5 --- /dev/null +++ b/lldb/lit/ObjectFile/ELF/basic-info.yaml @@ -0,0 +1,27 @@ +# REQUIRES: lld + +# RUN: yaml2obj %s > %t.o +# RUN: ld.lld %t.o -o %t -image-base 0x47000 +# RUN: lldb-test object-file %t | FileCheck %s + +# CHECK: Plugin name: elf +# CHECK: Architecture: x86_64-- +# CHECK: Executable: true +# CHECK: Stripped: false +# CHECK: Type: executable +# CHECK: Strata: user +# CHECK: Base VM address: 0x47000 + +--- !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: 0x0000000000000010 + Content: 554889E55DC3 +... diff --git a/lldb/lit/ObjectFile/ELF/build-id-case.yaml b/lldb/lit/ObjectFile/ELF/build-id-case.yaml new file mode 100644 index 00000000000..f9786b3754f --- /dev/null +++ b/lldb/lit/ObjectFile/ELF/build-id-case.yaml @@ -0,0 +1,40 @@ +# RUN: mkdir -p %t/.build-id/1b +# RUN: yaml2obj %s > %t/.build-id/1b/8a73ac238390e32a7ff4ac8ebe4d6a41ecf5c9.debug +# RUN: cd %t +# RUN: llvm-objcopy --strip-all %t/.build-id/1b/8a73ac238390e32a7ff4ac8ebe4d6a41ecf5c9.debug %t/stripped.out +# RUN: lldb-test object-file %t/stripped.out | FileCheck %s + +# CHECK: Name: .debug_frame +# CHECK-NEXT: Type: dwarf-frame + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_X86_64 + Entry: 0x00000000004003D0 +Sections: + - Name: .note.gnu.build-id + Type: SHT_NOTE + Flags: [ SHF_ALLOC ] + Address: 0x0000000000400274 + AddressAlign: 0x0000000000000004 + Content: 040000001400000003000000474E55001B8A73AC238390E32A7FF4AC8EBE4D6A41ECF5C9 + - Name: .text + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Address: 0x00000000004003D0 + AddressAlign: 0x0000000000000010 + Content: DEADBEEFBAADF00D + - Name: .debug_frame + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000008 + Content: DEADBEEFBAADF00D +Symbols: + - Name: main + Type: STT_FUNC + Section: .text + Value: 0x00000000004003D0 + Size: 0x0000000000000008 +... diff --git a/lldb/lit/ObjectFile/ELF/compressed-sections.yaml b/lldb/lit/ObjectFile/ELF/compressed-sections.yaml new file mode 100644 index 00000000000..f8c31d52bb8 --- /dev/null +++ b/lldb/lit/ObjectFile/ELF/compressed-sections.yaml @@ -0,0 +1,44 @@ +# REQUIRES: zlib +# RUN: yaml2obj %s > %t +# RUN: lldb-test object-file --contents %t | FileCheck %s +--- !ELF +FileHeader: + Class: ELFCLASS32 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_386 +Sections: + - Name: .hello_elf + Type: SHT_PROGBITS + Flags: [ SHF_COMPRESSED ] + Content: 010000000800000001000000789c5330700848286898000009c802c1 + - Name: .bogus + Type: SHT_PROGBITS + Flags: [ SHF_COMPRESSED ] + Content: deadbeefbaadf00d + - Name: .zdebug_info + Type: SHT_PROGBITS + Content: 5A4C49420000000000000008789c5330700848286898000009c802c1 + +# CHECK: Name: .hello_elf +# CHECK-NEXT: Type: regular +# CHECK: VM address: 0 +# CHECK-NEXT: VM size: 0 +# CHECK-NEXT: File size: 28 +# CHECK-NEXT: Data: ( +# CHECK-NEXT: 20304050 60708090 +# CHECK-NEXT: ) + +# CHECK: Name: .bogus +# CHECK-NEXT: Type: regular +# CHECK: VM address: 0 +# CHECK-NEXT: VM size: 0 +# CHECK-NEXT: File size: 8 +# CHECK-NEXT: Data: () + +# CHECK: Name: .zdebug_info +# CHECK: dwarf-info +# CHECK: File size: 28 +# CHECK: Data: ( +# CHECK-NEXT: 20304050 60708090 +# CHECK-NEXT: ) diff --git a/lldb/lit/ObjectFile/ELF/duplicate-section.yaml b/lldb/lit/ObjectFile/ELF/duplicate-section.yaml new file mode 100644 index 00000000000..8b280d2449b --- /dev/null +++ b/lldb/lit/ObjectFile/ELF/duplicate-section.yaml @@ -0,0 +1,41 @@ +# RUN: mkdir -p %t/.build-id/1b +# RUN: yaml2obj %s > %t/.build-id/1b/8a73ac238390e32a7ff4ac8ebe4d6a41ecf5c9.debug +# RUN: cd %t +# RUN: llvm-objcopy --strip-all --add-gnu-debuglink=.build-id/1b/8a73ac238390e32a7ff4ac8ebe4d6a41ecf5c9.debug %t/.build-id/1b/8a73ac238390e32a7ff4ac8ebe4d6a41ecf5c9.debug %t/stripped.out +# RUN: lldb-test object-file %t/stripped.out | FileCheck %s + +# Make sure that the debug_frame section is present only once. +# CHECK: Name: .debug_frame +# CHECK-NOT: .debug_frame + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_X86_64 + Entry: 0x00000000004003D0 +Sections: + - Name: .note.gnu.build-id + Type: SHT_NOTE + Flags: [ SHF_ALLOC ] + Address: 0x0000000000400274 + AddressAlign: 0x0000000000000004 + Content: 040000001400000003000000474E55001B8A73AC238390E32A7FF4AC8EBE4D6A41ECF5C9 + - Name: .text + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Address: 0x00000000004003D0 + AddressAlign: 0x0000000000000010 + Content: DEADBEEFBAADF00D + - Name: .debug_frame + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000008 + Content: DEADBEEFBAADF00D +Symbols: + - Name: main + Type: STT_FUNC + Section: .text + Value: 0x00000000004003D0 + Size: 0x0000000000000008 +... diff --git a/lldb/lit/ObjectFile/ELF/gnu-debuglink.yaml b/lldb/lit/ObjectFile/ELF/gnu-debuglink.yaml new file mode 100644 index 00000000000..b39b3187ae9 --- /dev/null +++ b/lldb/lit/ObjectFile/ELF/gnu-debuglink.yaml @@ -0,0 +1,32 @@ +# RUN: yaml2obj %s > %t +# RUN: llvm-objcopy --strip-all --add-gnu-debuglink=%t %t %t.stripped +# RUN: lldb-test object-file %t.stripped | FileCheck %s + +# CHECK: Name: .debug_frame +# CHECK-NEXT: Type: dwarf-frame + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_X86_64 + Entry: 0x00000000004003D0 +Sections: + - Name: .text + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Address: 0x00000000004003D0 + AddressAlign: 0x0000000000000010 + Content: DEADBEEFBAADF00D + - Name: .debug_frame + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000008 + Content: DEADBEEFBAADF00D +Symbols: + - Name: main + Type: STT_FUNC + Section: .text + Value: 0x00000000004003D0 + Size: 0x0000000000000008 +... diff --git a/lldb/lit/ObjectFile/ELF/many-sections.s b/lldb/lit/ObjectFile/ELF/many-sections.s new file mode 100644 index 00000000000..15d7e8fc158 --- /dev/null +++ b/lldb/lit/ObjectFile/ELF/many-sections.s @@ -0,0 +1,72 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux %s -o %t +# RUN: lldb-test object-file %t | FileCheck %s + +## Check that we are able to parse ELF files with more than SHN_LORESERVE +## sections. This generates a file that contains 64k sections from +## aaaaaaaa..dddddddd, plus a couple of standard ones (.strtab, etc.) +## Check the number is correct plus the names of a couple of chosen sections. + +# CHECK: Showing 65540 sections +# CHECK: Name: aaaaaaaa +# CHECK: Name: bbbbbbbb +# CHECK: Name: cccccccc +# CHECK: Name: abcdabcd +# CHECK: Name: dddddddd + +.macro gen_sections4 x + .section a\x + .section b\x + .section c\x + .section d\x +.endm + +.macro gen_sections16 x + gen_sections4 a\x + gen_sections4 b\x + gen_sections4 c\x + gen_sections4 d\x +.endm + +.macro gen_sections64 x + gen_sections16 a\x + gen_sections16 b\x + gen_sections16 c\x + gen_sections16 d\x +.endm + +.macro gen_sections256 x + gen_sections64 a\x + gen_sections64 b\x + gen_sections64 c\x + gen_sections64 d\x +.endm + +.macro gen_sections1024 x + gen_sections256 a\x + gen_sections256 b\x + gen_sections256 c\x + gen_sections256 d\x +.endm + +.macro gen_sections4096 x + gen_sections1024 a\x + gen_sections1024 b\x + gen_sections1024 c\x + gen_sections1024 d\x +.endm + +.macro gen_sections16384 x + gen_sections4096 a\x + gen_sections4096 b\x + gen_sections4096 c\x + gen_sections4096 d\x +.endm + +gen_sections16384 a +gen_sections16384 b +gen_sections16384 c +gen_sections16384 d + +.global _start +_start: diff --git a/lldb/lit/ObjectFile/ELF/minidebuginfo-corrupt-xz.yaml b/lldb/lit/ObjectFile/ELF/minidebuginfo-corrupt-xz.yaml new file mode 100644 index 00000000000..cec34b9c623 --- /dev/null +++ b/lldb/lit/ObjectFile/ELF/minidebuginfo-corrupt-xz.yaml @@ -0,0 +1,29 @@ +# REQUIRES: lzma + +# This test checks that an error occurs when a corrupted +# .gnu_debugdata section is trying to be xz uncompressed. + +# RUN: yaml2obj %s > %t.obj + +# TODO(kwk): once yaml2obj doesn't auto-generate a .symtab section +# when there's none in YAML, remove the following line: + +# RUN: llvm-objcopy --remove-section=.symtab %t.obj + +# RUN: %lldb -b -o 'image dump symtab' %t.obj 2>&1 | FileCheck %s + +# CHECK: warning: (x86_64) {{.*}}.obj An error occurred while decompression the section .gnu_debugdata: lzma_stream_buffer_decode()=lzma error: LZMA_DATA_ERROR + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_X86_64 + Entry: 0x00000000004004C0 +Sections: + - Name: .gnu_debugdata + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: FD377A585A000004E6D6B4460200210116000000742FE5A3E0180F05BA5D003F914584683D89A6DA8ACC93E24ED90802EC1FE2A7102958F4A42B6A7134F23922F6F35F529E133A8B5588025CFAC876C68510A157DBBCF8CA75E9854DED10FDD5CE0CDC136F6459B13B9847AEF79E9B1C7CD70EF4F3AF709F5DA0C1F40780154D72120A6A62A3F1A216E20DC597CE55BB23B48785957321A15FEE48808C1428B925DBC8022541CC594BD0AF2B51C6BE2854C81611017704DF6E509D21013B80BEC27D8919ACD3157E89353A08F4C86781ED708E89AB322D010F0F1605DAD9B9CE2B13C387769C83F5F85C647FD9C551E0E9C7D4A5CBE297970E486CB94AC283F98A7C6412A57F9C37952327549EEC4634D2CFA55B0F99923A14992D4293E0D87CEEF7FB6160C45928DE25074EEBF5329B5579AF01DB23DF22CBD48C8037B68FFFBE5CEA6CD26A936DD07D9B2E6006B7C6E5CC751072185EFE995D3F3C8DACF9039D4BEFB1F376B491568F6F00DB50FF477F36B90413E4FA30AE7C561A1249FD45FDFF884F70247FC21E57195A764151D8E341267E724D856C512BD243CDB33AB313758443877B2CB58F7F8F0461DE9766647F333A3531BDC4A26E9537EB314708D31212FCF4C21E9CB139F4DBFD21BB16A126C35E2BB3F7E30BF5A54961CECD4DD4D91A3757356F618754B21533C34F2BD97D70A02B1F338588BDBA9CDF5FC9FBE973E550194F07EC7A1E8E3C005FD60F8853223427628987E82E701CA7E2FDFA1B0ED564C37D115A72C3EC01E29C85C3630D8A385C4AE12F4F75F9F0BC12F2698345DD62A1F546A5953AF5CF3C0F22C7DA510F6739EB8CDB0E8A5A3BC13CFC31C1875C313908EFF23678869B76A6E1C10FE699E43BFFDE8F0752ED994A4A84BC0AD9D7381131D457C4917C4F6656F5C95D3221A79166C802D5F5A7C68554E54C42CA535465D224C7B641CF3417C3EAFD03CE5709BEA33DC7C9155CAC9D3C8033AF7CDA622020606A7C139D77FF85BC19323BF956C9C4662F60079BC7FE5F67B46211716A1A6CE4AB8AAB307D6444310CBC101071703EECC0B4622D91D705F5DA2932DA8BCEDA8E1CB0CDB20AAD652B8F86A521D3421287F1C175AE3BE6458AE6F8F3FB6FB7ED97B616B580D791E5FE0B74973F8604F419039B5B9D9A14397EE509F2B33AE404FF96DD0551472C5302E67910F0794B15CFE837351C6AF89B2FE88488B557BE8ACFFA331FB7AD553D35CAEB7D8BCEFB6CFF4A58E91355FE931408CF4CAFA9B97518B9E5C02078F64CE81279801B090348213DCAA7D12DC098BFF58C5A3202EFC38F64AD894379747B54AB5A9843F82E5FF1F394C8B78344A8F1655DDEF8D5FE09EBB3E703853ABD716743507000696FB6B35216B088E499F53880375521442ED45DCDD1B31AAEBDAD3C7DA958593425206C4B2A0BC6CADE3B0B1598499E08016E84F33E3EB9D7B03B9C9DFA91B8CE5C74DEF2BC97FEE9982B0AEC16C75EEB7AE9A858A9C37F6C12B040C68A49111DCF0F3A4780F3879E93D904676BE908FDC66373D34AA715A39EFBC2795C6C8F058CA24392FB2591AD06ACD6AED8746F926886180C2B007ED58C9884A8BEF6CCA1F549F5C4FB411A3FF78770D1147363AC80B98B5A8FDB3DEC4E61709F66A622BDA835B1FD67B7C7CB166ABB163FB7C5204AE200C71C6A18B532C407647323B8F2FAC7ECB68C250877FC8DD5FE05B2B39E66F687EBB6EEFB7D5209E22F451B76F57D90BB6641DFFDE1A1821C4D783E4756F3CEE7F63B9BA284F8E114B0D9A086D83233BED4A8F5B60933DC16AF4DDE19C9FC59BCC1646343ECE7007B1C4DC65C4A939CDD47F6ED8855913183149BECE66D8FE7793AE607EB8E28513749B9548252764110D3B58D1D8B348DB18F7F24F8CA0C7D9CB515D90F7F1848FF58472B2EF52EBAB123AFC7F87890CE9FC55B31160014294A9B7F81638A27335E29E15A10B1068D5E049B1C239814DBBCC1BB30E11EEBAD5ACF8FB1B986C4F48D73FEA6129D9708A0B5AC435402BEC8C79C71DB94394811B9A604141A125A4669F9A139A0264E93E822117BE8E0D93A1487C51214E9FBF5763A3FBE9DA700B9C9B435472AF9F0B4446B000000003239307DD8B645100001D60B90300000CA1EC9E9B1C467FB020000000004595A +... diff --git a/lldb/lit/ObjectFile/ELF/minidebuginfo-find-symbols.yaml b/lldb/lit/ObjectFile/ELF/minidebuginfo-find-symbols.yaml new file mode 100644 index 00000000000..230ce8bb1c3 --- /dev/null +++ b/lldb/lit/ObjectFile/ELF/minidebuginfo-find-symbols.yaml @@ -0,0 +1,26 @@ +# REQUIRES: lzma + +# RUN: yaml2obj %s > %t.obj + +# TODO(kwk): once yaml2obj doesn't auto-generate a .symtab section +# when there's none in YAML, remove the following line: + +# RUN: llvm-objcopy --remove-section=.symtab %t.obj + +# RUN: %lldb -b -o 'image dump symtab' %t.obj | FileCheck %s + +# CHECK: [ 0] 1 X Code 0x00000000004005b0 0x000000000000000f 0x00000012 multiplyByFour + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_X86_64 + Entry: 0x00000000004004C0 +Sections: + - Name: .gnu_debugdata + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: FD377A585A000004E6D6B4460200210116000000742FE5A3E0180F05BA5D003F914584683D89A6DA8ACC93E24ED90802EC1FE2A7102958F4A42B6A7134F23922F6F35F529E133A8B5588025CFAC876C68510A157DBBCF8CA75E9854DED10FDD5CE0CDC136F6459B13B9847AEF79E9B1C7CD70EF4F3AF709F5DA0C1F40780154D72120A6A62A3F1A216E20DC597CE55BB23B48785957321A15FEE48808C1428B925DBC8022541CC594BD0AF2B51C6BE2854C81611017704DF6E509D21013B80BEC27D8919ACD3157E89353A08F4C86781ED708E89AB322D010F0F1605DAD9B9CE2B13C387769C83F5F85C647FD9C551E0E9C7D4A5CBE297970E486CB94AC283F98A7C6412A57F9C37952327549EEC4634D2CFA55B0F99923A14992D4293E0D87CEEF7FB6160C45928DE25074EEBF5329B5579AF01DB23DF22CBD48C8037B68FFFBE5CEA6CD26A936DD07D9B2E6006B7C6E5CC751072185EFE995D3F3C8DACF9039D4BEFB1F376B491568F6F00DB50FF477F36B90413E4FA30AE7C561A1249FD45FDFF884F70247FC21E57195A764151D8E341267E724D856C512BD243CDB33AB313758443877B2CB58F7F8F0461DE9766647F333A3531BDC4A26E9537EB314708D31212FCF4C21E9CB139F4DBFD21BB16A126C35E2BB3F7E30BF5A54961CECD4DD4D91A3757356F618754B21533C34F2BD97D70A02B1F338588BDBA9CDF5FC9FBE973E550194F07EC7A1E8E3C005FD60F8853223427628987E82E701CA7E2FDFA1B0ED564C37D115A72C3EC01E29C85C3630D8A385C4AE12F4F75F9F0BC12F2698345DD62A1F546A5953AF5CF3C0F22C7DA510F6739EB8CDB0E8A5A3BC13CFC31C1875C313908EFF23678869B76A6E1C10FE699E43BFFDE8F0752ED994A4A84BC0AD9D7381131D457C4917C4F6656F5C95D3221A79166C802D5F5A7C68554E54C42CA535465D224C7B641CF3417C3EAFD03CE5709BEA33DC7C9155CAC9D3C8033AF7CDA622020606A7C139D77FF85BC19323BF956C9C4662F60079BC7FE5F67B46211716A1A6CE4AB8AAB307D6444310CBC101071703EECC0B4622D91D705F5DA2932DA8BCEDA8E1CB0CDB20AAD652B8F86A521D3421287F1C175AE3BE6458AE6F8F3FB6FB7ED97B616B580D791E5FE0B74973F8604F419039B5B9D9A14397EE509F2B33AE404FF96DD0551472C5302E67910F0794B15CFE837351C6AF89B2FE88488B557BE8ACFFA331FB7AD553D35CAEB7D8BCEFB6CFF4A58E91355FE931408CF4CAFA9B97518B9E5C02078F64CE81279801B090348213DCAA7D12DC098BFF58C5A3202EFC38F64AD894379747B54AB5A9843F82E5FF1F394C8B783C3A8F1655DDEF8D5FE09EBB3E703853ABD716743507000696FB6B35216B088E499F53880375521442ED45DCDD1B31AAEBDAD3C7DA958593425206C4B2A0BC6CADE3B0B1598499E08016E84F33E3EB9D7B03B9C9DFA91B8CE5C74DEF2BC97FEE9982B0AEC16C75EEB7AE9A858A9C37F6C12B040C68A49111DCF0F3A4780F3879E93D904676BE908FDC66373D34AA715A39EFBC2795C6C8F058CA24392FB2591AD06ACD6AED8746F926886180C2B007ED58C9884A8BEF6CCA1F549F5C4FB411A3FF78770D1147363AC80B98B5A8FDB3DEC4E61709F66A622BDA835B1FD67B7C7CB166ABB163FB7C5204AE200C71C6A18B532C407647323B8F2FAC7ECB68C250877FC8DD5FE05B2B39E66F687EBB6EEFB7D5209E22F451B76F57D90BB6641DFFDE1A1821C4D783E4756F3CEE7F63B9BA284F8E114B0D9A086D83233BED4A8F5B60933DC16AF4DDE19C9FC59BCC1646343ECE7007B1C4DC65C4A939CDD47F6ED8855913183149BECE66D8FE7793AE607EB8E28513749B9548252764110D3B58D1D8B348DB18F7F24F8CA0C7D9CB515D90F7F1848FF58472B2EF52EBAB123AFC7F87890CE9FC55B31160014294A9B7F81638A27335E29E15A10B1068D5E049B1C239814DBBCC1BB30E11EEBAD5ACF8FB1B986C4F48D73FEA6129D9708A0B5AC435402BEC8C79C71DB94394811B9A604141A125A4669F9A139A0264E93E822117BE8E0D93A1487C51214E9FBF5763A3FBE9DA700B9C9B435472AF9F0B4446B000000003239307DD8B645100001D60B90300000CA1EC9E9B1C467FB020000000004595A +... diff --git a/lldb/lit/ObjectFile/ELF/minidebuginfo-no-lzma.yaml b/lldb/lit/ObjectFile/ELF/minidebuginfo-no-lzma.yaml new file mode 100644 index 00000000000..a127109e991 --- /dev/null +++ b/lldb/lit/ObjectFile/ELF/minidebuginfo-no-lzma.yaml @@ -0,0 +1,29 @@ +# REQUIRES: !lzma + +# This test checks that a warning is printed when we're trying +# to decompress a .gnu_debugdata section when no LZMA support was compiled in. + +# RUN: yaml2obj %s > %t.obj + +# TODO(kwk): once yaml2obj doesn't auto-generate a .symtab section +# when there's none in YAML, remove the following line: + +# RUN: llvm-objcopy --remove-section=.symtab %t.obj + +# RUN: %lldb -b -o 'image dump symtab' %t.obj 2>&1 | FileCheck %s + +# CHECK: warning: (x86_64) {{.*}}.obj No LZMA support found for reading .gnu_debugdata section + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_X86_64 + Entry: 0x00000000004004C0 +Sections: + - Name: .gnu_debugdata + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: FD377A585A000004E6D6B4460200210116000000742FE5A3E0180F05BA5D003F914584683D89A6DA8ACC93E24ED90802EC1FE2A7102958F4A42B6A7134F23922F6F35F529E133A8B5588025CFAC876C68510A157DBBCF8CA75E9854DED10FDD5CE0CDC136F6459B13B9847AEF79E9B1C7CD70EF4F3AF709F5DA0C1F40780154D72120A6A62A3F1A216E20DC597CE55BB23B48785957321A15FEE48808C1428B925DBC8022541CC594BD0AF2B51C6BE2854C81611017704DF6E509D21013B80BEC27D8919ACD3157E89353A08F4C86781ED708E89AB322D010F0F1605DAD9B9CE2B13C387769C83F5F85C647FD9C551E0E9C7D4A5CBE297970E486CB94AC283F98A7C6412A57F9C37952327549EEC4634D2CFA55B0F99923A14992D4293E0D87CEEF7FB6160C45928DE25074EEBF5329B5579AF01DB23DF22CBD48C8037B68FFFBE5CEA6CD26A936DD07D9B2E6006B7C6E5CC751072185EFE995D3F3C8DACF9039D4BEFB1F376B491568F6F00DB50FF477F36B90413E4FA30AE7C561A1249FD45FDFF884F70247FC21E57195A764151D8E341267E724D856C512BD243CDB33AB313758443877B2CB58F7F8F0461DE9766647F333A3531BDC4A26E9537EB314708D31212FCF4C21E9CB139F4DBFD21BB16A126C35E2BB3F7E30BF5A54961CECD4DD4D91A3757356F618754B21533C34F2BD97D70A02B1F338588BDBA9CDF5FC9FBE973E550194F07EC7A1E8E3C005FD60F8853223427628987E82E701CA7E2FDFA1B0ED564C37D115A72C3EC01E29C85C3630D8A385C4AE12F4F75F9F0BC12F2698345DD62A1F546A5953AF5CF3C0F22C7DA510F6739EB8CDB0E8A5A3BC13CFC31C1875C313908EFF23678869B76A6E1C10FE699E43BFFDE8F0752ED994A4A84BC0AD9D7381131D457C4917C4F6656F5C95D3221A79166C802D5F5A7C68554E54C42CA535465D224C7B641CF3417C3EAFD03CE5709BEA33DC7C9155CAC9D3C8033AF7CDA622020606A7C139D77FF85BC19323BF956C9C4662F60079BC7FE5F67B46211716A1A6CE4AB8AAB307D6444310CBC101071703EECC0B4622D91D705F5DA2932DA8BCEDA8E1CB0CDB20AAD652B8F86A521D3421287F1C175AE3BE6458AE6F8F3FB6FB7ED97B616B580D791E5FE0B74973F8604F419039B5B9D9A14397EE509F2B33AE404FF96DD0551472C5302E67910F0794B15CFE837351C6AF89B2FE88488B557BE8ACFFA331FB7AD553D35CAEB7D8BCEFB6CFF4A58E91355FE931408CF4CAFA9B97518B9E5C02078F64CE81279801B090348213DCAA7D12DC098BFF58C5A3202EFC38F64AD894379747B54AB5A9843F82E5FF1F394C8B783C3A8F1655DDEF8D5FE09EBB3E703853ABD716743507000696FB6B35216B088E499F53880375521442ED45DCDD1B31AAEBDAD3C7DA958593425206C4B2A0BC6CADE3B0B1598499E08016E84F33E3EB9D7B03B9C9DFA91B8CE5C74DEF2BC97FEE9982B0AEC16C75EEB7AE9A858A9C37F6C12B040C68A49111DCF0F3A4780F3879E93D904676BE908FDC66373D34AA715A39EFBC2795C6C8F058CA24392FB2591AD06ACD6AED8746F926886180C2B007ED58C9884A8BEF6CCA1F549F5C4FB411A3FF78770D1147363AC80B98B5A8FDB3DEC4E61709F66A622BDA835B1FD67B7C7CB166ABB163FB7C5204AE200C71C6A18B532C407647323B8F2FAC7ECB68C250877FC8DD5FE05B2B39E66F687EBB6EEFB7D5209E22F451B76F57D90BB6641DFFDE1A1821C4D783E4756F3CEE7F63B9BA284F8E114B0D9A086D83233BED4A8F5B60933DC16AF4DDE19C9FC59BCC1646343ECE7007B1C4DC65C4A939CDD47F6ED8855913183149BECE66D8FE7793AE607EB8E28513749B9548252764110D3B58D1D8B348DB18F7F24F8CA0C7D9CB515D90F7F1848FF58472B2EF52EBAB123AFC7F87890CE9FC55B31160014294A9B7F81638A27335E29E15A10B1068D5E049B1C239814DBBCC1BB30E11EEBAD5ACF8FB1B986C4F48D73FEA6129D9708A0B5AC435402BEC8C79C71DB94394811B9A604141A125A4669F9A139A0264E93E822117BE8E0D93A1487C51214E9FBF5763A3FBE9DA700B9C9B435472AF9F0B4446B000000003239307DD8B645100001D60B90300000CA1EC9E9B1C467FB020000000004595A +... diff --git a/lldb/lit/ObjectFile/ELF/minidebuginfo-set-and-hit-breakpoint.test b/lldb/lit/ObjectFile/ELF/minidebuginfo-set-and-hit-breakpoint.test new file mode 100644 index 00000000000..c568a19642a --- /dev/null +++ b/lldb/lit/ObjectFile/ELF/minidebuginfo-set-and-hit-breakpoint.test @@ -0,0 +1,89 @@ +# REQUIRES: system-linux, lzma, xz + +# We want to keep the symbol "multiplyByThree" in the .dynamic section and not +# have it put the default .symtab section. +# RUN: echo "{multiplyByThree;};" > %T/dynmic-symbols.txt +# RUN: %clang -Wl,--dynamic-list=%T/dynmic-symbols.txt -g -o %t.binary %p/Inputs/minidebuginfo-main.c + +# The following section is adapted from GDB's official documentation: +# http://sourceware.org/gdb/current/onlinedocs/gdb/MiniDebugInfo.html#MiniDebugInfo + +# Extract the dynamic symbols from the main binary, there is no need +# to also have these in the normal symbol table. + +# IGNORE: llvm-nm -D %t.binary --format=posix --defined-only | awk '{ print $1 }' | sort > %t.dynsyms + +# Extract all the text (i.e. function) symbols from the debuginfo. +# (Note that we actually also accept "D" symbols, for the benefit +# of platforms like PowerPC64 that use function descriptors.) + +# IGNORE: llvm-nm %t.binary --format=posix --defined-only | awk '{ if ($2 == "T" || $2 == "t" || $2 == "D") print $1 }' | sort > %t.funcsyms + +# Keep all the function symbols not already in the dynamic symbol +# table. + +# IGNORE: comm -13 %t.dynsyms %t.funcsyms > %t.keep_symbols +# The result of the preceeding command can be hardcoded +# because we know what symbol to keep. +# RUN: echo "multiplyByFour" > %t.keep_symbols + +# Separate full debug info into debug binary. + +# RUN: llvm-objcopy --only-keep-debug %t.binary %t.debug + +# Copy the full debuginfo, keeping only a minimal set of symbols and +# removing some unnecessary sections. + +# RUN: llvm-objcopy -S --remove-section .gdb_index --remove-section .comment --keep-symbols=%t.keep_symbols %t.debug %t.mini_debuginfo + +# This command is not from the GDB manual but it slims down embedded minidebug +# info. On top if that, it ensures that we only have the multiplyByThree symbol +# in the .dynsym section of the main binary. The bits removing .rela.plt, +# .rela.dyn and .dynsym sections can be removed once llvm-objcopy +# --only-keep-debug starts to work. +# RUN: llvm-objcopy --remove-section=.rela.plt --remove-section=.rela.dyn \ +# RUN: --remove-section=.gnu.version --remove-section=.gnu.hash --remove-section=.dynsym %t.mini_debuginfo + +# Drop the full debug info from the original binary. + +# RUN: llvm-strip --strip-all -R .comment %t.binary + +# Inject the compressed data into the .gnu_debugdata section of the +# original binary. + +# RUN: xz --force --keep %t.mini_debuginfo + +# RUN: llvm-objcopy --add-section .gnu_debugdata=%t.mini_debuginfo.xz %t.binary + +# Now run the binary and see that we can set and hit a breakpoint +# from within the .dynsym section (multiplyByThree) and one from +# the .symtab section embedded in the .gnu_debugdata section (multiplyByFour). + +# RUN: %lldb -b -o 'b multiplyByThree' -o 'b multiplyByFour' -o 'run' -o 'continue' -o 'breakpoint list -v' %t.binary | FileCheck %s + +# CHECK: (lldb) b multiplyByThree +# CHECK-NEXT: Breakpoint 1: where = minidebuginfo-set-and-hit-breakpoint.test.tmp.binary`multiplyByThree, address = 0x{{.*}} + +# CHECK: (lldb) b multiplyByFour +# CHECK-NEXT: Breakpoint 2: where = minidebuginfo-set-and-hit-breakpoint.test.tmp.binary`multiplyByFour, address = 0x{{.*}} + +# CHECK: * thread #1, name = 'minidebuginfo-s', stop reason = breakpoint 1.1 +# CHECK: * thread #1, name = 'minidebuginfo-s', stop reason = breakpoint 2.1 + +# CHECK: (lldb) breakpoint list -v +# CHECK-NEXT: Current breakpoints: +# CHECK-NEXT: 1: name = 'multiplyByThree' +# CHECK-NEXT: 1.1: +# CHECK-NEXT: module = {{.*}}/minidebuginfo-set-and-hit-breakpoint.test.tmp.binary +# CHECK-NEXT: symbol = multiplyByThree +# CHECK-NEXT: address = 0x{{.*}} +# CHECK-NEXT: resolved = true +# CHECK-NEXT: hit count = 1 + +# CHECK: 2: name = 'multiplyByFour' +# CHECK-NEXT: 2.1: +# CHECK-NEXT: module = {{.*}}/minidebuginfo-set-and-hit-breakpoint.test.tmp.binary +# CHECK-NEXT: symbol = multiplyByFour +# CHECK-NEXT: address = 0x{{.*}} +# CHECK-NEXT: resolved = true +# CHECK-NEXT: hit count = 1 diff --git a/lldb/lit/ObjectFile/ELF/netbsd-core-amd64.test b/lldb/lit/ObjectFile/ELF/netbsd-core-amd64.test new file mode 100644 index 00000000000..7140b4f8998 --- /dev/null +++ b/lldb/lit/ObjectFile/ELF/netbsd-core-amd64.test @@ -0,0 +1,12 @@ +# Test whether NetBSD core dumps are recognized correctly. + +# Core dump generated by the following program: +# int main() { +# void* v = 0; +# *v = 1; +# return 0; +# } + +# RUN: lldb-test object-file %S/Inputs/netbsd-amd64.core | FileCheck %s +# CHECK: Architecture: x86_64-unknown-netbsd +# CHECK: Type: core file diff --git a/lldb/lit/ObjectFile/ELF/netbsd-exec-8.99.30-amd64.yaml b/lldb/lit/ObjectFile/ELF/netbsd-exec-8.99.30-amd64.yaml new file mode 100644 index 00000000000..d8e68e9085a --- /dev/null +++ b/lldb/lit/ObjectFile/ELF/netbsd-exec-8.99.30-amd64.yaml @@ -0,0 +1,22 @@ +# Test whether NetBSD executables are recognized correctly. + +# RUN: yaml2obj %s > %t +# RUN: lldb-test object-file %t | FileCheck %s +# CHECK: Architecture: x86_64--netbsd8.99.30 +# CHECK: Type: executable + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_X86_64 + Entry: 0x00000000002006F0 +Sections: + - Name: .note.netbsd.ident + Type: SHT_NOTE + Flags: [ SHF_ALLOC ] + Address: 0x00000000002005A8 + AddressAlign: 0x0000000000000004 + Content: 0700000004000000010000004E6574425344000078B29535 +... diff --git a/lldb/lit/ObjectFile/ELF/section-addresses.yaml b/lldb/lit/ObjectFile/ELF/section-addresses.yaml new file mode 100644 index 00000000000..012abbf1f6d --- /dev/null +++ b/lldb/lit/ObjectFile/ELF/section-addresses.yaml @@ -0,0 +1,58 @@ +# RUN: yaml2obj %s > %t +# RUN: lldb-test object-file %t | FileCheck %s + +# CHECK-LABEL: Name: .one +# CHECK: VM address: 0x0 + +# CHECK-LABEL: Name: .nonalloc +# CHECK: VM address: 0x0 + +# CHECK-LABEL: Name: .two +# CHECK: VM address: 0x8 + +# CHECK-LABEL: Name: .three +# CHECK: VM address: 0xc + +# CHECK-LABEL: Name: .four +# CHECK: VM address: 0xc + +# CHECK-LABEL: Name: .five +# CHECK: VM address: 0x1000 + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_X86_64 + Entry: 0x00000000000007A0 +Sections: + - Name: .one + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC ] + AddressAlign: 0x0000000000000004 + Content: DEADBEEFBAADF00D + - Name: .nonalloc + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000004 + Content: DEADBEEFBAADF00D + - Name: .two + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC ] + AddressAlign: 0x0000000000000004 + Content: DE + - Name: .three + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC ] + AddressAlign: 0x0000000000000004 + - Name: .four + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC ] + AddressAlign: 0x0000000000000004 + Content: DEADBEEFBAADF00D + - Name: .five + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC ] + AddressAlign: 0x0000000000001000 + Content: DEADBEEFBAADF00D +... diff --git a/lldb/lit/ObjectFile/ELF/section-overlap.yaml b/lldb/lit/ObjectFile/ELF/section-overlap.yaml new file mode 100644 index 00000000000..bfbd873be41 --- /dev/null +++ b/lldb/lit/ObjectFile/ELF/section-overlap.yaml @@ -0,0 +1,51 @@ +# Test handling of (corrupt?) object files, which have sections with overlapping +# virtual addresses. +# +# Right now the overlapping sections get dropped, but other behaviors +# (including outright rejecting such files) are possible too. + +# RUN: yaml2obj %s > %t +# RUN: lldb-test object-file %t | FileCheck %s + +# CHECK-NOT: .overlap1 +# CHECK-NOT: .overlap2 + +!ELF +FileHeader: + Class: ELFCLASS32 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_ARM +Sections: + - Name: .sect1 + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC ] + Address: 0x1000 + AddressAlign: 0x4 + Content: DEADBEEFBAADF00D + - Name: .overlap1 + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC ] + Address: 0x1004 + AddressAlign: 0x4 + Content: DEADBEEFBAADF00D + - Name: .sect2 + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC ] + Address: 0x2000 + AddressAlign: 0x4 + Content: DEADBEEFBAADF00D + - Name: .overlap2 + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC ] + Address: 0x2004 + AddressAlign: 0x4 + Content: DEADBEEFBAADF00D +ProgramHeaders: + - Type: PT_LOAD + Flags: [ PF_X, PF_W, PF_R ] + VAddr: 0x1000 + Align: 0x4 + Sections: + - Section: .sect1 + - Section: .overlap1 diff --git a/lldb/lit/ObjectFile/ELF/section-permissions.yaml b/lldb/lit/ObjectFile/ELF/section-permissions.yaml new file mode 100644 index 00000000000..99c2773c81b --- /dev/null +++ b/lldb/lit/ObjectFile/ELF/section-permissions.yaml @@ -0,0 +1,34 @@ +# RUN: yaml2obj %s > %t +# RUN: lldb-test object-file %t | FileCheck %s + +# CHECK-LABEL: Name: .r-x +# CHECK: Permissions: r-x +# +# CHECK-LABEL: Name: .rw- +# CHECK: Permissions: rw- + +# CHECK-LABEL: Name: .--- +# CHECK: Permissions: --- + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_X86_64 + Entry: 0x00000000000007A0 +Sections: + - Name: .r-x + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Content: DEADBEEFBAADF00D + - Name: .rw- + Type: SHT_PROGBITS + Flags: [ SHF_WRITE, SHF_ALLOC ] + AddressAlign: 0x0000000000000004 + Content: DEADBEEFBAADF00D + - Name: .--- + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: DEADBEEFBAADF00D +... diff --git a/lldb/lit/ObjectFile/ELF/section-types-edgecases.yaml b/lldb/lit/ObjectFile/ELF/section-types-edgecases.yaml new file mode 100644 index 00000000000..ad1fa2d9097 --- /dev/null +++ b/lldb/lit/ObjectFile/ELF/section-types-edgecases.yaml @@ -0,0 +1,35 @@ +# This test doesn't attempt to mandate a specific section classification. It is +# here to document the existing behavior and to make sure we don't do something +# completely crazy (like crashing). + +# RUN: yaml2obj %s > %t +# RUN: lldb-test object-file %t | FileCheck %s + +# The section is called .data, but it has the SHF_EXECINSTR flag set. Have +# the flag take precedence over the name. +# CHECK-LABEL: Name: .data +# CHECK-NEXT: Type: code + +# Section type (SHT_SYMTAB) takes precedence over name-based deduction. +# CHECK-LABEL: Name: .text +# CHECK-NEXT: Type: elf-symbol-table + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_DYN + Machine: EM_X86_64 + Entry: 0x00000000000007A0 +Sections: + - Name: .data + Type: SHT_PROGBITS + Flags: [ SHF_EXECINSTR, SHF_ALLOC ] + AddressAlign: 0x0000000000000004 + Content: DEADBEEFBAADF00D + - Name: .text + Type: SHT_SYMTAB + Flags: [ ] + AddressAlign: 0x0000000000000004 + Content: DEADBEEFBAADF00D +... diff --git a/lldb/lit/ObjectFile/ELF/section-types.yaml b/lldb/lit/ObjectFile/ELF/section-types.yaml new file mode 100644 index 00000000000..9f6b4c0533b --- /dev/null +++ b/lldb/lit/ObjectFile/ELF/section-types.yaml @@ -0,0 +1,88 @@ +# RUN: yaml2obj %s > %t +# RUN: lldb-test object-file %t | FileCheck %s + +# CHECK-LABEL: Name: .text +# CHECK-NEXT: Type: code + +# CHECK-LABEL: Name: .debug_info +# CHECK-NEXT: Type: dwarf-info + +# CHECK-LABEL: Name: .debug_types +# CHECK-NEXT: Type: dwarf-types + +# CHECK-LABEL: Name: .debug_types.dwo +# CHECK-NEXT: Type: dwarf-types-dwo + +# CHECK-LABEL: Name: .debug_names +# CHECK-NEXT: Type: dwarf-names + +# CHECK-LABEL: Name: .gnu_debugaltlink +# CHECK-NEXT: Type: dwarf-gnu-debugaltlink + +# CHECK-LABEL: Name: __codesection +# CHECK-NEXT: Type: code + +# CHECK-LABEL: Name: .data +# CHECK-NEXT: Type: data +# CHECK: Thread specific: no + +# CHECK-LABEL: Name: .tdata +# CHECK-NEXT: Type: data +# CHECK: Thread specific: yes + +# CHECK-LABEL: Name: .tbss +# CHECK-NEXT: Type: zero-fill +# CHECK: Thread specific: yes + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_X86_64 + Entry: 0x00000000000007A0 +Sections: + - Name: .text + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Content: DEADBEEFBAADF00D + - Name: .debug_info + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: DEADBEEFBAADF00D + - Name: .debug_types + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: DEADBEEFBAADF00D + - Name: .debug_types.dwo + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: DEADBEEFBAADF00D + - Name: .debug_names + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: DEADBEEFBAADF00D + - Name: .gnu_debugaltlink + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: DEADBEEFBAADF00D + - Name: __codesection + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Content: DEADBEEFBAADF00D + - Name: .data + Type: SHT_PROGBITS + Flags: [ SHF_WRITE, SHF_ALLOC ] + AddressAlign: 0x0000000000000004 + Content: 2F000000 + - Name: .tdata + Type: SHT_PROGBITS + Flags: [ SHF_WRITE, SHF_ALLOC, SHF_TLS ] + AddressAlign: 0x0000000000000004 + Content: 2F000000 + - Name: .tbss + Type: SHT_NOBITS + Flags: [ SHF_WRITE, SHF_ALLOC, SHF_TLS ] + AddressAlign: 0x0000000000000004 + Size: 0x0000000000000004 +... diff --git a/lldb/lit/ObjectFile/ELF/short-build-id.yaml b/lldb/lit/ObjectFile/ELF/short-build-id.yaml new file mode 100644 index 00000000000..90781347392 --- /dev/null +++ b/lldb/lit/ObjectFile/ELF/short-build-id.yaml @@ -0,0 +1,26 @@ +# RUN: yaml2obj %s >%t +# RUN: lldb-test object-file %t | FileCheck %s + +# CHECK: UUID: 333059A4-3CC3-D5F9 + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_X86_64 + Entry: 0x0000000000201000 +Sections: + - Name: .note.gnu.build-id + Type: SHT_NOTE + Flags: [ SHF_ALLOC ] + Address: 0x0000000000200190 + AddressAlign: 0x0000000000000004 + Content: 040000000800000003000000474E5500333059A43CC3D5F9 + - Name: .text + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Address: 0x0000000000201000 + AddressAlign: 0x0000000000000004 + Content: '' +... |

