From patchwork Mon Jan 28 14:30:36 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 216223 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]) by ozlabs.org (Postfix) with SMTP id A5A892C0080 for ; Tue, 29 Jan 2013 01:31:08 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1359988269; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Date:From:To:Subject:Message-ID:Reply-To: MIME-Version:Content-Type:Content-Disposition:User-Agent: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=iadLBb2gyXJWEhJBePQ+ YknH16w=; b=RM0xZddGawW5sSHM+mISYbyZZs3veZP2NmZfTX8a41jZFH2WT4YL ofqecE6oKuRzIZ4CeEDmX7BPmNubebVsq8MLiUm+z5bVtKHmz4XkUoDXBStOslVc K3DUZRwEZnyWN+KzCzn4UDuO+QgGq8voUlJleO8KruQ4nHGIhesBZRc= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:Received:Date:From:To:Subject:Message-ID:Reply-To:MIME-Version:Content-Type:Content-Disposition:User-Agent:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=DZf3t+AhQSKYFe2NjSt5heoHw+6izCHV+mp7fyFdClUUNav8WiXlL8LKWTS0ac YHe672DHi1B4b5tIevteSHc1uXuwJYhCFDZczF8feXIDkQwFCd3hBqwSh+zcz8pa B0RvO+nCf+nHay+Dv7lYMNGER5lk3WCRzfJv9Qo9l5ES0=; Received: (qmail 19318 invoked by alias); 28 Jan 2013 14:31:02 -0000 Received: (qmail 19302 invoked by uid 22791); 28 Jan 2013 14:31:01 -0000 X-SWARE-Spam-Status: No, hits=-6.5 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, KHOP_SPAMHAUS_DROP, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, RP_MATCHES_RCVD, SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 28 Jan 2013 14:30:52 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r0SEUd0V004930 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 28 Jan 2013 09:30:48 -0500 Received: from zalov.redhat.com (vpn1-6-106.ams2.redhat.com [10.36.6.106]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r0SEUc0S001089 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 28 Jan 2013 09:30:39 -0500 Received: from zalov.cz (localhost [127.0.0.1]) by zalov.redhat.com (8.14.5/8.14.5) with ESMTP id r0SEUbTA017764 for ; Mon, 28 Jan 2013 15:30:37 +0100 Received: (from jakub@localhost) by zalov.cz (8.14.5/8.14.5/Submit) id r0SEUbq6017763 for gcc-patches@gcc.gnu.org; Mon, 28 Jan 2013 15:30:37 +0100 Date: Mon, 28 Jan 2013 15:30:36 +0100 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Subject: [committed] Avoid string.h includes in -fno-builtin-memset testcases (PR testsuite/56053) Message-ID: <20130128143036.GI4385@tucnak.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes 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 Hi! Some targets apparently force fortification unconditionally or at least by default, when string.h is then included, memset etc. inlines might call __builtin_memset or __builtin___memset_chk directly and for explicit builtin uses -fno-builtin* doesn't work. Fixed by avoiding those includes and instead adding needed prototypes by hand, tested on x86_64-linux, committed as obvious to trunk. 2013-01-28 Jakub Jelinek PR testsuite/56053 * c-c++-common/asan/heap-overflow-1.c: Don't include stdlib.h and string.h. Provide memset, malloc and free prototypes, adjust line numbers in dg-output. * c-c++-common/asan/stack-overflow-1.c: Don't include string.h. Provide memset prototype and adjust line numbers in dg-output. * c-c++-common/asan/global-overflow-1.c: Likewise. Jakub --- gcc/testsuite/c-c++-common/asan/heap-overflow-1.c.jj 2012-12-13 00:02:50.000000000 +0100 +++ gcc/testsuite/c-c++-common/asan/heap-overflow-1.c 2013-01-28 13:47:58.682416114 +0100 @@ -2,8 +2,18 @@ /* { dg-options "-fno-builtin-malloc -fno-builtin-free -fno-builtin-memset" } */ /* { dg-shouldfail "asan" } */ -#include -#include +#ifdef __cplusplus +extern "C" { +#endif + +void *memset (void *, int, __SIZE_TYPE__); +void *malloc (__SIZE_TYPE__); +void free (void *); + +#ifdef __cplusplus +} +#endif + volatile int ten = 10; int main(int argc, char **argv) { char *x = (char*)malloc(10); @@ -14,8 +24,8 @@ int main(int argc, char **argv) { } /* { dg-output "READ of size 1 at 0x\[0-9a-f\]+ thread T0.*(\n|\r\n|\r)" } */ -/* { dg-output " #0 0x\[0-9a-f\]+ (in _*main (\[^\n\r]*heap-overflow-1.c:11|\[^\n\r]*:0)|\[(\]).*(\n|\r\n|\r)" } */ +/* { dg-output " #0 0x\[0-9a-f\]+ (in _*main (\[^\n\r]*heap-overflow-1.c:21|\[^\n\r]*:0)|\[(\]).*(\n|\r\n|\r)" } */ /* { dg-output "0x\[0-9a-f\]+ is located 0 bytes to the right of 10-byte region\[^\n\r]*(\n|\r\n|\r)" } */ /* { dg-output "allocated by thread T0 here:\[^\n\r]*(\n|\r\n|\r)" } */ /* { dg-output " #0 0x\[0-9a-f\]+ (in _*(interceptor_|)malloc|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */ -/* { dg-output " #1 0x\[0-9a-f\]+ (in _*main (\[^\n\r]*heap-overflow-1.c:9|\[^\n\r]*:0)|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */ +/* { dg-output " #1 0x\[0-9a-f\]+ (in _*main (\[^\n\r]*heap-overflow-1.c:19|\[^\n\r]*:0)|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */ --- gcc/testsuite/c-c++-common/asan/stack-overflow-1.c.jj 2012-12-13 00:02:50.000000000 +0100 +++ gcc/testsuite/c-c++-common/asan/stack-overflow-1.c 2013-01-28 13:48:41.046171347 +0100 @@ -2,9 +2,13 @@ /* { dg-options "-fno-builtin-memset" } */ /* { dg-shouldfail "asan" } */ -volatile int ten = 10; +extern +#ifdef __cplusplus +"C" +#endif +void *memset (void *, int, __SIZE_TYPE__); -#include +volatile int ten = 10; int main() { char x[10]; @@ -14,5 +18,5 @@ int main() { } /* { dg-output "READ of size 1 at 0x\[0-9a-f\]+ thread T0\[^\n\r]*(\n|\r\n|\r)" } */ -/* { dg-output " #0 0x\[0-9a-f\]+ (in _*main (\[^\n\r]*stack-overflow-1.c:12|\[^\n\r]*:0)|\[(\]).*(\n|\r\n|\r)" } */ +/* { dg-output " #0 0x\[0-9a-f\]+ (in _*main (\[^\n\r]*stack-overflow-1.c:16|\[^\n\r]*:0)|\[(\]).*(\n|\r\n|\r)" } */ /* { dg-output "Address 0x\[0-9a-f\]+ is\[^\n\r]*frame
" } */ --- gcc/testsuite/c-c++-common/asan/global-overflow-1.c.jj 2012-12-13 00:02:50.000000000 +0100 +++ gcc/testsuite/c-c++-common/asan/global-overflow-1.c 2013-01-28 13:46:13.900017787 +0100 @@ -2,7 +2,12 @@ /* { dg-options "-fno-builtin-memset" } */ /* { dg-shouldfail "asan" } */ -#include +extern +#ifdef __cplusplus +"C" +#endif +void *memset (void *, int, __SIZE_TYPE__); + volatile int ten = 10; int main() { @@ -18,6 +23,6 @@ int main() { } /* { dg-output "READ of size 1 at 0x\[0-9a-f\]+ thread T0.*(\n|\r\n|\r)" } */ -/* { dg-output " #0 0x\[0-9a-f\]+ (in _*main (\[^\n\r]*global-overflow-1.c:15|\[^\n\r]*:0)|\[(\])\[^\n\r]*(\n|\r\n|\r).*" } */ +/* { dg-output " #0 0x\[0-9a-f\]+ (in _*main (\[^\n\r]*global-overflow-1.c:20|\[^\n\r]*:0)|\[(\])\[^\n\r]*(\n|\r\n|\r).*" } */ /* { dg-output "0x\[0-9a-f\]+ is located 0 bytes to the right of global variable" } */ /* { dg-output ".*YYY\[^\n\r]* of size 10\[^\n\r]*(\n|\r\n|\r)" } */