From patchwork Mon Feb 23 21:05:41 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 442670 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 02332140134 for ; Tue, 24 Feb 2015 08:05:57 +1100 (AEDT) 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:reply-to:mime-version :content-type; q=dns; s=default; b=EGrP8r7lwtqMo+XEyjUH0OBjc7nUE mjio06XA2O5M1ek0rYkK3+4yDeXnwGxMeCZGq+PbsIVnUT+6Nqd/qC8Ht8GDxL+f vNOxI68Rko1w+j/KMW39jHJoP9/q4so2/KfSrIWhFcvrWabNEDgUwzAl1eagRNK2 yz4gRgzIPpsY9I= 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:reply-to:mime-version :content-type; s=default; bh=NCq8MsHlAwhCtUPYM7eHDZsIaCk=; b=tc9 gb4rXHc1kLfGLSmp2cKr/qZZFlvBDiY5Fn1Wvv4fVS0NowVYc2J8h1ng0FQ4Ufse zX5X8NCqzwszYD17WQFp8UZkzTRnw89AYoi1bY5zlXrwpOW4a8Ug85VtQBLwEMuE 0QALk/AnA0f0/45WRIzcc/Cj1oXnE6vO0fQyo3G0= Received: (qmail 106618 invoked by alias); 23 Feb 2015 21:05:50 -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 106609 invoked by uid 89); 23 Feb 2015 21:05:50 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Mon, 23 Feb 2015 21:05:49 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t1NL5kZo031246 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 23 Feb 2015 16:05:47 -0500 Received: from tucnak.zalov.cz (ovpn-116-28.ams2.redhat.com [10.36.116.28]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t1NL5iV9026829 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=NO); Mon, 23 Feb 2015 16:05:45 -0500 Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.14.9/8.14.9) with ESMTP id t1NL5gwd023026; Mon, 23 Feb 2015 22:05:42 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.14.9/8.14.9/Submit) id t1NL5fbt023025; Mon, 23 Feb 2015 22:05:41 +0100 Date: Mon, 23 Feb 2015 22:05:41 +0100 From: Jakub Jelinek To: Kostya Serebryany Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Disable "ODR" checking in libsanitizer Message-ID: <20150223210541.GM1746@tucnak.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes Hi! The "ODR" checking lib libsanitizer isn't really ODR checking and relies on the LLVM way of registering the same symbol multiple times, where GCC uses private aliases and the only time "ODR violatilation" is reported is when there are symbol aliases. Until libsanitizer rewrites this to use names instead of addresses and has some bit to turn off ODR checking (e.g. for languages where ODR is non-existent or for internal symbols or private symbols), this stuff doesn't make any sense for GCC and breaks valid code. Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk. 2015-02-20 Jakub Jelinek PR bootstrap/63888 * asan/asan_globals.cc (RegisterGlobal): Disable detect_odr_violation support until it is rewritten upstream. * c-c++-common/asan/pr63888.c: New test. Jakub --- libsanitizer/asan/asan_globals.cc.jj 2014-11-14 00:10:34.000000000 +0100 +++ libsanitizer/asan/asan_globals.cc 2015-02-20 11:43:33.179177767 +0100 @@ -148,7 +148,9 @@ static void RegisterGlobal(const Global CHECK(AddrIsInMem(g->beg)); CHECK(AddrIsAlignedByGranularity(g->beg)); CHECK(AddrIsAlignedByGranularity(g->size_with_redzone)); - if (flags()->detect_odr_violation) { + // This "ODR violation" detection is fundamentally incompatible with + // how GCC registers globals. Disable as useless until rewritten upstream. + if (0 && flags()->detect_odr_violation) { // Try detecting ODR (One Definition Rule) violation, i.e. the situation // where two globals with the same name are defined in different modules. if (__asan_region_is_poisoned(g->beg, g->size_with_redzone)) { --- gcc/testsuite/c-c++-common/asan/pr63888.c.jj 2015-02-23 19:07:02.260413707 +0100 +++ gcc/testsuite/c-c++-common/asan/pr63888.c 2015-02-23 19:06:31.000000000 +0100 @@ -0,0 +1,34 @@ +/* PR bootstrap/63888 */ +/* { dg-do run } */ + +__attribute__((noinline, noclone)) int +foo (int x) +{ + int v = 0; + switch (x) + { + case 11: v = 67; break; + case 12: v = 68; break; + case 13: v = 69; break; + } + return v; +} + +__attribute__((noinline, noclone)) int +bar (int x) +{ + int v = 0; + switch (x) + { + case 18: v = 67; break; + case 19: v = 68; break; + case 20: v = 69; break; + } + return v; +} + +int +main () +{ + return foo (11) - 67 + bar (19) - 68; +}