From patchwork Wed May 2 19:12:59 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Bosscher X-Patchwork-Id: 156538 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 8BD74B6FAC for ; Thu, 3 May 2012 05:13:20 +1000 (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=1336590800; h=Comment: DomainKey-Signature:Received:Received:Received:Received: MIME-Version:Received:Received:Date:Message-ID:Subject:From:To: Cc:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=cTfT59O fFZFixecGBYc31J5tbdo=; b=cug7FvNK+mLpR6bsuIBuFK9LQniI0rulELN9auy JJkAAaNdfQBD6QA3MiVFIyI8S9E5osYSN4KL8bEO5SEQFsyhb6EaFIFvEFclQrjj dJVFWEv52l7oNM+gPST7zCvq+MYEwZ4zS6zcC9qOd/CvgbvVdWVLJjSiWRh9loJs zQ+0= 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:MIME-Version:Received:Received:Date:Message-ID:Subject:From:To:Cc:Content-Type:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=so6JYQS3DNTQp0flUWO6r+JJm2c0pRVl48ZK2q8Tj9wGsAyGSD1u0sgtreYUhY xTCzDeTodKu/lWMWE8c45T0Ix5O668lU98jI40nOhApGOs2A2d8HwRjtRHsU7xLU PJBi+YFkF8tgQwUXPyEkjEsH1n70D8olTx1GT1NY21SXM=; Received: (qmail 30131 invoked by alias); 2 May 2012 19:13:15 -0000 Received: (qmail 30122 invoked by uid 22791); 2 May 2012 19:13:13 -0000 X-SWARE-Spam-Status: No, hits=-4.0 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, KHOP_RCVD_TRUST, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE X-Spam-Check-By: sourceware.org Received: from mail-yx0-f175.google.com (HELO mail-yx0-f175.google.com) (209.85.213.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 02 May 2012 19:13:00 +0000 Received: by yenm3 with SMTP id m3so1163434yen.20 for ; Wed, 02 May 2012 12:12:59 -0700 (PDT) MIME-Version: 1.0 Received: by 10.236.75.232 with SMTP id z68mr34100134yhd.6.1335985979247; Wed, 02 May 2012 12:12:59 -0700 (PDT) Received: by 10.100.90.6 with HTTP; Wed, 2 May 2012 12:12:59 -0700 (PDT) Date: Wed, 2 May 2012 21:12:59 +0200 Message-ID: Subject: [patch] For alpha-vms, unset flag_jump_tables if flag_pic is nonzero From: Steven Bosscher To: GCC Patches Cc: Richard Henderson 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 Hello, alpha-vms is the only target that does not define ASM_OUTPUT_ADDR_DIFF_ELT. That makes the code in stmt.c to handle this case alpha-vms specific. But there is a better way to handle this: Just mimic -fno-jump-tables if flag_pic is nonzero. Tested by building a cross-compiler for alpha-dec-vms and verifying that flag_jump_tables==0 in expand_case. OK for trunk? Ciao! Steven * config/alpha/vms.h (SUBTARGET_OVERRIDE_OPTIONS): For pic code, unset flag_jump_tables. * stmt.c (expand_case): Remove special flag_pic case conditional on ASM_OUTPUT_ADDR_DIFF_ELT not being defined. Index: config/alpha/vms.h =================================================================== --- config/alpha/vms.h (revision 187046) +++ config/alpha/vms.h (working copy) @@ -257,7 +257,15 @@ typedef struct {int num_args; enum avms_ #undef ASM_FINAL_SPEC /* The VMS convention is to always provide minimal debug info - for a traceback unless specifically overridden. */ + for a traceback unless specifically overridden. + + Because ASM_OUTPUT_ADDR_DIFF_ELT is not defined for alpha-vms, + jump tables cannot be output for PIC code, because you can't put + an absolute address in a readonly section. Putting the table in + a writable section is a security hole. Therefore, we unset the + flag_jump_tables flag, forcing switch statements to be expanded + using decision trees. There are probably other ways to address + this issue, but using a decision tree is clearly safe. */ #undef SUBTARGET_OVERRIDE_OPTIONS #define SUBTARGET_OVERRIDE_OPTIONS \ @@ -268,6 +276,8 @@ do { write_symbols = VMS_DEBUG; \ debug_info_level = DINFO_LEVEL_TERSE; \ } \ + if (flag_pic == 1) \ + flag_jump_tables = 0; \ } while (0) #undef LINK_SPEC Index: stmt.c =================================================================== --- stmt.c (revision 187046) +++ stmt.c (working copy) @@ -2198,9 +2198,6 @@ expand_case (gimple stmt) /* RANGE may be signed, and really large ranges will show up as negative numbers. */ || compare_tree_int (range, 0) < 0 -#ifndef ASM_OUTPUT_ADDR_DIFF_ELT - || flag_pic -#endif || !flag_jump_tables || TREE_CONSTANT (index_expr) /* If neither casesi or tablejump is available, we can