diff options
| author | Pavel Labath <pavel@labath.sk> | 2019-08-08 12:57:46 +0000 |
|---|---|---|
| committer | Pavel Labath <pavel@labath.sk> | 2019-08-08 12:57:46 +0000 |
| commit | 88c77d6752ca6b50f69392d05b13bf1ef0dcb724 (patch) | |
| tree | e0c57e36f65037f79c73370be60b8c2fe96fa854 /lldb/unittests/ObjectFile/ELF/TestObjectFileELF.cpp | |
| parent | 9427aa2d543ba281f816e6ce7107d6467acf6794 (diff) | |
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/ELF/TestObjectFileELF.cpp')
| -rw-r--r-- | lldb/unittests/ObjectFile/ELF/TestObjectFileELF.cpp | 59 |
1 files changed, 0 insertions, 59 deletions
diff --git a/lldb/unittests/ObjectFile/ELF/TestObjectFileELF.cpp b/lldb/unittests/ObjectFile/ELF/TestObjectFileELF.cpp index 0f72a86573ef..ef62258ea822 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); -} |
