Add load base to map for relocation packing.
The new linker relocation packing support uses non-zero load bases, so we better handle them properly. Also print out the load base for a map if it's non-zero. Bug: 20687795 Change-Id: Iec2d1db2051e7b4a278c1dfa57d745128a7f2974
This commit is contained in:
parent
f1a58f8f33
commit
329ed7dae4
|
@ -379,6 +379,9 @@ static void dump_all_maps(Backtrace* backtrace, BacktraceMap* map, log_t* log, p
|
|||
line += " (BuildId: " + build_id + ")";
|
||||
}
|
||||
}
|
||||
if (it->load_base != 0) {
|
||||
line += android::base::StringPrintf(" (load base 0x%" PRIxPTR ")", it->load_base);
|
||||
}
|
||||
_LOG(log, logtype::MAPS, "%s\n", line.c_str());
|
||||
}
|
||||
if (print_fault_address_marker) {
|
||||
|
|
|
@ -37,6 +37,7 @@ struct backtrace_map_t {
|
|||
|
||||
uintptr_t start;
|
||||
uintptr_t end;
|
||||
uintptr_t load_base;
|
||||
int flags;
|
||||
std::string name;
|
||||
};
|
||||
|
@ -82,6 +83,14 @@ public:
|
|||
return map.end > 0;
|
||||
}
|
||||
|
||||
static uintptr_t GetRelativePc(const backtrace_map_t& map, uintptr_t pc) {
|
||||
if (IsValid(map)) {
|
||||
return pc - map.start + map.load_base;
|
||||
} else {
|
||||
return pc;
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
BacktraceMap(pid_t pid);
|
||||
|
||||
|
|
|
@ -97,12 +97,7 @@ std::string Backtrace::FormatFrameData(const backtrace_frame_data_t* frame) {
|
|||
map_name = "<unknown>";
|
||||
}
|
||||
|
||||
uintptr_t relative_pc;
|
||||
if (BacktraceMap::IsValid(frame->map)) {
|
||||
relative_pc = frame->pc - frame->map.start;
|
||||
} else {
|
||||
relative_pc = frame->pc;
|
||||
}
|
||||
uintptr_t relative_pc = BacktraceMap::GetRelativePc(frame->map, frame->pc);
|
||||
|
||||
std::string line(StringPrintf("#%02zu pc %" PRIPTR " %s", frame->num, relative_pc, map_name));
|
||||
if (!frame->func_name.empty()) {
|
||||
|
|
|
@ -51,6 +51,7 @@ bool UnwindMap::GenerateMap() {
|
|||
|
||||
map.start = unw_map.start;
|
||||
map.end = unw_map.end;
|
||||
map.load_base = unw_map.load_base;
|
||||
map.flags = unw_map.flags;
|
||||
map.name = unw_map.path;
|
||||
|
||||
|
@ -91,6 +92,7 @@ bool UnwindMapLocal::GenerateMap() {
|
|||
|
||||
map.start = unw_map.start;
|
||||
map.end = unw_map.end;
|
||||
map.load_base = unw_map.load_base;
|
||||
map.flags = unw_map.flags;
|
||||
map.name = unw_map.path;
|
||||
|
||||
|
|
|
@ -771,6 +771,7 @@ TEST(libbacktrace, format_test) {
|
|||
// Check map name empty, but exists.
|
||||
frame.map.start = 1;
|
||||
frame.map.end = 1;
|
||||
frame.map.load_base = 0;
|
||||
#if defined(__LP64__)
|
||||
EXPECT_EQ("#01 pc 0000000000000001 <unknown>",
|
||||
#else
|
||||
|
@ -806,6 +807,16 @@ TEST(libbacktrace, format_test) {
|
|||
EXPECT_EQ("#01 pc 0000000012345678 MapFake (ProcFake+645)",
|
||||
#else
|
||||
EXPECT_EQ("#01 pc 12345678 MapFake (ProcFake+645)",
|
||||
#endif
|
||||
backtrace->FormatFrameData(&frame));
|
||||
|
||||
// Check func_name is set, func offset is non-zero, and load_base is non-zero.
|
||||
frame.func_offset = 645;
|
||||
frame.map.load_base = 100;
|
||||
#if defined(__LP64__)
|
||||
EXPECT_EQ("#01 pc 00000000123456dc MapFake (ProcFake+645)",
|
||||
#else
|
||||
EXPECT_EQ("#01 pc 123456dc MapFake (ProcFake+645)",
|
||||
#endif
|
||||
backtrace->FormatFrameData(&frame));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue