From patchwork Fri Nov 18 13:31:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Georg-Johann Lay X-Patchwork-Id: 696567 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 3tKzS73n6Lz9t37 for ; Sat, 19 Nov 2016 00:32:05 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="loPM6Ldt"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=SrzRGj9r6+ZQk7CT6vgAoNWHVTlUPYde9D8mtPCf+F+CyQRUhm rzBtfT9VeVWiagy7+7wnX6MN1sdFKsa5p/Ybv06w6WH6D4jbqU1XiJqS4HNz1Hqj AP6kbW6pqTxL4TyRBu9wpvIenGPADSEl2VWvIgcrALA/gKZTPoCvb134U= 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:to:cc :from:subject:message-id:date:mime-version:content-type; s= default; bh=m1XBWKA1blI9hZJpZs1jliGaJ+8=; b=loPM6LdtTGSkYmITgCq1 xSXuyDPUNsGl9LqjPBFS+JT6dBMBenQVShID9WNXApMmuO453arOnpuEzXiwf6dr OgZkFwrma0EKfHgFfuLFc5a32ZOrNwtyItcq0JactfMGJBqznctsKm4C9w2ERy0z VZFAxHB8lrPw53hUFBjd4TU= Received: (qmail 55814 invoked by alias); 18 Nov 2016 13:31:58 -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 55790 invoked by uid 89); 18 Nov 2016 13:31:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy=Disallow, Hx-languages-length:2040, 101026, applicable X-HELO: mo4-p00-ob.smtp.rzone.de Received: from mo4-p00-ob.smtp.rzone.de (HELO mo4-p00-ob.smtp.rzone.de) (81.169.146.221) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 18 Nov 2016 13:31:47 +0000 X-RZG-AUTH: :LXoWVUeid/7A29J/hMvvT3ol15ykJcYwR/bcHRirORRW3yMcVao= X-RZG-CLASS-ID: mo00 Received: from [192.168.0.123] (mail.hightec-rt.com [213.135.1.215]) by smtp.strato.de (RZmta 39.9 DYNA|AUTH) with ESMTPSA id u0b573sAIDVhZyi (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA (curve secp521r1 with 521 ECDH bits, eq. 15360 bits RSA)) (Client did not present a certificate); Fri, 18 Nov 2016 14:31:43 +0100 (CET) To: gcc-patches Cc: Denis Chertykov , Senthil Kumar Selvaraj , Pitchumani Sivanupandi From: Georg-Johann Lay Subject: [patch,avr] Disallow LDS / STS for .rodata on AVR_TINY. Message-ID: <540210d1-fe71-bc83-35e4-443ee1084b03@gjlay.de> Date: Fri, 18 Nov 2016 14:31:42 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 X-IsSubscribed: yes Currently, Binutils still comes with an AVR_TINY linker description file which puts .rodata into RAM so that LDS is applicable for reading such objects. However, as these devices come with a linearised address model, linker descriptions which put .rodata into flash are much more reasonable. This patch caters for such situations: As .rodata virtual addresses will be offset by 0x4000, respective objects may no more be accessed by LDS. Moreover, objects with a section attribute won't be accessed by LDS. Ok for trunk? Johann PR target/78093 * config/avr/avr.c (avr_decl_maybe_lds_p): New static function. (avr_encode_section_info) [TARGET_ABSDATA && AVR_TINY]: Use it. Index: config/avr/avr.c =================================================================== --- config/avr/avr.c (revision 242544) +++ config/avr/avr.c (working copy) @@ -10102,6 +10102,33 @@ avr_section_type_flags (tree decl, const } +/* A helper for the next function. NODE is a decl that is associated with + a symbol. Return TRUE if the respective object may be accessed by LDS. + There migth still be other reasons for why LDS is not appropriate. + This function is only useful for AVR_TINY. */ + +static bool +avr_decl_maybe_lds_p (tree node) +{ + if (!node + || TREE_CODE (node) != VAR_DECL + || DECL_SECTION_NAME (node) != NULL) + return false; + + if (TREE_READONLY (node)) + return true; + + // C++ requires peeling arrays. + + do + node = TREE_TYPE (node); + while (ARRAY_TYPE == TREE_CODE (node)); + + return (node != error_mark_node + && !TYPE_READONLY (node)); +} + + /* Implement `TARGET_ENCODE_SECTION_INFO'. */ static void @@ -10193,7 +10220,8 @@ avr_encode_section_info (tree decl, rtx if (avr_decl_absdata_p (decl, DECL_ATTRIBUTES (decl)) || (TARGET_ABSDATA && !progmem_p - && !addr_attr) + && !addr_attr + && avr_decl_maybe_lds_p (decl)) || (addr_attr // If addr_attr is non-null, it has an argument. Peek into it. && TREE_INT_CST_LOW (TREE_VALUE (TREE_VALUE (addr_attr))) < 0xc0))