Add binary search table for .debug_frame
Add ELF section somewhat similar to .eh_frame_hdr,
which can be used in libunwind to do binary search.
This increases .oat file size by 0.1%.
Bug: 110133331
Test: ./art/test.py -b --host -r -t 137-cfi
Change-Id: Ief47d15eb3f3d302438b713af4cfbcddd0c5078a
diff --git a/compiler/debug/elf_debug_frame_writer.h b/compiler/debug/elf_debug_frame_writer.h
index c5fa647..1f827ea 100644
--- a/compiler/debug/elf_debug_frame_writer.h
+++ b/compiler/debug/elf_debug_frame_writer.h
@@ -29,8 +29,6 @@
namespace art {
namespace debug {
-static constexpr bool kWriteDebugFrameHdr = false;
-
static void WriteCIE(InstructionSet isa, /*inout*/ std::vector<uint8_t>* buffer) {
using Reg = dwarf::Reg;
// Scratch registers should be marked as undefined. This tells the
@@ -196,9 +194,7 @@
});
std::vector<uint32_t> binary_search_table;
- if (kWriteDebugFrameHdr) {
- binary_search_table.reserve(2 * sorted_method_infos.size());
- }
+ binary_search_table.reserve(2 * sorted_method_infos.size());
// Write .debug_frame section.
auto* cfi_section = builder->GetDebugFrame();
@@ -214,10 +210,8 @@
DCHECK(!mi->cfi.empty());
const Elf_Addr code_address = mi->code_address +
(mi->is_code_address_text_relative ? builder->GetText()->GetAddress() : 0);
- if (kWriteDebugFrameHdr) {
- binary_search_table.push_back(dchecked_integral_cast<uint32_t>(code_address));
- binary_search_table.push_back(cfi_section->GetPosition());
- }
+ binary_search_table.push_back(dchecked_integral_cast<uint32_t>(code_address));
+ binary_search_table.push_back(cfi_section->GetPosition());
dwarf::WriteFDE(is64bit,
/* cie_pointer= */ 0,
code_address,
@@ -230,7 +224,10 @@
cfi_section->End();
}
- if (kWriteDebugFrameHdr) {
+ if (method_infos.size() > 1) {
+ std::sort(binary_search_table.begin(), binary_search_table.end());
+
+ // Custom Android section. It is very similar to the official .eh_frame_hdr format.
std::vector<uint8_t> header_buffer;
dwarf::Writer<> header(&header_buffer);
header.PushUint8(1); // Version.