在macOS上找不到针对架构x86_64的libfuzzer

我正在尝试在macOS 10.14.6和CLion 2019.2.5上编译一个简单的模糊测试示例

#include <stdint.h>
#include <stddef.h>

extern "C" int LLVMfuzzerTestOneInput(const uint8_t *data,size_t size) {
    if (size > 0 && data[0] == 'H')
        if (size > 1 && data[1] == 'I')
            if (size > 2 && data[2] == '!')
                __builtin_trap();
    return 0;
}

这里也显示https://llvm.org/docs/LibFuzzer.html#toy-example,如果已经设置了我的CMakeLists.txt,那么一切正常,他会在发生错误后链接CXX可执行文件

Undefined symbols for architecture x86_64:
  "_main",referenced from:
     implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64

当我通过终端用Ubuntu 18.04的Virtualbox尝试编译时发生相同的错误-相同的Clion版本和Cmakelist没问题

qq345289212 回答:在macOS上找不到针对架构x86_64的libfuzzer

使用正确的编译器而不是苹果的编译器就可以了, -> brew install llvm 将偏好设置编译器c和c ++设置为/usr/local/opt/llvm/bin/clang

本文链接:https://www.f2er.com/2971150.html

大家都在问