summaryrefslogtreecommitdiffstats
path: root/compiler-rt
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2018-10-23 00:50:40 +0000
committerKostya Serebryany <kcc@google.com>2018-10-23 00:50:40 +0000
commitaf95597c3c9ecf18a9e66e6a403daf6dc3dd597f (patch)
tree788c11dd2645ffa523611aa3d77d0788bd9cc170 /compiler-rt
parent9d7de097d4f89912e01032bd619b8a8e97cb9376 (diff)
downloadbcm5719-llvm-af95597c3c9ecf18a9e66e6a403daf6dc3dd597f.tar.gz
bcm5719-llvm-af95597c3c9ecf18a9e66e6a403daf6dc3dd597f.zip
[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 llvm-svn: 344985
Diffstat (limited to 'compiler-rt')
-rw-r--r--compiler-rt/lib/hwasan/hwasan.cc20
-rw-r--r--compiler-rt/lib/hwasan/hwasan_interface_internal.h3
2 files changed, 23 insertions, 0 deletions
diff --git a/compiler-rt/lib/hwasan/hwasan.cc b/compiler-rt/lib/hwasan/hwasan.cc
index 02aee4d61c6..518cd11ff30 100644
--- a/compiler-rt/lib/hwasan/hwasan.cc
+++ b/compiler-rt/lib/hwasan/hwasan.cc
@@ -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;
diff --git a/compiler-rt/lib/hwasan/hwasan_interface_internal.h b/compiler-rt/lib/hwasan/hwasan_interface_internal.h
index 448997e5e88..0e49a3fc267 100644
--- a/compiler-rt/lib/hwasan/hwasan_interface_internal.h
+++ b/compiler-rt/lib/hwasan/hwasan_interface_internal.h
@@ -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
OpenPOWER on IntegriCloud