aboutsummaryrefslogtreecommitdiff
path: root/compiler-rt
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2020-01-17 20:27:24 +0000
committerDimitry Andric <dim@FreeBSD.org>2020-01-17 20:27:24 +0000
commit7cc9cf2bf09f069cb2dd947ead05d0b54301fb71 (patch)
tree2bac2b35d5d597aa34805cb4b4b2644599b58f6a /compiler-rt
parentc80d8fac37703ecdd2c24b90267e62ce8e9b4ea5 (diff)
Notes
Diffstat (limited to 'compiler-rt')
-rwxr-xr-xcompiler-rt/lib/gwp_asan/scripts/symbolize.sh55
-rw-r--r--compiler-rt/tools/CMakeLists.txt1
-rw-r--r--compiler-rt/tools/gwp_asan/CMakeLists.txt20
-rw-r--r--compiler-rt/tools/gwp_asan/stack_trace_compressor_fuzzer.cpp49
4 files changed, 0 insertions, 125 deletions
diff --git a/compiler-rt/lib/gwp_asan/scripts/symbolize.sh b/compiler-rt/lib/gwp_asan/scripts/symbolize.sh
deleted file mode 100755
index fad9620a676e..000000000000
--- a/compiler-rt/lib/gwp_asan/scripts/symbolize.sh
+++ /dev/null
@@ -1,55 +0,0 @@
-#!/bin/bash
-
-# The lines that we're looking to symbolize look like this:
- #0 ./a.out(_foo+0x3e6) [0x55a52e64c696]
-# ... which come from the backtrace_symbols() symbolisation function used by
-# default in Scudo's implementation of GWP-ASan.
-
-while read -r line; do
- # Check that this line needs symbolization.
- should_symbolize="$(echo $line |\
- grep -E '^[ ]*\#.*\(.*\+0x[0-9a-f]+\) \[0x[0-9a-f]+\]$')"
-
- if [ -z "$should_symbolize" ]; then
- echo "$line"
- continue
- fi
-
- # Carve up the input line into sections.
- binary_name="$(echo $line | grep -oE ' .*\(' | rev | cut -c2- | rev |\
- cut -c2-)"
- function_name="$(echo $line | grep -oE '\([^+]*' | cut -c2-)"
- function_offset="$(echo $line | grep -oE '\(.*\)' | grep -oE '\+.*\)' |\
- cut -c2- | rev | cut -c2- | rev)"
- frame_number="$(echo $line | grep -oE '\#[0-9]+ ')"
-
- if [ -z "$function_name" ]; then
- # If the offset is binary-relative, just resolve that.
- symbolized="$(echo $function_offset | addr2line -e $binary_name)"
- else
- # Otherwise, the offset is function-relative. Get the address of the
- # function, and add it to the offset, then symbolize.
- function_addr="0x$(echo $function_offset |\
- nm --defined-only $binary_name 2> /dev/null |\
- grep -E " $function_name$" | cut -d' ' -f1)"
-
- # Check that we could get the function address from nm.
- if [ -z "$function_addr" ]; then
- echo "$line"
- continue
- fi
-
- # Add the function address and offset to get the offset into the binary.
- binary_offset="$(printf "0x%X" "$((function_addr+function_offset))")"
- symbolized="$(echo $binary_offset | addr2line -e $binary_name)"
- fi
-
- # Check that it symbolized properly. If it didn't, output the old line.
- echo $symbolized | grep -E ".*\?.*:" > /dev/null
- if [ "$?" -eq "0" ]; then
- echo "$line"
- continue
- else
- echo "${frame_number}${symbolized}"
- fi
-done
diff --git a/compiler-rt/tools/CMakeLists.txt b/compiler-rt/tools/CMakeLists.txt
deleted file mode 100644
index aa4aff34b1bb..000000000000
--- a/compiler-rt/tools/CMakeLists.txt
+++ /dev/null
@@ -1 +0,0 @@
-add_subdirectory(gwp_asan)
diff --git a/compiler-rt/tools/gwp_asan/CMakeLists.txt b/compiler-rt/tools/gwp_asan/CMakeLists.txt
deleted file mode 100644
index b0f9f0cf9e5d..000000000000
--- a/compiler-rt/tools/gwp_asan/CMakeLists.txt
+++ /dev/null
@@ -1,20 +0,0 @@
-# Build the stack trace compressor fuzzer. This will require Clang >= 6.0.0, as
-# -fsanitize=fuzzer-no-link was not a valid command line flag prior to this.
-if (LLVM_USE_SANITIZE_COVERAGE)
- add_executable(stack_trace_compressor_fuzzer
- ../../lib/gwp_asan/stack_trace_compressor.cpp
- ../../lib/gwp_asan/stack_trace_compressor.h
- stack_trace_compressor_fuzzer.cpp)
- set_target_properties(
- stack_trace_compressor_fuzzer PROPERTIES FOLDER "Fuzzers")
- target_compile_options(
- stack_trace_compressor_fuzzer PRIVATE -fsanitize=fuzzer-no-link)
- set_target_properties(
- stack_trace_compressor_fuzzer PROPERTIES LINK_FLAGS -fsanitize=fuzzer)
- target_include_directories(
- stack_trace_compressor_fuzzer PRIVATE ../../lib/)
-
- if (TARGET gwp_asan)
- add_dependencies(gwp_asan stack_trace_compressor_fuzzer)
- endif()
-endif()
diff --git a/compiler-rt/tools/gwp_asan/stack_trace_compressor_fuzzer.cpp b/compiler-rt/tools/gwp_asan/stack_trace_compressor_fuzzer.cpp
deleted file mode 100644
index aa57fdaff636..000000000000
--- a/compiler-rt/tools/gwp_asan/stack_trace_compressor_fuzzer.cpp
+++ /dev/null
@@ -1,49 +0,0 @@
-#include <cstddef>
-#include <cstdint>
-#include <cstdio>
-#include <cstdlib>
-#include <vector>
-
-#include "gwp_asan/stack_trace_compressor.h"
-
-constexpr size_t kBytesForLargestVarInt = (sizeof(uintptr_t) * 8) / 7 + 1;
-
-extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
- size_t BufferSize = kBytesForLargestVarInt * Size / sizeof(uintptr_t);
- std::vector<uint8_t> Buffer(BufferSize);
- std::vector<uint8_t> Buffer2(BufferSize);
-
- // Unpack the fuzz bytes.
- gwp_asan::compression::unpack(Data, Size,
- reinterpret_cast<uintptr_t *>(Buffer2.data()),
- BufferSize / sizeof(uintptr_t));
-
- // Pack the fuzz bytes.
- size_t BytesWritten = gwp_asan::compression::pack(
- reinterpret_cast<const uintptr_t *>(Data), Size / sizeof(uintptr_t),
- Buffer.data(), BufferSize);
-
- // Unpack the compressed buffer.
- size_t DecodedElements = gwp_asan::compression::unpack(
- Buffer.data(), BytesWritten,
- reinterpret_cast<uintptr_t *>(Buffer2.data()),
- BufferSize / sizeof(uintptr_t));
-
- // Ensure that every element was encoded and decoded properly.
- if (DecodedElements != Size / sizeof(uintptr_t))
- abort();
-
- // Ensure that the compression and uncompression resulted in the same trace.
- const uintptr_t *FuzzPtrs = reinterpret_cast<const uintptr_t *>(Data);
- const uintptr_t *DecodedPtrs =
- reinterpret_cast<const uintptr_t *>(Buffer2.data());
- for (size_t i = 0; i < Size / sizeof(uintptr_t); ++i) {
- if (FuzzPtrs[i] != DecodedPtrs[i]) {
- fprintf(stderr, "FuzzPtrs[%zu] != DecodedPtrs[%zu] (0x%zx vs. 0x%zx)", i,
- i, FuzzPtrs[i], DecodedPtrs[i]);
- abort();
- }
- }
-
- return 0;
-}