diff options
author | 2016-02-05 09:40:10 +0000 | |
---|---|---|
committer | 2016-02-05 11:29:14 +0000 | |
commit | ae5d2738a2b941b543c3fd478af910d4cd16f2ba (patch) | |
tree | a198a7b0449c00938a35d013270d0db8bba197c9 | |
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
-rw-r--r-- | compiler/elf_builder.h | 6 | ||||
-rw-r--r-- | compiler/elf_writer_debug.cc | 38 | ||||
-rw-r--r-- | compiler/elf_writer_debug.h | 7 | ||||
-rw-r--r-- | compiler/elf_writer_quick.cc | 7 |
4 files changed, 32 insertions, 26 deletions
diff --git a/compiler/elf_builder.h b/compiler/elf_builder.h index bc7c83ed7d..b673eeb3b6 100644 --- a/compiler/elf_builder.h +++ b/compiler/elf_builder.h @@ -361,12 +361,6 @@ class ElfBuilder FINAL { other_sections_.push_back(std::move(s)); } - // Set where the next section will be allocated in the virtual address space. - void SetVirtualAddress(Elf_Addr address) { - DCHECK_GE(address, virtual_address_); - virtual_address_ = address; - } - // Reserve space for ELF header and program headers. // We do not know the number of headers until later, so // it is easiest to just reserve a fixed amount of space. 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 diff --git a/compiler/elf_writer_debug.h b/compiler/elf_writer_debug.h index 8e8472f678..e289197971 100644 --- a/compiler/elf_writer_debug.h +++ b/compiler/elf_writer_debug.h @@ -36,9 +36,10 @@ void WriteDebugInfo(ElfBuilder<ElfTypes>* builder, CFIFormat cfi_format, bool write_oat_patches); -template <typename ElfTypes> -void WriteMiniDebugInfo(ElfBuilder<ElfTypes>* builder, - const ArrayRef<const MethodDebugInfo>& method_infos); +std::vector<uint8_t> MakeMiniDebugInfo(InstructionSet isa, + size_t rodata_section_size, + size_t text_section_size, + const ArrayRef<const MethodDebugInfo>& method_infos); ArrayRef<const uint8_t> WriteDebugElfFileForMethod(const dwarf::MethodDebugInfo& method_info); diff --git a/compiler/elf_writer_quick.cc b/compiler/elf_writer_quick.cc index f2a95f2396..05ac21913d 100644 --- a/compiler/elf_writer_quick.cc +++ b/compiler/elf_writer_quick.cc @@ -155,7 +155,12 @@ void ElfWriterQuick<ElfTypes>::WriteDebugInfo( } if (compiler_options_->GetGenerateMiniDebugInfo()) { // Generate only some information and compress it. - dwarf::WriteMiniDebugInfo(builder_.get(), method_infos); + std::vector<uint8_t> xz_elf_file = MakeMiniDebugInfo( + builder_->GetIsa(), + builder_->GetRoData()->GetSize(), + builder_->GetText()->GetSize(), + method_infos); + builder_->WriteSection(".gnu_debugdata", &xz_elf_file); } } |