[compiler-rt] r344985 - [hwasan] add stack frame descriptions.
Kostya Serebryany via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 22 17:50:40 PDT 2018
Author: kcc
Date: Mon Oct 22 17:50:40 2018
New Revision: 344985
URL: http://llvm.org/viewvc/llvm-project?rev=344985&view=rev
Log:
[hwasan] add stack frame descriptions.
Summary:
At compile-time, create an array of {PC,HumanReadableStackFrameDescription}
for every function that has an instrumented frame, and pass this array
to the run-time at the module-init time.
Similar to how we handle pc-table in SanitizerCoverage.
The run-time is dummy, will add the actual logic in later commits.
Reviewers: morehouse, eugenis
Reviewed By: eugenis
Subscribers: srhines, llvm-commits, kubamracek
Differential Revision: https://reviews.llvm.org/D53227
Modified:
compiler-rt/trunk/lib/hwasan/hwasan.cc
compiler-rt/trunk/lib/hwasan/hwasan_interface_internal.h
Modified: compiler-rt/trunk/lib/hwasan/hwasan.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/hwasan/hwasan.cc?rev=344985&r1=344984&r2=344985&view=diff
==============================================================================
--- compiler-rt/trunk/lib/hwasan/hwasan.cc (original)
+++ compiler-rt/trunk/lib/hwasan/hwasan.cc Mon Oct 22 17:50:40 2018
@@ -220,6 +220,22 @@ void UpdateMemoryUsage() {
void UpdateMemoryUsage() {}
#endif
+struct FrameDescription {
+ uptr PC;
+ const char *Descr;
+};
+
+void InitFrameDescriptors(uptr b, uptr e) {
+ FrameDescription *beg = reinterpret_cast<FrameDescription *>(b);
+ FrameDescription *end = reinterpret_cast<FrameDescription *>(e);
+ // Must have at least one entry, which we can use for a linked list.
+ CHECK_GE(end - beg, 1U);
+ if (Verbosity()) {
+ for (FrameDescription *frame_descr = beg; frame_descr < end; frame_descr++)
+ Printf("Frame: %p %s\n", frame_descr->PC, frame_descr->Descr);
+ }
+}
+
} // namespace __hwasan
// Interface.
@@ -238,6 +254,10 @@ void __hwasan_shadow_init() {
hwasan_shadow_inited = 1;
}
+void __hwasan_init_frames(uptr beg, uptr end) {
+ InitFrameDescriptors(beg, end);
+}
+
void __hwasan_init() {
CHECK(!hwasan_init_is_running);
if (hwasan_inited) return;
Modified: compiler-rt/trunk/lib/hwasan/hwasan_interface_internal.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/hwasan/hwasan_interface_internal.h?rev=344985&r1=344984&r2=344985&view=diff
==============================================================================
--- compiler-rt/trunk/lib/hwasan/hwasan_interface_internal.h (original)
+++ compiler-rt/trunk/lib/hwasan/hwasan_interface_internal.h Mon Oct 22 17:50:40 2018
@@ -37,6 +37,9 @@ using __sanitizer::u16;
using __sanitizer::u8;
SANITIZER_INTERFACE_ATTRIBUTE
+void __hwasan_init_frames(uptr, uptr);
+
+SANITIZER_INTERFACE_ATTRIBUTE
extern uptr __hwasan_shadow_memory_dynamic_address;
SANITIZER_INTERFACE_ATTRIBUTE
More information about the llvm-commits
mailing list