From ae5d2738a2b941b543c3fd478af910d4cd16f2ba Mon Sep 17 00:00:00 2001 From: David Srbecky Date: Fri, 5 Feb 2016 09:40:10 +0000 Subject: 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 --- compiler/elf_writer_debug.cc | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) (limited to 'compiler/elf_writer_debug.cc') 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* src, std::vector* ds } template -void WriteMiniDebugInfo(ElfBuilder* parent_builder, - const ArrayRef& method_infos) { - const InstructionSet isa = parent_builder->GetIsa(); +std::vector MakeMiniDebugInfoInternal( + InstructionSet isa, + size_t rodata_section_size, + size_t text_section_size, + const ArrayRef& method_infos) { std::vector buffer; buffer.reserve(KB); VectorOutputStream out("Mini-debug-info ELF file", &buffer); std::unique_ptr> builder(new ElfBuilder(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* parent_builder, std::vector compressed_buffer; compressed_buffer.reserve(buffer.size() / 4); XzCompress(&buffer, &compressed_buffer); - parent_builder->WriteSection(".gnu_debugdata", &compressed_buffer); + return compressed_buffer; +} + +std::vector MakeMiniDebugInfo( + InstructionSet isa, + size_t rodata_size, + size_t text_size, + const ArrayRef& method_infos) { + if (Is64BitInstructionSet(isa)) { + return MakeMiniDebugInfoInternal(isa, rodata_size, text_size, method_infos); + } else { + return MakeMiniDebugInfoInternal(isa, rodata_size, text_size, method_infos); + } } template @@ -1649,12 +1661,6 @@ template void WriteDebugInfo( const ArrayRef& method_infos, CFIFormat cfi_format, bool write_oat_patches); -template void WriteMiniDebugInfo( - ElfBuilder* builder, - const ArrayRef& method_infos); -template void WriteMiniDebugInfo( - ElfBuilder* builder, - const ArrayRef& method_infos); } // namespace dwarf } // namespace art -- cgit v1.2.3-59-g8ed1b