[llvm] r263787 - [Fuzzer] Guard no_sanitize_memory attributes behind __has_feature.

Kostya Serebryany via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 18 10:07:14 PDT 2016


Thanks!
Just curious, in where you were building libFuzzer with GCC?
In the LLVM cmake the libFuzzer build is guarded by
-DLLVM_USE_SANITIZE_COVERAGE=YES which only works with clang.

On Fri, Mar 18, 2016 at 7:19 AM, Benjamin Kramer via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> Author: d0k
> Date: Fri Mar 18 09:19:19 2016
> New Revision: 263787
>
> URL: http://llvm.org/viewvc/llvm-project?rev=263787&view=rev
> Log:
> [Fuzzer] Guard no_sanitize_memory attributes behind __has_feature.
>
> Otherwise GCC fails to build it because it doesn't know the attribute.
>
> Modified:
>     llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp
>
> Modified: llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp?rev=263787&r1=263786&r2=263787&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp (original)
> +++ llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp Fri Mar 18 09:19:19 2016
> @@ -20,6 +20,14 @@
>  #endif
>  #endif
>
> +#define NO_SANITIZE_MEMORY
> +#if defined(__has_feature)
> +#if __has_feature(memory_sanitizer)
> +#undef NO_SANITIZE_MEMORY
> +#define NO_SANITIZE_MEMORY __attribute__((no_sanitize_memory))
> +#endif
> +#endif
> +
>  extern "C" {
>  // Re-declare some of the sanitizer functions as "weak" so that
>  // libFuzzer can be linked w/o the sanitizers and sanitizer-coverage
> @@ -92,7 +100,7 @@ void Fuzzer::DumpCurrentUnit(const char
>        {CurrentUnitData, CurrentUnitData + CurrentUnitSize}, Prefix);
>  }
>
> -__attribute__((no_sanitize_memory))
> +NO_SANITIZE_MEMORY
>  void Fuzzer::DeathCallback() {
>    if (!CurrentUnitSize) return;
>    Printf("DEATH:\n");
> @@ -134,7 +142,7 @@ void Fuzzer::InterruptCallback() {
>    _Exit(0);  // Stop right now, don't perform any at-exit actions.
>  }
>
> -__attribute__((no_sanitize_memory))
> +NO_SANITIZE_MEMORY
>  void Fuzzer::AlarmCallback() {
>    assert(Options.UnitTimeoutSec > 0);
>    if (!CurrentUnitSize)
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160318/160cc14c/attachment.html>


More information about the llvm-commits mailing list