Artem Dinaburg via llvm-dev
unread,Jan 31, 2017, 2:34:59 PM1/31/17Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to llvm...@lists.llvm.org
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