diff options
author | David Srbecky <dsrbecky@google.com> | 2015-04-07 19:46:22 +0100 |
---|---|---|
committer | David Srbecky <dsrbecky@google.com> | 2015-04-07 20:07:58 +0100 |
commit | 8c57831b2b07185ee1986b9af68a351e1ca584c3 (patch) | |
tree | 862c57e602dff367ca141d3a86235b48bf47bf17 /compiler/elf_writer_quick.cc | |
parent | caff30245889729f102af87e79705893401251ef (diff) | |
download | art-8c57831b2b07185ee1986b9af68a351e1ca584c3.tar.gz art-8c57831b2b07185ee1986b9af68a351e1ca584c3.tar.bz2 art-8c57831b2b07185ee1986b9af68a351e1ca584c3.zip |
Remove the old CFI infrastructure.
Change-Id: I12a17a8a1c39ffccaa499c328ebac36e4d74dc4e
Diffstat (limited to 'compiler/elf_writer_quick.cc')
-rw-r--r-- | compiler/elf_writer_quick.cc | 180 |
1 files changed, 2 insertions, 178 deletions
diff --git a/compiler/elf_writer_quick.cc b/compiler/elf_writer_quick.cc index 24cb364d08..1bd83b6c85 100644 --- a/compiler/elf_writer_quick.cc +++ b/compiler/elf_writer_quick.cc @@ -89,116 +89,6 @@ bool ElfWriterQuick<Elf_Word, Elf_Sword, Elf_Addr, Elf_Dyn, return elf_writer.Write(oat_writer, dex_files, android_root, is_host); } -std::vector<uint8_t>* ConstructCIEFrameX86(bool is_x86_64) { - std::vector<uint8_t>* cfi_info = new std::vector<uint8_t>; - - // Length (will be filled in later in this routine). - if (is_x86_64) { - Push32(cfi_info, 0xffffffff); // Indicates 64bit - Push32(cfi_info, 0); - Push32(cfi_info, 0); - } else { - Push32(cfi_info, 0); - } - - // CIE id: always 0. - if (is_x86_64) { - Push32(cfi_info, 0); - Push32(cfi_info, 0); - } else { - Push32(cfi_info, 0); - } - - // Version: always 1. - cfi_info->push_back(0x01); - - // Augmentation: 'zR\0' - cfi_info->push_back(0x7a); - cfi_info->push_back(0x52); - cfi_info->push_back(0x0); - - // Code alignment: 1. - EncodeUnsignedLeb128(1, cfi_info); - - // Data alignment. - if (is_x86_64) { - EncodeSignedLeb128(-8, cfi_info); - } else { - EncodeSignedLeb128(-4, cfi_info); - } - - // Return address register. - if (is_x86_64) { - // R16(RIP) - cfi_info->push_back(0x10); - } else { - // R8(EIP) - cfi_info->push_back(0x08); - } - - // Augmentation length: 1. - cfi_info->push_back(1); - - // Augmentation data. - if (is_x86_64) { - // 0x04 ((DW_EH_PE_absptr << 4) | DW_EH_PE_udata8). - cfi_info->push_back(0x04); - } else { - // 0x03 ((DW_EH_PE_absptr << 4) | DW_EH_PE_udata4). - cfi_info->push_back(0x03); - } - - // Initial instructions. - if (is_x86_64) { - // DW_CFA_def_cfa R7(RSP) 8. - cfi_info->push_back(0x0c); - cfi_info->push_back(0x07); - cfi_info->push_back(0x08); - - // DW_CFA_offset R16(RIP) 1 (* -8). - cfi_info->push_back(0x90); - cfi_info->push_back(0x01); - } else { - // DW_CFA_def_cfa R4(ESP) 4. - cfi_info->push_back(0x0c); - cfi_info->push_back(0x04); - cfi_info->push_back(0x04); - - // DW_CFA_offset R8(EIP) 1 (* -4). - cfi_info->push_back(0x88); - cfi_info->push_back(0x01); - } - - // Padding to a multiple of 4 - while ((cfi_info->size() & 3) != 0) { - // DW_CFA_nop is encoded as 0. - cfi_info->push_back(0); - } - - // Set the length of the CIE inside the generated bytes. - if (is_x86_64) { - uint32_t length = cfi_info->size() - 12; - UpdateWord(cfi_info, 4, length); - } else { - uint32_t length = cfi_info->size() - 4; - UpdateWord(cfi_info, 0, length); - } - return cfi_info; -} - -std::vector<uint8_t>* ConstructCIEFrame(InstructionSet isa) { - switch (isa) { - case kX86: - return ConstructCIEFrameX86(false); - case kX86_64: - return ConstructCIEFrameX86(true); - - default: - // Not implemented. - return nullptr; - } -} - class OatWriterWrapper FINAL : public CodeOutput { public: explicit OatWriterWrapper(OatWriter* oat_writer) : oat_writer_(oat_writer) {} @@ -621,9 +511,7 @@ static void WriteDebugSymbols(const CompilerDriver* compiler_driver, ElfBuilder<Elf_Word, Elf_Sword, Elf_Addr, Elf_Dyn, Elf_Sym, Elf_Ehdr, Elf_Phdr, Elf_Shdr>* builder, OatWriter* oat_writer) { - std::unique_ptr<std::vector<uint8_t>> cfi_info( - ConstructCIEFrame(compiler_driver->GetInstructionSet())); - + UNUSED(compiler_driver); Elf_Addr text_section_address = builder->GetTextBuilder().GetSection()->sh_addr; // Iterate over the compiled methods. @@ -643,63 +531,8 @@ static void WriteDebugSymbols(const CompilerDriver* compiler_driver, symtab->AddSymbol("$t", &builder->GetTextBuilder(), it->low_pc_ & ~1, true, 0, STB_LOCAL, STT_NOTYPE); } - - // Include CFI for compiled method, if possible. - if (cfi_info.get() != nullptr) { - DCHECK(it->compiled_method_ != nullptr); - - // Copy in the FDE, if present - const SwapVector<uint8_t>* fde = it->compiled_method_->GetCFIInfo(); - if (fde != nullptr) { - // Copy the information into cfi_info and then fix the address in the new copy. - int cur_offset = cfi_info->size(); - cfi_info->insert(cfi_info->end(), fde->begin(), fde->end()); - - bool is_64bit = *(reinterpret_cast<const uint32_t*>(fde->data())) == 0xffffffff; - - // Set the 'CIE_pointer' field. - uint64_t CIE_pointer = cur_offset + (is_64bit ? 12 : 4); - uint64_t offset_to_update = CIE_pointer; - if (is_64bit) { - (*cfi_info)[offset_to_update+0] = CIE_pointer; - (*cfi_info)[offset_to_update+1] = CIE_pointer >> 8; - (*cfi_info)[offset_to_update+2] = CIE_pointer >> 16; - (*cfi_info)[offset_to_update+3] = CIE_pointer >> 24; - (*cfi_info)[offset_to_update+4] = CIE_pointer >> 32; - (*cfi_info)[offset_to_update+5] = CIE_pointer >> 40; - (*cfi_info)[offset_to_update+6] = CIE_pointer >> 48; - (*cfi_info)[offset_to_update+7] = CIE_pointer >> 56; - } else { - (*cfi_info)[offset_to_update+0] = CIE_pointer; - (*cfi_info)[offset_to_update+1] = CIE_pointer >> 8; - (*cfi_info)[offset_to_update+2] = CIE_pointer >> 16; - (*cfi_info)[offset_to_update+3] = CIE_pointer >> 24; - } - - // Set the 'initial_location' field. - offset_to_update += is_64bit ? 8 : 4; - if (is_64bit) { - const uint64_t quick_code_start = it->low_pc_ + text_section_address; - (*cfi_info)[offset_to_update+0] = quick_code_start; - (*cfi_info)[offset_to_update+1] = quick_code_start >> 8; - (*cfi_info)[offset_to_update+2] = quick_code_start >> 16; - (*cfi_info)[offset_to_update+3] = quick_code_start >> 24; - (*cfi_info)[offset_to_update+4] = quick_code_start >> 32; - (*cfi_info)[offset_to_update+5] = quick_code_start >> 40; - (*cfi_info)[offset_to_update+6] = quick_code_start >> 48; - (*cfi_info)[offset_to_update+7] = quick_code_start >> 56; - } else { - const uint32_t quick_code_start = it->low_pc_ + text_section_address; - (*cfi_info)[offset_to_update+0] = quick_code_start; - (*cfi_info)[offset_to_update+1] = quick_code_start >> 8; - (*cfi_info)[offset_to_update+2] = quick_code_start >> 16; - (*cfi_info)[offset_to_update+3] = quick_code_start >> 24; - } - } - } } - bool hasCFI = (cfi_info.get() != nullptr); bool hasLineInfo = false; for (auto& dbg_info : oat_writer->GetCFIMethodInfo()) { if (dbg_info.dbgstream_ != nullptr && @@ -709,7 +542,7 @@ static void WriteDebugSymbols(const CompilerDriver* compiler_driver, } } - if (hasLineInfo || hasCFI) { + if (hasLineInfo) { ElfRawSectionBuilder<Elf_Word, Elf_Sword, Elf_Shdr> debug_info(".debug_info", SHT_PROGBITS, 0, nullptr, 0, 1, 0); @@ -731,15 +564,6 @@ static void WriteDebugSymbols(const CompilerDriver* compiler_driver, builder->RegisterRawSection(debug_info); builder->RegisterRawSection(debug_abbrev); - if (hasCFI) { - ElfRawSectionBuilder<Elf_Word, Elf_Sword, Elf_Shdr> eh_frame(".eh_frame", - SHT_PROGBITS, - SHF_ALLOC, - nullptr, 0, 4, 0); - eh_frame.SetBuffer(std::move(*cfi_info.get())); - builder->RegisterRawSection(eh_frame); - } - if (hasLineInfo) { builder->RegisterRawSection(debug_line); } |