Relocate DWARF using .oat_patches.
The current solution is to hard-code knowledge of DWARF in the linker.
This works for simple use of DWARF, but breaks as soon as I try to do
anything more complex. Making the linker fully support DWARF would be
non-trivial task and would be essentially rewrite. Using .oat_patches
is much easier solution.
Relocating .debug_* sections required extending .oat_patches to support
more sections than just .text. I have encoded each section as
null-terminated section name followed by ULEB128 deltas.
The ULEB128 encoding shrinks .oat_patches for .text by factor of
about 6 with 64-bit compiler, and factor of 3 with 32-bit compiler.
On the other hand, it grows by the extra .oat_patches for DWARF which
were not present before (if debug symbols are included).
Overall, it is still a clear improvement even with the DWARF patches.
Change-Id: I78ffeda0f8a3da03341995a3b5ef15c954e16e9f
diff --git a/runtime/elf_file_impl.h b/runtime/elf_file_impl.h
index 16d3857..383dc41 100644
--- a/runtime/elf_file_impl.h
+++ b/runtime/elf_file_impl.h
@@ -110,6 +110,12 @@
bool FixupSymbols(Elf_Addr base_address, bool dynamic);
bool FixupRelocations(Elf_Addr base_address);
bool FixupDebugSections(typename std::make_signed<Elf_Off>::type base_address_delta);
+ bool ApplyOatPatchesTo(const char* target_section_name,
+ typename std::make_signed<Elf_Off>::type base_address_delta);
+ static bool ApplyOatPatches(const uint8_t* patches, const uint8_t* patches_end,
+ const char* target_section_name,
+ typename std::make_signed<Elf_Off>::type delta,
+ uint8_t* to_patch, const uint8_t* to_patch_end);
bool Strip(std::string* error_msg);