[llvm-dev] CFI, Safe-Stack, and -fno-sanitize-trap
Artem Dinaburg via llvm-dev
llvm-dev at lists.llvm.org
Tue Jan 31 11:34:50 PST 2017
Hi,
I am using clang++3.9 to build a simple program with both CFI and safe-stack. I am getting linker errors when combining -fsanitize=safe-stack, -fsanitize=cfi, and -fno-sanitize-trap=all. Combining safe-stack and CFI without -fno-sanitize-trap=all works as expected.
It looks like clang is attempting to link in two compiler-rt libraries, one for ubsan and one for safestack, and this causes multiply defined symbols.
Is this the expected behavior? Can only one sanitizer at a time have trapping disabled?
The command line to trigger is below.
---
$ clang++-3.9 -flto -fvisibility=default -fsanitize=safe-stack -fsanitize=cfi -fuse-ld=gold -fno-sanitize-trap=all hello.cpp
... lots of multiply defined symbol errors...
/usr/bin/ld.gold: error: /usr/lib/llvm-3.9/bin/../lib/clang/3.9.1/lib/linux/libclang_rt.safestack-x86_64.a(sanitizer_common_nolibc.cc.o): multiple definition of '__sanitizer::Abort()'
/usr/bin/ld.gold: /usr/lib/llvm-3.9/bin/../lib/clang/3.9.1/lib/linux/libclang_rt.ubsan_standalone-x86_64.a(sanitizer_posix_libcdep.cc.o): previous definition here
/usr/bin/ld.gold: error: /usr/lib/llvm-3.9/bin/../lib/clang/3.9.1/lib/linux/libclang_rt.safestack-x86_64.a(sanitizer_common_nolibc.cc.o): multiple definition of '__sanitizer::SleepForSeconds(int)'
/usr/bin/ld.gold: /usr/lib/llvm-3.9/bin/../lib/clang/3.9.1/lib/linux/libclang_rt.ubsan_standalone-x86_64.a(sanitizer_posix_libcdep.cc.o): previous definition here
clang: error: linker command failed with exit code 1 (use -v to see invocation)
---
hello.cpp:
---
#include <iostream>
int main(int argc, const char* argv[]) {
std::cout << "Hello, World\n";
return 0;
}
---
Thanks,
Artem
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3970 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170131/a5afb240/attachment.bin>
More information about the llvm-dev
mailing list