unwind: Skip Mapping Symbols on ARM

ARM documentation for Mapping Symbols:
https://developer.arm.com/documentation/dui0803/a/Accessing-and-managing-symbols-with-armlink/About-mapping-symbols

PiperOrigin-RevId: 491836684
Change-Id: I2e259e66f2253d80902aa763f2637f3f6fdea414
This commit is contained in:
Wiktor Garbacz 2022-11-30 00:16:02 -08:00 committed by Copybara-Service
parent 755f29b35e
commit 77c80b7213
3 changed files with 16 additions and 0 deletions

View File

@ -57,6 +57,7 @@ cc_library(
deps = [ deps = [
":ptrace_hook", ":ptrace_hook",
":unwind_cc_proto", ":unwind_cc_proto",
"//sandboxed_api:config",
"//sandboxed_api/sandbox2:comms", "//sandboxed_api/sandbox2:comms",
"//sandboxed_api/sandbox2/util:maps_parser", "//sandboxed_api/sandbox2/util:maps_parser",
"//sandboxed_api/sandbox2/util:minielf", "//sandboxed_api/sandbox2/util:minielf",

View File

@ -40,6 +40,7 @@ target_link_libraries(sandbox2_unwind PRIVATE
sapi::strerror sapi::strerror
sandbox2::unwind_proto sandbox2::unwind_proto
sapi::base sapi::base
sapi::config
sapi::file_helpers sapi::file_helpers
sapi::raw_logging sapi::raw_logging
sapi::status sapi::status

View File

@ -30,6 +30,7 @@
#include "absl/strings/match.h" #include "absl/strings/match.h"
#include "absl/strings/str_cat.h" #include "absl/strings/str_cat.h"
#include "libunwind-ptrace.h" #include "libunwind-ptrace.h"
#include "sandboxed_api/config.h"
#include "sandboxed_api/sandbox2/comms.h" #include "sandboxed_api/sandbox2/comms.h"
#include "sandboxed_api/sandbox2/unwind/ptrace_hook.h" #include "sandboxed_api/sandbox2/unwind/ptrace_hook.h"
#include "sandboxed_api/sandbox2/unwind/unwind.pb.h" #include "sandboxed_api/sandbox2/unwind/unwind.pb.h"
@ -171,6 +172,19 @@ absl::StatusOr<SymbolMap> LoadSymbolsMap(pid_t pid) {
} }
for (const ElfFile::Symbol& symbol : elf->symbols()) { for (const ElfFile::Symbol& symbol : elf->symbols()) {
// Skip Mapping Symbols on ARM
// ARM documentation for Mapping Symbols:
// https://developer.arm.com/documentation/dui0803/a/Accessing-and-managing-symbols-with-armlink/About-mapping-symbols
if constexpr (sapi::host_cpu::IsArm64() || sapi::host_cpu::IsArm()) {
if (absl::StartsWith(symbol.name, "$x") ||
absl::StartsWith(symbol.name, "$d") ||
absl::StartsWith(symbol.name, "$t") ||
absl::StartsWith(symbol.name, "$a") ||
absl::StartsWith(symbol.name, "$v")) {
continue;
}
}
if (elf->position_independent()) { if (elf->position_independent()) {
if (symbol.address >= entry.pgoff && if (symbol.address >= entry.pgoff &&
symbol.address - entry.pgoff < entry.end - entry.start) { symbol.address - entry.pgoff < entry.end - entry.start) {