Skip to content

Commit 27b5838

Browse files
committed
Remove old safe access handler
1 parent dce4c5f commit 27b5838

2 files changed

Lines changed: 0 additions & 63 deletions

File tree

ddprof-lib/src/main/cpp/profiler.cpp

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -886,28 +886,6 @@ bool Profiler::crashHandler(int signo, siginfo_t *siginfo, void *ucontext) {
886886
return false;
887887
}
888888

889-
uintptr_t length = SafeAccess::skipLoad(pc);
890-
if (length > 0) {
891-
// Skip the fault instruction, as if it successfully loaded NULL
892-
frame.pc() += length;
893-
frame.retval() = 0;
894-
if (thrd != nullptr) {
895-
thrd->exitCrashHandler();
896-
}
897-
return true;
898-
}
899-
900-
length = SafeAccess::skipLoadArg(pc);
901-
if (length > 0) {
902-
// Act as if the load returned default_value argument
903-
frame.pc() += length;
904-
frame.retval() = frame.arg1();
905-
if (thrd != nullptr) {
906-
thrd->exitCrashHandler();
907-
}
908-
return true;
909-
}
910-
911889
if (WX_MEMORY && Trap::isFaultInstruction(pc)) {
912890
if (thrd != nullptr) {
913891
thrd->exitCrashHandler();

ddprof-lib/src/main/cpp/safeAccess.h

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -64,47 +64,6 @@ class SafeAccess {
6464
#endif
6565
return *ptr;
6666
}
67-
68-
NOADDRSANITIZE static uintptr_t skipLoad(uintptr_t pc) {
69-
if (pc - (uintptr_t)load < sizeSafeLoadFunc) {
70-
#if defined(__x86_64__)
71-
return *(u16 *)pc == 0x8b48 ? 3 : 0; // mov rax, [reg]
72-
#elif defined(__i386__)
73-
return *(u8 *)pc == 0x8b ? 2 : 0; // mov eax, [reg]
74-
#elif defined(__arm__) || defined(__thumb__)
75-
return (*(instruction_t *)pc & 0x0e50f000) == 0x04100000
76-
? 4
77-
: 0; // ldr r0, [reg]
78-
#elif defined(__aarch64__)
79-
return (*(instruction_t *)pc & 0xffc0001f) == 0xf9400000
80-
? 4
81-
: 0; // ldr x0, [reg]
82-
#else
83-
return sizeof(instruction_t);
84-
#endif
85-
}
86-
return 0;
87-
}
88-
89-
static uintptr_t skipLoadArg(uintptr_t pc) {
90-
#if defined(__aarch64__)
91-
if ((pc - (uintptr_t)load32) < sizeSafeLoadFunc ||
92-
(pc - (uintptr_t)loadPtr) < sizeSafeLoadFunc) {
93-
return 4;
94-
}
95-
#endif
96-
return 0;
97-
}
98-
#ifndef __SANITIZE_ADDRESS__
99-
constexpr static size_t sizeSafeLoadFunc = 16;
100-
#else
101-
// asan significantly increases the size of the load function
102-
// checking disassembled code can help adjust the value
103-
// gdb --batch -ex 'disas _ZN10SafeAccess4loadEPPv' ./elfparser_ut
104-
// I see that the functions can also have a 156 bytes size for the load32
105-
// and 136 for the loadPtr functions
106-
constexpr static inline size_t sizeSafeLoadFunc = 132;
107-
#endif
10867
};
10968

11069
#endif // _SAFEACCESS_H

0 commit comments

Comments
 (0)