[PATCH] D66568: [GWP-ASan] Remove c++ standard lib dependency.
Petr Hosek via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 21 17:21:53 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL369606: [GWP-ASan] Remove c++ standard lib dependency. (authored by phosek, committed by ).
Herald added a subscriber: delcypher.
Changed prior to commit:
https://reviews.llvm.org/D66568?vs=216527&id=216531#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D66568/new/
https://reviews.llvm.org/D66568
Files:
compiler-rt/trunk/lib/gwp_asan/CMakeLists.txt
compiler-rt/trunk/lib/gwp_asan/stack_trace_compressor_fuzzer.cpp
Index: compiler-rt/trunk/lib/gwp_asan/CMakeLists.txt
===================================================================
--- compiler-rt/trunk/lib/gwp_asan/CMakeLists.txt
+++ compiler-rt/trunk/lib/gwp_asan/CMakeLists.txt
@@ -108,8 +108,11 @@
${GWP_ASAN_HEADERS})
set_target_properties(
stack_trace_compressor_fuzzer PROPERTIES FOLDER "Fuzzers")
- target_compile_options(
- stack_trace_compressor_fuzzer PRIVATE -fsanitize=fuzzer-no-link)
+
+ # TODO(phosek): Remove -nostdlib++ and remove the "no c++ standard library
+ # for compiler-rt" dependency here.
+ target_compile_options(stack_trace_compressor_fuzzer
+ PRIVATE -nostdlib++ -fsanitize=fuzzer-no-link)
set_target_properties(
stack_trace_compressor_fuzzer PROPERTIES LINK_FLAGS -fsanitize=fuzzer)
add_dependencies(stack_trace_compressor_fuzzer fuzzer)
Index: compiler-rt/trunk/lib/gwp_asan/stack_trace_compressor_fuzzer.cpp
===================================================================
--- compiler-rt/trunk/lib/gwp_asan/stack_trace_compressor_fuzzer.cpp
+++ compiler-rt/trunk/lib/gwp_asan/stack_trace_compressor_fuzzer.cpp
@@ -1,8 +1,7 @@
-#include <cstddef>
-#include <cstdint>
-#include <cstdio>
-#include <cstdlib>
-#include <vector>
+#include <stddef.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
#include "gwp_asan/stack_trace_compressor.h"
@@ -10,23 +9,22 @@
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);
+ uint8_t *Buffer = reinterpret_cast<uint8_t *>(malloc(BufferSize));
+ uint8_t *Buffer2 = reinterpret_cast<uint8_t *>(malloc(BufferSize));
// Unpack the fuzz bytes.
gwp_asan::compression::unpack(Data, Size,
- reinterpret_cast<uintptr_t *>(Buffer2.data()),
+ reinterpret_cast<uintptr_t *>(Buffer2),
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);
+ size_t BytesWritten =
+ gwp_asan::compression::pack(reinterpret_cast<const uintptr_t *>(Data),
+ Size / sizeof(uintptr_t), Buffer, BufferSize);
// Unpack the compressed buffer.
size_t DecodedElements = gwp_asan::compression::unpack(
- Buffer.data(), BytesWritten,
- reinterpret_cast<uintptr_t *>(Buffer2.data()),
+ Buffer, BytesWritten, reinterpret_cast<uintptr_t *>(Buffer2),
BufferSize / sizeof(uintptr_t));
// Ensure that every element was encoded and decoded properly.
@@ -35,8 +33,7 @@
// 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());
+ const uintptr_t *DecodedPtrs = reinterpret_cast<const uintptr_t *>(Buffer2);
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,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D66568.216531.patch
Type: text/x-patch
Size: 3369 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190822/4a562f7c/attachment.bin>
More information about the llvm-commits
mailing list