This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Initialize sanitizer builtins (PR sanitizer/60745)
- From: Marek Polacek <polacek at redhat dot com>
- To: Jeff Law <law at redhat dot com>
- Cc: Jonathan Wakely <jwakely at redhat dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>, Jakub Jelinek <jakub at redhat dot com>
- Date: Sat, 5 Apr 2014 19:36:34 +0200
- Subject: Re: [PATCH] Initialize sanitizer builtins (PR sanitizer/60745)
- Authentication-results: sourceware.org; auth=none
- References: <20140403165630 dot GE24603 at redhat dot com> <533ECD26 dot 2000504 at redhat dot com> <20140404154848 dot GT13192 at redhat dot com> <20140404171427 dot GG24603 at redhat dot com> <533EF0CC dot 2020904 at redhat dot com> <20140404194552 dot GH24603 at redhat dot com> <533F1BCC dot 5070408 at redhat dot com>
On Fri, Apr 04, 2014 at 02:53:32PM -0600, Jeff Law wrote:
> Presumably when we wrote out the PCH -fsanitize wasn't being used
> and thus those builtins are not initialized. Right?
Right. I put a local hack into c_common_write_pch and that said:
wrote x86_64-unknown-linux-gnu/bits/stdc++.h.gch/O2g.gch, sanitize flag: 0
so builtins weren't initialized (see #define DEF_SANITIZER_BUILTIN for
why). O2g.gch is the file that is then read by c_common_read_pch.
> Assuming that's correct, your patch is fine with a comment to that effect.
Thanks. I'll wait a day or two for possible comments.
2014-04-05 Marek Polacek <polacek@redhat.com>
PR sanitizer/60745
* c-ubsan.c: Include asan.h.
(ubsan_instrument_return): Call initialize_sanitizer_builtins.
diff --git gcc/c-family/c-ubsan.c gcc/c-family/c-ubsan.c
index dc4d981..e89ebc1 100644
--- gcc/c-family/c-ubsan.c
+++ gcc/c-family/c-ubsan.c
@@ -29,6 +29,7 @@ along with GCC; see the file COPYING3. If not see
#include "ubsan.h"
#include "c-family/c-common.h"
#include "c-family/c-ubsan.h"
+#include "asan.h"
/* Instrument division by zero and INT_MIN / -1. If not instrumenting,
return NULL_TREE. */
@@ -185,6 +186,10 @@ ubsan_instrument_vla (location_t loc, tree size)
tree
ubsan_instrument_return (location_t loc)
{
+ /* It is possible that PCH zapped table with definitions of sanitizer
+ builtins. Reinitialize them if needed. */
+ initialize_sanitizer_builtins ();
+
tree data = ubsan_create_data ("__ubsan_missing_return_data", &loc,
NULL, NULL_TREE);
tree t = builtin_decl_explicit (BUILT_IN_UBSAN_HANDLE_MISSING_RETURN);
Marek