On 12/16/22 03:27, Jakub Jelinek via Gcc-patches wrote:
Hi!

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.

Ok for trunk?

2022-12-16  Jakub Jelinek  <ja...@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.
No objections to the technical bits. I trust your judgement WRT risk/reward for including in gcc-13. So your call on whether to commit now or wait.

jeff

Reply via email to