public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-4774] hwasan: Add libhwasan_preinit.o Date: Mon, 19 Dec 2022 10:15:50 +0000 (GMT) [thread overview] Message-ID: <20221219101550.EC5373CAD35E@sourceware.org> (raw) https://gcc.gnu.org/g:f39b7a4d37f46bb7e627d67f4a1ae9114f2175d1 commit r13-4774-gf39b7a4d37f46bb7e627d67f4a1ae9114f2175d1 Author: Jakub Jelinek <jakub@redhat.com> Date: Mon Dec 19 11:14:55 2022 +0100 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. Diff: --- gcc/config/gnu-user.h | 3 +- libsanitizer/hwasan/Makefile.am | 5 +++- libsanitizer/hwasan/Makefile.in | 62 ++++++++++++++++++++++++++++++----------- 3 files changed, 51 insertions(+), 19 deletions(-) diff --git a/gcc/config/gnu-user.h b/gcc/config/gnu-user.h index 857c0e077bf..edb3aa6e451 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 diff --git a/libsanitizer/hwasan/Makefile.am b/libsanitizer/hwasan/Makefile.am index b8d39af4322..5a89189f6d8 100644 --- a/libsanitizer/hwasan/Makefile.am +++ b/libsanitizer/hwasan/Makefile.am @@ -12,6 +12,7 @@ AM_CCASFLAGS = $(EXTRA_ASFLAGS) ACLOCAL_AMFLAGS = -I $(top_srcdir) -I $(top_srcdir)/config toolexeclib_LTLIBRARIES = libhwasan.la +nodist_toolexeclib_HEADERS = libhwasan_preinit.o hwasan_files = \ hwasan_allocation_functions.cpp \ @@ -28,7 +29,6 @@ hwasan_files = \ hwasan_memintrinsics.cpp \ hwasan_new_delete.cpp \ hwasan_poisoning.cpp \ - hwasan_preinit.cpp \ hwasan_report.cpp \ hwasan_setjmp_aarch64.S \ hwasan_setjmp_x86_64.S \ @@ -49,6 +49,9 @@ libhwasan_la_LIBADD += $(LIBSTDCXX_RAW_CXX_LDFLAGS) libhwasan_la_LDFLAGS = -version-info `grep -v '^\#' $(srcdir)/libtool-version` $(link_libhwasan) +libhwasan_preinit.o: hwasan_preinit.o + cp $< $@ + # Work around what appears to be a GNU make bug handling MAKEFLAGS # values defined in terms of make variables, as is the case for CC and # friends when we are called from the top level Makefile. diff --git a/libsanitizer/hwasan/Makefile.in b/libsanitizer/hwasan/Makefile.in index b9b942003a3..4240aa90147 100644 --- a/libsanitizer/hwasan/Makefile.in +++ b/libsanitizer/hwasan/Makefile.in @@ -14,6 +14,7 @@ @SET_MAKE@ + VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ @@ -141,7 +142,8 @@ am__uninstall_files_from_dir = { \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } -am__installdirs = "$(DESTDIR)$(toolexeclibdir)" +am__installdirs = "$(DESTDIR)$(toolexeclibdir)" \ + "$(DESTDIR)$(toolexeclibdir)" LTLIBRARIES = $(toolexeclib_LTLIBRARIES) am__DEPENDENCIES_1 = libhwasan_la_DEPENDENCIES = \ @@ -152,10 +154,9 @@ am__objects_1 = hwasan_allocation_functions.lo hwasan_allocator.lo \ hwasan_fuchsia.lo hwasan_globals.lo hwasan_interceptors.lo \ hwasan_interceptors_vfork.lo hwasan_linux.lo \ hwasan_memintrinsics.lo hwasan_new_delete.lo \ - hwasan_poisoning.lo hwasan_preinit.lo hwasan_report.lo \ - hwasan_setjmp_aarch64.lo hwasan_setjmp_x86_64.lo \ - hwasan_tag_mismatch_aarch64.lo hwasan_thread.lo \ - hwasan_thread_list.lo hwasan_type_test.lo + hwasan_poisoning.lo hwasan_report.lo hwasan_setjmp_aarch64.lo \ + hwasan_setjmp_x86_64.lo hwasan_tag_mismatch_aarch64.lo \ + hwasan_thread.lo hwasan_thread_list.lo hwasan_type_test.lo am_libhwasan_la_OBJECTS = $(am__objects_1) libhwasan_la_OBJECTS = $(am_libhwasan_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) @@ -233,6 +234,7 @@ am__can_run_installinfo = \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac +HEADERS = $(nodist_toolexeclib_HEADERS) am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is @@ -415,6 +417,7 @@ AM_CXXFLAGS = -Wall -W -Wno-unused-parameter -Wwrite-strings -pedantic \ AM_CCASFLAGS = $(EXTRA_ASFLAGS) ACLOCAL_AMFLAGS = -I $(top_srcdir) -I $(top_srcdir)/config toolexeclib_LTLIBRARIES = libhwasan.la +nodist_toolexeclib_HEADERS = libhwasan_preinit.o hwasan_files = \ hwasan_allocation_functions.cpp \ hwasan_allocator.cpp \ @@ -430,7 +433,6 @@ hwasan_files = \ hwasan_memintrinsics.cpp \ hwasan_new_delete.cpp \ hwasan_poisoning.cpp \ - hwasan_preinit.cpp \ hwasan_report.cpp \ hwasan_setjmp_aarch64.S \ hwasan_setjmp_x86_64.S \ @@ -575,7 +577,6 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hwasan_memintrinsics.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hwasan_new_delete.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hwasan_poisoning.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hwasan_preinit.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hwasan_report.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hwasan_setjmp_aarch64.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hwasan_setjmp_x86_64.Plo@am__quote@ @@ -631,6 +632,27 @@ mostlyclean-libtool: clean-libtool: -rm -rf .libs _libs +install-nodist_toolexeclibHEADERS: $(nodist_toolexeclib_HEADERS) + @$(NORMAL_INSTALL) + @list='$(nodist_toolexeclib_HEADERS)'; test -n "$(toolexeclibdir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(toolexeclibdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(toolexeclibdir)" || exit 1; \ + fi; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(toolexeclibdir)'"; \ + $(INSTALL_HEADER) $$files "$(DESTDIR)$(toolexeclibdir)" || exit $$?; \ + done + +uninstall-nodist_toolexeclibHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(nodist_toolexeclib_HEADERS)'; test -n "$(toolexeclibdir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + dir='$(DESTDIR)$(toolexeclibdir)'; $(am__uninstall_files_from_dir) ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique @@ -685,9 +707,9 @@ distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags check-am: all-am check: check-am -all-am: Makefile $(LTLIBRARIES) +all-am: Makefile $(LTLIBRARIES) $(HEADERS) installdirs: - for dir in "$(DESTDIR)$(toolexeclibdir)"; do \ + for dir in "$(DESTDIR)$(toolexeclibdir)" "$(DESTDIR)$(toolexeclibdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am @@ -749,7 +771,8 @@ install-dvi: install-dvi-am install-dvi-am: -install-exec-am: install-toolexeclibLTLIBRARIES +install-exec-am: install-nodist_toolexeclibHEADERS \ + install-toolexeclibLTLIBRARIES install-html: install-html-am @@ -789,7 +812,8 @@ ps: ps-am ps-am: -uninstall-am: uninstall-toolexeclibLTLIBRARIES +uninstall-am: uninstall-nodist_toolexeclibHEADERS \ + uninstall-toolexeclibLTLIBRARIES .MAKE: install-am install-strip @@ -800,17 +824,21 @@ uninstall-am: uninstall-toolexeclibLTLIBRARIES info-am install install-am install-data install-data-am \ install-dvi install-dvi-am install-exec install-exec-am \ install-html install-html-am install-info install-info-am \ - install-man install-pdf install-pdf-am install-ps \ - install-ps-am install-strip install-toolexeclibLTLIBRARIES \ - installcheck installcheck-am installdirs maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-compile \ - mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ - tags tags-am uninstall uninstall-am \ + install-man install-nodist_toolexeclibHEADERS install-pdf \ + install-pdf-am install-ps install-ps-am install-strip \ + install-toolexeclibLTLIBRARIES installcheck installcheck-am \ + installdirs maintainer-clean maintainer-clean-generic \ + mostlyclean mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \ + uninstall-am uninstall-nodist_toolexeclibHEADERS \ uninstall-toolexeclibLTLIBRARIES .PRECIOUS: Makefile +libhwasan_preinit.o: hwasan_preinit.o + cp $< $@ + # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT:
reply other threads:[~2022-12-19 10:15 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20221219101550.EC5373CAD35E@sourceware.org \ --to=jakub@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).