From a0add2c099683dcfc16d3b67c6c1c438c36c2ce7 Mon Sep 17 00:00:00 2001 From: simonb Date: Fri, 5 Jun 2015 06:22:56 -0700 Subject: [PATCH] crazy linker: Fix incorrect link map l_addr value. Link map's l_addr field should contain the load bias: - https://android-review.googlesource.com/#/c/46470/2/linker/linker.cpp It currently contains the load address. Where the min vaddr of LOAD segments is zero, the load address and load bias are the same, and the problem remains hidden. Android's relocation packer generates a non-zero min vaddr, and this exposes the problem on arm64 platforms. The symptom is abort in uw_init_context_1, where uw_frame_state_for returns _URC_END_OF_STACK rather than (expected) _URC_NO_REASON. gcc's stack unwinding code does not find correct unwinding information after an incorrect l_addr has been used to convert from virtual to physical addresses. Arm32 does not show the problem because it uses dl_unwind_find_exidx in place of _Unwind_IteratePhdrCallback. See also line 196 of: - https://android.googlesource.com/platform/bionic/+/ lollipop-mr1-release/linker/linker.cpp BUG=385553 Review URL: https://codereview.chromium.org/1155973005 Cr-Commit-Position: refs/heads/master@{#333040} --- third_party/android_crazy_linker/README.chromium | 2 ++ third_party/android_crazy_linker/src/src/crazy_linker_library_list.cpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/third_party/android_crazy_linker/README.chromium b/third_party/android_crazy_linker/README.chromium index fa9158e2d34d..655c0696e57b 100644 --- a/third_party/android_crazy_linker/README.chromium +++ b/third_party/android_crazy_linker/README.chromium @@ -76,3 +76,5 @@ Local Modifications: - Correct fix for crbug/479220 (replace IsSystemLibrary() with caller flags). +- Fix link_map_.l_addr (was load address, should be load bias). + diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_library_list.cpp b/third_party/android_crazy_linker/src/src/crazy_linker_library_list.cpp index f4acadbac34f..0bc3689d0dbf 100644 --- a/third_party/android_crazy_linker/src/src/crazy_linker_library_list.cpp +++ b/third_party/android_crazy_linker/src/src/crazy_linker_library_list.cpp @@ -431,7 +431,7 @@ LibraryView* LibraryList::LoadLibrary(const char* lib_name, return NULL; // Notify GDB of load. - lib->link_map_.l_addr = lib->load_address(); + lib->link_map_.l_addr = lib->load_bias(); lib->link_map_.l_name = const_cast(lib->base_name_); lib->link_map_.l_ld = reinterpret_cast(lib->view_.dynamic()); Globals::GetRDebug()->AddEntry(&lib->link_map_); -- 2.11.4.GIT