aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2022-12-19 11:14:55 +0100
committerJakub Jelinek <jakub@redhat.com>2022-12-19 11:14:55 +0100
commitf39b7a4d37f46bb7e627d67f4a1ae9114f2175d1 (patch)
treed1732db3d2c0c583042c4285e0b7a74bff469b5c /gcc
parent61f9fe404933552a1858414f8181936d63a88ca2 (diff)
downloadgcc-f39b7a4d37f46bb7e627d67f4a1ae9114f2175d1.zip
gcc-f39b7a4d37f46bb7e627d67f4a1ae9114f2175d1.tar.gz
gcc-f39b7a4d37f46bb7e627d67f4a1ae9114f2175d1.tar.bz2
hwasan: Add libhwasan_preinit.o
I've noticed an inconsistency with the other sanitizers. For -fsanitize={address,thread,leak} we link into binaries lib*san_preinit.o such that the -lasan, -ltsan or -llsan libraries are initialized as early as possible through .preinit_array. The hwasan library has the same thing, but we strangely compiled it into the library (where it apparently didn't do anything, .preinit_array doesn't seem to be created for shared libraries), rather than installing it like in the other 3 cases. The following patch handles it for hwasan similarly to asan, tsan and lsan. I don't have any hw with hwasan support, so I've just checked it builds and installs as expected and that gcc -fsanitize=hwaddress -o a a.c -mlam=u57 on trivial main results in .preinit_array section in the binary. 2022-12-19 Jakub Jelinek <jakub@redhat.com> * config/gnu-user.h (LIBHWASAN_EARLY_SPEC): Add libhwasan_preinit.o to link spec if not -shared. * hwasan/Makefile.am (nodist_toolexeclib_HEADERS): Set to libhwasan_preinit.o. (hwasan_files): Remove hwasan_preinit.cpp. (libhwasan_preinit.o): Copy from hwasan_preinit.o. * hwasan/Makefile.in: Regenerated.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/config/gnu-user.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/gcc/config/gnu-user.h b/gcc/config/gnu-user.h
index 857c0e0..edb3aa6 100644
--- a/gcc/config/gnu-user.h
+++ b/gcc/config/gnu-user.h
@@ -138,7 +138,8 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
LD_STATIC_OPTION " --whole-archive -lasan --no-whole-archive " \
LD_DYNAMIC_OPTION "}}%{!static-libasan:-lasan}"
#undef LIBHWASAN_EARLY_SPEC
-#define LIBHWASAN_EARLY_SPEC "%{static-libhwasan:%{!shared:" \
+#define LIBHWASAN_EARLY_SPEC "%{!shared:libhwasan_preinit%O%s} " \
+ "%{static-libhwasan:%{!shared:" \
LD_STATIC_OPTION " --whole-archive -lhwasan --no-whole-archive " \
LD_DYNAMIC_OPTION "}}%{!static-libhwasan:-lhwasan}"
#undef LIBTSAN_EARLY_SPEC