diff options
author | 2016-02-05 09:40:10 +0000 | |
---|---|---|
committer | 2016-02-05 11:29:14 +0000 | |
commit | ae5d2738a2b941b543c3fd478af910d4cd16f2ba (patch) | |
tree | a198a7b0449c00938a35d013270d0db8bba197c9 /compiler/elf_writer_debug.cc | |
parent | ac6a195ec8e1b5a7a6bd3d0c53d8997ff7a5e2cc (diff) |
Change the method which generates DWARF mini-debug-info.
This splits some code from CL198651. It moves the WriteSection
call out one level and does not otherwise change behaviour.
Change-Id: I7dc1c7c08b577b50bf6fa366a9b0ca757048b81e
Diffstat (limited to 'compiler/elf_writer_debug.cc')
-rw-r--r-- | compiler/elf_writer_debug.cc | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/compiler/elf_writer_debug.cc b/compiler/elf_writer_debug.cc index ca8cd68b33..e2481b061c 100644 --- a/compiler/elf_writer_debug.cc +++ b/compiler/elf_writer_debug.cc @@ -1549,20 +1549,20 @@ static void XzCompress(const std::vector<uint8_t>* src, std::vector<uint8_t>* ds } template <typename ElfTypes> -void WriteMiniDebugInfo(ElfBuilder<ElfTypes>* parent_builder, - const ArrayRef<const MethodDebugInfo>& method_infos) { - const InstructionSet isa = parent_builder->GetIsa(); +std::vector<uint8_t> MakeMiniDebugInfoInternal( + InstructionSet isa, + size_t rodata_section_size, + size_t text_section_size, + const ArrayRef<const MethodDebugInfo>& method_infos) { std::vector<uint8_t> buffer; buffer.reserve(KB); VectorOutputStream out("Mini-debug-info ELF file", &buffer); std::unique_ptr<ElfBuilder<ElfTypes>> builder(new ElfBuilder<ElfTypes>(isa, &out)); builder->Start(); - // Write .rodata and .text as NOBITS sections. - // This allows tools to detect virtual address relocation of the parent ELF file. - builder->SetVirtualAddress(parent_builder->GetRoData()->GetAddress()); - builder->GetRoData()->WriteNoBitsSection(parent_builder->GetRoData()->GetSize()); - builder->SetVirtualAddress(parent_builder->GetText()->GetAddress()); - builder->GetText()->WriteNoBitsSection(parent_builder->GetText()->GetSize()); + // Mirror .rodata and .text as NOBITS sections. + // It is needed to detected relocations after compression. + builder->GetRoData()->WriteNoBitsSection(rodata_section_size); + builder->GetText()->WriteNoBitsSection(text_section_size); WriteDebugSymbols(builder.get(), method_infos, false /* with_signature */); WriteCFISection(builder.get(), method_infos, DW_DEBUG_FRAME_FORMAT, false /* write_oat_paches */); builder->End(); @@ -1570,7 +1570,19 @@ void WriteMiniDebugInfo(ElfBuilder<ElfTypes>* parent_builder, std::vector<uint8_t> compressed_buffer; compressed_buffer.reserve(buffer.size() / 4); XzCompress(&buffer, &compressed_buffer); - parent_builder->WriteSection(".gnu_debugdata", &compressed_buffer); + return compressed_buffer; +} + +std::vector<uint8_t> MakeMiniDebugInfo( + InstructionSet isa, + size_t rodata_size, + size_t text_size, + const ArrayRef<const MethodDebugInfo>& method_infos) { + if (Is64BitInstructionSet(isa)) { + return MakeMiniDebugInfoInternal<ElfTypes64>(isa, rodata_size, text_size, method_infos); + } else { + return MakeMiniDebugInfoInternal<ElfTypes32>(isa, rodata_size, text_size, method_infos); + } } template <typename ElfTypes> @@ -1649,12 +1661,6 @@ template void WriteDebugInfo<ElfTypes64>( const ArrayRef<const MethodDebugInfo>& method_infos, CFIFormat cfi_format, bool write_oat_patches); -template void WriteMiniDebugInfo<ElfTypes32>( - ElfBuilder<ElfTypes32>* builder, - const ArrayRef<const MethodDebugInfo>& method_infos); -template void WriteMiniDebugInfo<ElfTypes64>( - ElfBuilder<ElfTypes64>* builder, - const ArrayRef<const MethodDebugInfo>& method_infos); } // namespace dwarf } // namespace art |