summaryrefslogtreecommitdiffstats
path: root/lldb/unittests/ObjectFile
diff options
context:
space:
mode:
authorPavel Labath <pavel@labath.sk>2019-08-08 12:57:46 +0000
committerPavel Labath <pavel@labath.sk>2019-08-08 12:57:46 +0000
commit88c77d6752ca6b50f69392d05b13bf1ef0dcb724 (patch)
treee0c57e36f65037f79c73370be60b8c2fe96fa854 /lldb/unittests/ObjectFile
parent9427aa2d543ba281f816e6ce7107d6467acf6794 (diff)
downloadbcm5719-llvm-88c77d6752ca6b50f69392d05b13bf1ef0dcb724.tar.gz
bcm5719-llvm-88c77d6752ca6b50f69392d05b13bf1ef0dcb724.zip
ObjectFileELF: Convert a unit test to a lit test
It is much easier to test this functionality via lldb-test. llvm-svn: 368289
Diffstat (limited to 'lldb/unittests/ObjectFile')
-rw-r--r--lldb/unittests/ObjectFile/ELF/CMakeLists.txt1
-rw-r--r--lldb/unittests/ObjectFile/ELF/Inputs/debug-info-relocations.pcm.yaml182
-rw-r--r--lldb/unittests/ObjectFile/ELF/TestObjectFileELF.cpp59
3 files changed, 0 insertions, 242 deletions
diff --git a/lldb/unittests/ObjectFile/ELF/CMakeLists.txt b/lldb/unittests/ObjectFile/ELF/CMakeLists.txt
index 9d2b64becb1..9bc2125ef01 100644
--- a/lldb/unittests/ObjectFile/ELF/CMakeLists.txt
+++ b/lldb/unittests/ObjectFile/ELF/CMakeLists.txt
@@ -11,7 +11,6 @@ add_lldb_unittest(ObjectFileELFTests
set(test_inputs
early-section-headers.so
- debug-info-relocations.pcm.yaml
sections-resolve-consistently.yaml
)
add_unittest_inputs(ObjectFileELFTests "${test_inputs}")
diff --git a/lldb/unittests/ObjectFile/ELF/Inputs/debug-info-relocations.pcm.yaml b/lldb/unittests/ObjectFile/ELF/Inputs/debug-info-relocations.pcm.yaml
deleted file mode 100644
index 10f5e59432f..00000000000
--- a/lldb/unittests/ObjectFile/ELF/Inputs/debug-info-relocations.pcm.yaml
+++ /dev/null
@@ -1,182 +0,0 @@
---- !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
- Content: 636C616E672076657273696F6E20362E302E312028746167732F52454C454153455F3630312F66696E616C2900726564756365642E68002F746D702F617364666173646673646661006600696E7400
- - Name: .debug_abbrev
- Type: SHT_PROGBITS
- AddressAlign: 0x0000000000000001
- Content: 011101250E1305030E10171B0EB44219110112060000022E00110112064018030E3A0B3B0B271949133F190000032400030E3E0B0B0B000000
- - 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_ranges
- Type: SHT_PROGBITS
- AddressAlign: 0x0000000000000001
- Content: ''
- - Name: .debug_macinfo
- Type: SHT_PROGBITS
- AddressAlign: 0x0000000000000001
- Content: '00'
- - Name: .debug_pubnames
- Type: SHT_PROGBITS
- AddressAlign: 0x0000000000000001
- Content: 140000000200000000004B0000002A000000660000000000
- - Name: .rela.debug_pubnames
- Type: SHT_RELA
- Link: .symtab
- AddressAlign: 0x0000000000000008
- Info: .debug_pubnames
- Relocations:
- - Offset: 0x0000000000000006
- Symbol: .debug_info
- Type: R_AARCH64_ABS32
- - Name: .debug_pubtypes
- Type: SHT_PROGBITS
- AddressAlign: 0x0000000000000001
- Content: 160000000200000000004B00000043000000696E740000000000
- - Name: .rela.debug_pubtypes
- Type: SHT_RELA
- Link: .symtab
- AddressAlign: 0x0000000000000008
- Info: .debug_pubtypes
- Relocations:
- - Offset: 0x0000000000000006
- Symbol: .debug_info
- Type: R_AARCH64_ABS32
- - Name: .comment
- Type: SHT_PROGBITS
- Flags: [ SHF_MERGE, SHF_STRINGS ]
- AddressAlign: 0x0000000000000001
- Content: 00636C616E672076657273696F6E20362E302E312028746167732F52454C454153455F3630312F66696E616C2900
- - Name: .note.GNU-stack
- Type: SHT_PROGBITS
- AddressAlign: 0x0000000000000001
- Content: ''
- - Name: .debug_frame
- Type: SHT_PROGBITS
- AddressAlign: 0x0000000000000008
- Content: 14000000FFFFFFFF04000800017C1E0C1F00000000000000140000000000000000000000000000000800000000000000
- - Name: .rela.debug_frame
- Type: SHT_RELA
- Link: .symtab
- AddressAlign: 0x0000000000000008
- Info: .debug_frame
- Relocations:
- - Offset: 0x000000000000001C
- Symbol: .debug_frame
- Type: R_AARCH64_ABS32
- - Offset: 0x0000000000000020
- Symbol: .text
- Type: R_AARCH64_ABS64
- - Name: .debug_line
- Type: SHT_PROGBITS
- AddressAlign: 0x0000000000000001
- Content: 3C000000040021000000010101FB0E0D00010101010000000100000100726564756365642E68000000000000090200000000000000001305030A4B0204000101
- - Name: .rela.debug_line
- Type: SHT_RELA
- Link: .symtab
- AddressAlign: 0x0000000000000008
- Info: .debug_line
- Relocations:
- - Offset: 0x000000000000002E
- Symbol: .text
- Type: R_AARCH64_ABS64
-Symbols:
- - Name: reduced.h
- Type: STT_FILE
- - Name: '$d.1'
- Section: .debug_str
- - Name: '$d.2'
- Section: .debug_abbrev
- - Name: '$d.3'
- Section: .debug_info
- - Name: '$d.4'
- Section: .debug_macinfo
- - Name: '$d.5'
- Section: .debug_pubnames
- - Name: '$d.6'
- Section: .debug_pubtypes
- - Name: '$d.7'
- Section: .comment
- - Name: '$d.8'
- Section: .debug_frame
- - Name: '$d.9'
- Section: .debug_line
- - Name: '$x.0'
- Section: .text
- - 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_frame
- Type: STT_SECTION
- Section: .debug_frame
- - Name: .debug_line
- Type: STT_SECTION
- Section: .debug_line
- - Name: f
- Type: STT_FUNC
- Section: .text
- Size: 0x0000000000000008
- Binding: STB_GLOBAL
-DynamicSymbols:
-...
diff --git a/lldb/unittests/ObjectFile/ELF/TestObjectFileELF.cpp b/lldb/unittests/ObjectFile/ELF/TestObjectFileELF.cpp
index 0f72a86573e..ef62258ea82 100644
--- a/lldb/unittests/ObjectFile/ELF/TestObjectFileELF.cpp
+++ b/lldb/unittests/ObjectFile/ELF/TestObjectFileELF.cpp
@@ -123,62 +123,3 @@ TEST_F(ObjectFileELFTest, GetModuleSpecifications_EarlySectionHeaders) {
Uuid.SetFromStringRef("1b8a73ac238390e32a7ff4ac8ebe4d6a41ecf5c9", 20);
EXPECT_EQ(Spec.GetUUID(), Uuid);
}
-
-static void CHECK_ABS32(uint8_t *bytes, uint32_t offset, uint32_t addend) {
- uint32_t res;
- memcpy(&res, reinterpret_cast<uint32_t *>(bytes + offset), sizeof(uint32_t));
- ASSERT_EQ(addend, res);
-}
-
-static void CHECK_ABS64(uint8_t *bytes, uint64_t offset, uint64_t addend) {
- uint64_t res;
- memcpy(&res, reinterpret_cast<uint64_t *>(bytes + offset), sizeof(uint64_t));
- ASSERT_EQ(addend, res);
-}
-
-TEST_F(ObjectFileELFTest, TestAARCH64Relocations) {
- llvm::SmallString<128> obj;
- ASSERT_NO_ERROR(llvm::sys::fs::createTemporaryFile(
- "debug-info-relocations-%%%%%%", "obj", obj));
- llvm::FileRemover remover(obj);
- ASSERT_THAT_ERROR(ReadYAMLObjectFile("debug-info-relocations.pcm.yaml", obj),
- llvm::Succeeded());
-
- ModuleSpec spec{FileSpec(obj)};
- spec.GetSymbolFileSpec().SetFile(obj, FileSpec::Style::native);
- auto module_sp = std::make_shared<Module>(spec);
-
- auto objfile = static_cast<ObjectFileELF *>(module_sp->GetObjectFile());
- SectionList *section_list = objfile->GetSectionList();
- ASSERT_NE(nullptr, section_list);
-
- auto debug_info_sp =
- section_list->FindSectionByName(ConstString(".debug_info"));
- ASSERT_NE(nullptr, debug_info_sp);
- objfile->RelocateSection(debug_info_sp.get());
-
- DataExtractor data;
- // length of 0x10 is not needed but length 0x0 crashes
- objfile->GetData(0x00, 0x10, data);
- DataBufferSP &data_buffer_sp = data.GetSharedDataBuffer();
- uint8_t *bytes = data_buffer_sp->GetBytes();
-
- addr_t debug_info_offset = debug_info_sp->GetFileOffset();
- bytes += debug_info_offset;
-
- // Sanity check - The first byte from the yaml file is 0x47
- ASSERT_EQ(0x47, *bytes);
-
- // .rela.debug_info contains 9 relocations:
- // 7 R_AARCH64_ABS32 - 2 R_AARCH64_ABS64
- // None have a value. Four have addends.
- CHECK_ABS32(bytes, 0x6, 0);
- CHECK_ABS32(bytes, 0xC, 0);
- CHECK_ABS32(bytes, 0x12, 45);
- CHECK_ABS32(bytes, 0x16, 0);
- CHECK_ABS32(bytes, 0x1A, 55);
- CHECK_ABS64(bytes, 0x1E, 0);
- CHECK_ABS64(bytes, 0x2B, 0);
- CHECK_ABS32(bytes, 0x39, 73);
- CHECK_ABS32(bytes, 0x44, 75);
-}
OpenPOWER on IntegriCloud