aboutsummaryrefslogtreecommitdiff
path: root/gcc/ipa-chkp.c
diff options
context:
space:
mode:
authorIlya Enkovich <ilya.enkovich@intel.com>2015-03-10 09:46:11 +0000
committerIlya Enkovich <ienkovich@gcc.gnu.org>2015-03-10 09:46:11 +0000
commit226d62d2d1fae33873e8ecda6004fb24ec36e421 (patch)
tree9f634c911b71cfb8096225967112f43c9f6053e2 /gcc/ipa-chkp.c
parentd2d7e672ad18c54aedfa766b7918d1631a22b4fa (diff)
downloadgcc-226d62d2d1fae33873e8ecda6004fb24ec36e421.zip
gcc-226d62d2d1fae33873e8ecda6004fb24ec36e421.tar.gz
gcc-226d62d2d1fae33873e8ecda6004fb24ec36e421.tar.bz2
c.opt (fchkp-use-wrappers): New.
* c-family/c.opt (fchkp-use-wrappers): New. * ipa-chkp.c (CHKP_WRAPPER_SYMBOL_PREFIX): New. (chkp_wrap_function): New. (chkp_build_instrumented_fndecl): Support wrapped functions. * doc/invoke.texi (-fcheck-pointer-bounds): New. (-fchkp-check-incomplete-type): New. (-fchkp-first-field-has-own-bounds): New. (-fchkp-narrow-bounds): New. (-fchkp-narrow-to-innermost-array): New. (-fchkp-optimize): New. (-fchkp-use-fast-string-functions): New. (-fchkp-use-nochk-string-functions): New. (-fchkp-use-static-bounds): New. (-fchkp-use-static-const-bounds): New. (-fchkp-treat-zero-dynamic-size-as-infinite): New. (-fchkp-check-read): New. (-fchkp-check-write): New. (-fchkp-store-bounds): New. (-fchkp-instrument-calls): New. (-fchkp-instrument-marked-only): New. (-fchkp-use-wrappers): New. (-static-libmpx): New. (-static-libmpxwrappers): New. From-SVN: r221314
Diffstat (limited to 'gcc/ipa-chkp.c')
-rw-r--r--gcc/ipa-chkp.c57
1 files changed, 52 insertions, 5 deletions
diff --git a/gcc/ipa-chkp.c b/gcc/ipa-chkp.c
index 0b857ff..3bea06a 100644
--- a/gcc/ipa-chkp.c
+++ b/gcc/ipa-chkp.c
@@ -100,6 +100,44 @@ along with GCC; see the file COPYING3. If not see
removed. */
#define CHKP_BOUNDS_OF_SYMBOL_PREFIX "__chkp_bounds_of_"
+#define CHKP_WRAPPER_SYMBOL_PREFIX "__mpx_wrapper_"
+
+/* Return 1 calls to FNDECL should be replaced with
+ a call to wrapper function. */
+static bool
+chkp_wrap_function (tree fndecl)
+{
+ if (!flag_chkp_use_wrappers)
+ return false;
+
+ if (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL)
+ {
+ switch (DECL_FUNCTION_CODE (fndecl))
+ {
+ case BUILT_IN_STRLEN:
+ case BUILT_IN_STRCPY:
+ case BUILT_IN_STRNCPY:
+ case BUILT_IN_STPCPY:
+ case BUILT_IN_STPNCPY:
+ case BUILT_IN_STRCAT:
+ case BUILT_IN_STRNCAT:
+ case BUILT_IN_MEMCPY:
+ case BUILT_IN_MEMPCPY:
+ case BUILT_IN_MEMSET:
+ case BUILT_IN_MEMMOVE:
+ case BUILT_IN_BZERO:
+ case BUILT_IN_MALLOC:
+ case BUILT_IN_CALLOC:
+ case BUILT_IN_REALLOC:
+ return 1;
+
+ default:
+ return 0;
+ }
+ }
+
+ return false;
+}
/* Build a clone of FNDECL with a modified name. */
@@ -124,11 +162,20 @@ chkp_build_instrumented_fndecl (tree fndecl)
because it conflicts with decl merging algorithms in LTO.
Achieve the result by using transparent alias name for the
instrumented version. */
- s = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (fndecl));
- s += ".chkp";
- new_name = get_identifier (s.c_str ());
- IDENTIFIER_TRANSPARENT_ALIAS (new_name) = 1;
- TREE_CHAIN (new_name) = DECL_ASSEMBLER_NAME (fndecl);
+ if (chkp_wrap_function(fndecl))
+ {
+ s = CHKP_WRAPPER_SYMBOL_PREFIX;
+ s += IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (fndecl));
+ new_name = get_identifier (s.c_str ());
+ }
+ else
+ {
+ s = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (fndecl));
+ s += ".chkp";
+ new_name = get_identifier (s.c_str ());
+ IDENTIFIER_TRANSPARENT_ALIAS (new_name) = 1;
+ TREE_CHAIN (new_name) = DECL_ASSEMBLER_NAME (fndecl);
+ }
SET_DECL_ASSEMBLER_NAME (new_decl, new_name);
/* For functions with body versioning will make a copy of arguments.