[compiler-rt] Revert "[safestack] Various Solaris fixes" (PR #98541)
Rainer Orth via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 16 04:52:08 PDT 2024
rorth wrote:
> I believe just defining `#define SANITIZER_COMMON_NO_REDEFINE_BUILTINS` before including #include "sanitizer_common/sanitizer_platform.h" in `compiler-rt/lib/safestack/safestack_platform.h` is enough.
Unfortunately not. On Solaris at least, all tests still `FAIL` to link with
```
Undefined first referenced
symbol in file
__sanitizer_internal_memset /var/llvm/local-amd64-release-stage2-A-flang-clang18/tools/clang/stage2-bins/lib/clang/19/lib/sunos/libclang_rt.safestack-i386.a(interception_linux.cpp.o)
__sanitizer_internal_memcpy /var/llvm/local-amd64-release-stage2-A-flang-clang18/tools/clang/stage2-bins/lib/clang/19/lib/sunos/libclang_rt.safestack-i386.a(interception_linux.cpp.o)
__sanitizer_internal_memmove /var/llvm/local-amd64-release-stage2-A-flang-clang18/tools/clang/stage2-bins/lib/clang/19/lib/sunos/libclang_rt.safestack-i386.a(interception_linux.cpp.o)
```
which indeed is ultimately due to `sanitizer_redefine_builtins.h`. Since the existing interception objects are just included in `libclang_rt.safestack-${arch}.a` as is, they aren't affected. I'm unclear if also adding `#define SANITIZER_COMMON_NO_REDEFINE_BUILTINS` at the top of `interception_linux.cpp` would be appropriate.
> `-ftrivial-auto-var-init=pattern` is optional for compiler-rt, most helps to reduce false negative with lsan.
Ah, thanks. It still would be nice to document beyond `clang --help`.
> `__sanitizer_internal_mem` is from sanitizer_redefine_builtins.h which suppose to avoid libc mem* calls from sanitizers with mem* interceptors. Luckly for us safe stack does not have them, so SANITIZER_COMMON_NO_REDEFINE_BUILTINS is appropriate.
>
> > It seems the safestack developers have just been lucky (or lazy) here.
>
> Both: `-ftrivial-auto-var-init=pattern` SANITIZER_COMMON_NO_REDEFINE_BUILTINS were added after safestack implementation. So this "sanitizer_common/sanitizer_platform.h" from safestack is unfortunate, we missed that adding pattern and REDEFINE for others sanitizers. Note iterception also use that header.
Exactly, and it shows on Solaris ;-)
https://github.com/llvm/llvm-project/pull/98541
More information about the llvm-commits
mailing list