summaryrefslogtreecommitdiff
path: root/gcc/ipa-chkp.c
diff options
context:
space:
mode:
authorienkovich <ienkovich@138bc75d-0d04-0410-961f-82ee72b054a4>2015-03-10 09:46:11 +0000
committerienkovich <ienkovich@138bc75d-0d04-0410-961f-82ee72b054a4>2015-03-10 09:46:11 +0000
commit4cefd7f71b5c9666489ba23e5cf3615b24891fba (patch)
tree9f634c911b71cfb8096225967112f43c9f6053e2 /gcc/ipa-chkp.c
parent8a325e42e5eccc86fae85854c46783da8e0dd0cf (diff)
downloadgcc-4cefd7f71b5c9666489ba23e5cf3615b24891fba.tar.gz
* 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@221314 138bc75d-0d04-0410-961f-82ee72b054a4
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 0b857ffb8a0..3bea06ab750 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.