Depends on D129371.
It survived all GCC ASan tests.
Changes are trivial and mostly "borrowed" RISC-V logics, except that a different SHADOW_OFFSET is used.
xry111 on Jul 9 2022, 12:22 AM.Authored by
Mark __interceptor::real_vfork with ASM_HIDDEN and use la.local for it.
Add %plt for COMMON_INTERCEPTOR_HANDLE_VFORK because it's not DSO local and the linker warns about using calling it w/o PLT.
LGTM besides two extremely minor nits.
I've rebased and applied the two diffs for GCC. And for ASan, define TARGET_ASAN_SHADOW_OFFSET to return the shadow offset (1 << 46).
The changes are available at https://github.com/xry111/gcc/tree/me/loongarch-sanitizer-test.
Build it with /path/to/gcc/configure --prefix=/home/xry111/gcc-trunk --disable-multilib --with-system-zlib --enable-libsanitizer --disable-bootstrap, then make. --enable-libsanitizer is necessary because libsanitizer is not enabled by default by GCC building system for LoongArch target. --disable-bootstrap saves some time, but if the system compiler is affected by https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106096 you'll need --enable-bootstrap.
Run UBSan tests with make check-gcc RUNTESTFLAGS=ubsan.exp.
Run ASan tests with make check-gcc RUNTESTFLAGS=asan.exp.
Seems that currently we can only check the changes by GCC because LoongArch hasn’t been supported by clang.
Not sure whether this change could land. What do others think?
+vitalybuka for this question.