From patchwork Fri Nov 8 09:02:56 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Enkovich X-Patchwork-Id: 289722 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 6EF5B2C00C8 for ; Fri, 8 Nov 2013 20:04:39 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; q=dns; s=default; b=XcUFiuJTB4R/UiqOS 0HFGV9cy8IzUp6ZywAtAA6GdiCUjZhc2kGrEgFu7kpmcBDntVhYClRMjWhM08dxd KrFcWSas2AjaVsrRMDBgbL1QXso01e/ReAacXY0Mi4AO6mFlrCmnDhm6Rx94WyLa d1RUvGApN1jgvwFqp7aehhAoV0= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=default; bh=NpitVCZr05QwxDe6FVx1VlS 7478=; b=eJqrdbaR0fBobyb5CbmrJI9w3FQLN7D9rFHplH2Setaj9iHKYiKl2Vw yeLPk93qe+i1a7e+M8aouADKfvE2ty7QamutSPF7uKLBc+cc7dLPPFeW4GboJofy yDG6IqLLUeyfDchd2225PBfWgLCYOAdwk91LHUfLw5qMyar0sTME= Received: (qmail 31065 invoked by alias); 8 Nov 2013 09:04:28 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 31054 invoked by uid 89); 8 Nov 2013 09:04:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=3.3 required=5.0 tests=AWL, BAYES_50, FREEMAIL_FROM, RDNS_NONE, SPAM_SUBJECT, SPF_PASS, URIBL_BLOCKED autolearn=no version=3.3.2 X-HELO: mail-pb0-f51.google.com Received: from Unknown (HELO mail-pb0-f51.google.com) (209.85.160.51) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Fri, 08 Nov 2013 09:03:57 +0000 Received: by mail-pb0-f51.google.com with SMTP id xa7so1886299pbc.10 for ; Fri, 08 Nov 2013 01:03:46 -0800 (PST) X-Received: by 10.66.191.162 with SMTP id gz2mr14597471pac.151.1383901426503; Fri, 08 Nov 2013 01:03:46 -0800 (PST) Received: from msticlxl57.ims.intel.com (fmdmzpr04-ext.fm.intel.com. [192.55.55.39]) by mx.google.com with ESMTPSA id hz10sm10571477pbc.36.2013.11.08.01.03.44 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 08 Nov 2013 01:03:45 -0800 (PST) Date: Fri, 8 Nov 2013 13:02:56 +0400 From: Ilya Enkovich To: gcc-patches@gcc.gnu.org Cc: GCC Patches Subject: Re: [PATCH, MPX, 2/X] Pointers Checker [8/25] Languages support Message-ID: <20131108090256.GA21297@msticlxl57.ims.intel.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes 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 * 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;