我想把它们联系起来:
-std=c++11编译-std=c++11 -stdlib=libc++编译具体来说,正在执行这个链接器命令:
/bin/bash ././libtool静默-标记=CXX-模式=链接clang++-5.0 -i././包含-i./../lib-i./lib-i././test/fuzz -fsanitize=address -fsanitize-使用-范围后-fsanitize-覆盖率=跟踪-pc保护,跟踪-cmp -std=c++11 -stdlib=libc++ -o curl_fuzzer curl_fuzzer-curl_fuzzer.o ./lib/libcurl.la/root/checkout/Fuzzer/libFuzzer.a.a -lssh2 -lssl -lcrypto -lssl -lcrypto -lz -lpthread -lm
执行此命令将输出以下内容:
/bin/bash ../../libtool --silent --tag=CXX --mode=link clang++-5.0 -I../../include -I../../lib -I../../lib -I../../tests/fuzz -fsanitize=address -fsanitize-address-use-after-scope -fsanitize-coverage=trace-pc-guard,trace-cmp -std=c++11 -stdlib=libc++ -o curl_fuzzer curl_fuzzer-curl_fuzzer.o ../../lib/libcurl.la /root/checkouts/Fuzzer/libFuzzer.a -lssh2 -lssl -lcrypto -lssl -lcrypto -lz -lpthread -lm > /tmp/cat.txt 2>&1; head -20 /tmp/cat.txt
/root/checkouts/Fuzzer/libFuzzer.a(FuzzerIO.o): In function `fuzzer::FileToVector(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned long, bool)':
/root/checkouts/Fuzzer/./FuzzerIO.cpp:34: undefined reference to `std::basic_ifstream<char, std::char_traits<char> >::basic_ifstream(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::_Ios_Openmode)'
/root/checkouts/Fuzzer/./FuzzerIO.cpp:40: undefined reference to `std::istream::seekg(long, std::_Ios_Seekdir)'
/root/checkouts/Fuzzer/./FuzzerIO.cpp:41: undefined reference to `std::istream::tellg()'
/root/checkouts/Fuzzer/./FuzzerIO.cpp:47: undefined reference to `std::istream::seekg(long, std::_Ios_Seekdir)'
/root/checkouts/Fuzzer/./FuzzerIO.cpp:49: undefined reference to `std::istream::read(char*, long)'
/root/checkouts/Fuzzer/libFuzzer.a(FuzzerIO.o): In function `~basic_ifstream':
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0/fstream:534: undefined reference to `VTT for std::basic_ifstream<char, std::char_traits<char> >'
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0/fstream:534: undefined reference to `std::basic_ifstream<char, std::char_traits<char> >::~basic_ifstream()'
/root/checkouts/Fuzzer/libFuzzer.a(FuzzerIO.o): In function `~basic_ios':
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0/bits/basic_ios.h:282: undefined reference to `std::ios_base::~ios_base()'
/root/checkouts/Fuzzer/libFuzzer.a(FuzzerIO.o): In function `~basic_ifstream':
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0/fstream:534: undefined reference to `VTT for std::basic_ifstream<char, std::char_traits<char> >'
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0/fstream:534: undefined reference to `std::basic_ifstream<char, std::char_traits<char> >::~basic_ifstream()'
/root/checkouts/Fuzzer/libFuzzer.a(FuzzerIO.o): In function `~basic_ios':
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0/bits/basic_ios.h:282: undefined reference to `std::ios_base::~ios_base()'
/root/checkouts/Fuzzer/libFuzzer.a(FuzzerIO.o): In function `fuzzer::FileToString(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/root/checkouts/Fuzzer/./FuzzerIO.cpp:54: undefined reference to `std::basic_ifstream<char, std::char_traits<char> >::basic_ifstream(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::_Ios_Openmode)'
/root/checkouts/Fuzzer/libFuzzer.a(FuzzerIO.o): In function `~basic_ifstream':
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0/fstream:534: undefined reference to `VTT for std::basic_ifstream<char, std::char_traits<char> >'
<snip>我试着做了以下工作来解决这个问题:
-lc++ -什么都不做-lc++abi -什么都不做感觉好像我错过了一些显而易见的东西但我不知道是什么..。
我的clang-5.0安装来自clang-5.0/kali-rolling。
发布于 2017-09-14 01:40:33
您已经用libstdc++编译了部分代码,用libc++编译了部分代码。当您将它们链接在一起(使用libc++)时,具有对libstdc++的引用的部分不会被解析。
例如,std::__cxx11::basic_string绝对是一个libstdc++符号。
发布于 2017-09-02 10:19:45
看起来,不管出于什么原因,kali的clang-5.0版本没有正确地将二进制文件与libc++连接起来。我用google的ossfuzz版本的clang (clang-6.0)测试了相同的代码,并成功地将所有内容链接在一起。
https://stackoverflow.com/questions/46005228
复制相似问题