Hi,

Here is an updated patch version with no langhook.

Regarding TLS objects issue - I do not think compiler should compensate the 
absence of instrumentation in libraries.  Compiler should be responsible for 
initialization of Bounds Tables for .tdata section.  Correct data copy is a 
responsibility of library.  User should use either instrumented library or 
wrapper calls if he needs this functionality.

Thanks,
Ilya
--
gcc/

2013-11-06  Ilya Enkovich  <ilya.enkov...@intel.com>

        * c/c-parser.c: Include tree-chkp.h.
        (c_parser_declaration_or_fndef): Register statically
        initialized decls in Pointer Bounds Checker.
        * cp/decl.c: Include tree-chkp.h.
        (cp_finish_decl): Register statically
        initialized decls in Pointer Bounds Checker.
        * gimplify.c: Include tree-chkp.h.
        (gimplify_init_constructor): Register statically
        initialized decls in Pointer Bounds Checker.


diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c
index 9ccae3b..397b323 100644
--- a/gcc/c/c-parser.c
+++ b/gcc/c/c-parser.c
@@ -56,6 +56,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "cgraph.h"
 #include "plugin.h"
 #include "omp-low.h"
+#include "tree-chkp.h"
 
 
 /* Initialization routine for this file.  */
@@ -1682,6 +1683,12 @@ c_parser_declaration_or_fndef (c_parser *parser, bool 
fndef_ok,
                  maybe_warn_string_init (TREE_TYPE (d), init);
                  finish_decl (d, init_loc, init.value,
                               init.original_type, asm_name);
+
+                 /* Register all decls with initializers in Pointer
+                    Bounds Checker to generate required static bounds
+                    initializers.  */
+                 if (DECL_INITIAL (d) != error_mark_node)
+                   chkp_register_var_initializer (d);
                }
            }
          else
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 1e92f2a..74df02f 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -53,6 +53,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "splay-tree.h"
 #include "plugin.h"
 #include "cgraph.h"
+#include "tree-chkp.h"
 
 /* Possible cases of bad specifiers type used by bad_specifiers. */
 enum bad_spec_place {
@@ -6379,6 +6380,12 @@ cp_finish_decl (tree decl, tree init, bool 
init_const_expr_p,
             the class specifier.  */
          if (!DECL_EXTERNAL (decl))
            var_definition_p = true;
+
+         /* If var has initilizer then we need to register it in
+            Pointer Bounds Checker to generate static bounds initilizer
+            if required.  */
+         if (DECL_INITIAL (decl) && DECL_INITIAL (decl) != error_mark_node)
+           chkp_register_var_initializer (decl);
        }
       /* If the variable has an array type, lay out the type, even if
         there is no initializer.  It is valid to index through the
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 4f52c27..7aaac15 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -48,6 +48,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "vec.h"
 #include "omp-low.h"
 #include "gimple-low.h"
+#include "tree-chkp.h"
 
 #include "langhooks-def.h"     /* FIXME: for lhd_set_decl_assembler_name */
 #include "tree-pass.h"         /* FIXME: only for PROP_gimple_any */
@@ -4111,6 +4112,11 @@ gimplify_init_constructor (tree *expr_p, gimple_seq 
*pre_p, gimple_seq *post_p,
 
                walk_tree (&ctor, force_labels_r, NULL, NULL);
                ctor = tree_output_constant_def (ctor);
+
+               /* We need to register created constant object to
+                  initialize bounds for pointers in it.  */
+               chkp_register_var_initializer (ctor);
+
                if (!useless_type_conversion_p (type, TREE_TYPE (ctor)))
                  ctor = build1 (VIEW_CONVERT_EXPR, type, ctor);
                TREE_OPERAND (*expr_p, 1) = ctor;

Reply via email to