 +// The code assumes that the main binary is the the first one to be iterated on.
 +int dl_iterate_phdr_callback(struct dl_phdr_info *info, size_t size,
 +                                    void *data) {
-+//  PrintErrorAndExitIf(main_object_start_address != kInvalidStartAddress,
-+//                      "main_object_start_address is already set");
-+//  fuzzer::Printf("[INIT] main_object_start_address: %lu\n", main_object_start_address);
-+//  fuzzer::Printf("[INIT] main_object_size         : %lu\n", main_object_size);
 +  main_object_start_address = info->dlpi_addr;
-+//  fuzzer::Printf("[UPDT] main_object_start_address: %lu\n", main_object_start_address);
 +  for (int j = 0; j < info->dlpi_phnum; j++) {
 +    uintptr_t end_offset =
 +        info->dlpi_phdr[j].p_vaddr + info->dlpi_phdr[j].p_memsz;
 +    if (main_object_size < end_offset) main_object_size = end_offset;
-+//    fuzzer::Printf("[UPDT] main_object_size         : %lu\n", main_object_size);
 +  }
-+//  fuzzer::Printf("[FINL] main_object_start_address: %lu\n", main_object_start_address);
-+//  fuzzer::Printf("[FINL] main_object_size         : %lu\n", main_object_size);
-+//  uintptr_t some_code_address =
-+//      reinterpret_cast<uintptr_t>(&dl_iterate_phdr_callback);
-+//  PrintErrorAndExitIf(main_object_start_address > some_code_address,
-+//                      "main_object_start_address is above the code");
-+//  PrintErrorAndExitIf(
-+//      main_object_start_address + main_object_size < some_code_address,
-+//      "main_object_start_address + main_object_size is below the code");
 +  return 1;  // we need only the first header, so return 1.
 +}
 +

+  uintptr_t StoreAddr = reinterpret_cast<uintptr_t>(Addr);
+  uintptr_t PCOffset = PC - main_object_start_address;
+  uintptr_t StoreOffset = StoreAddr - main_object_start_address;
+//
+//  fuzzer::Printf("[TraceStore] PC                       : %lu\n", PCOffset);
+//  fuzzer::Printf("[TraceStore] StoreAddr                : %lu\n", StoreAddr);
+//  fuzzer::Printf("[TraceStore] main_object_start_address: %lu\n",
+//    main_object_start_address);
+//  fuzzer::Printf("[TraceStore] PCOffset                 : %lu\n", PCOffset);
+//  fuzzer::Printf("[TraceStore] StoreOffset              : %lu\n", StoreOffset);
+//  fuzzer::Printf("[TraceStore] main_object_size         : %lu\n", main_object_size);
+
+  if (PCOffset >= main_object_size) return;
+  if (StoreOffset >= main_object_size) return;

 
 extern "C" {
 // This function should be defined by the user.
diff --git a/compiler-rt/lib/fuzzer/FuzzerTracePC.cpp b/compiler-rt/lib/fuzzer/FuzzerTracePC.cpp
index f12f7aa61bc4..c45178254383 100644
--- a/compiler-rt/lib/fuzzer/FuzzerTracePC.cpp
+++ b/compiler-rt/lib/fuzzer/FuzzerTracePC.cpp
@@ -27,6 +27,14 @@
