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: 82894 Delivered-To: patch@linaro.org Received: by 10.140.97.165 with SMTP id m34csp77693qge; Fri, 18 Nov 2016 05:32:11 -0800 (PST) X-Received: by 10.37.173.1 with SMTP id y1mr4365959ybi.88.1479475931325; Fri, 18 Nov 2016 05:32:11 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id 204si1695829ywo.92.2016.11.18.05.32.11 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 Nov 2016 05:32:11 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-441944-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-441944-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-441944-patch=linaro.org@gcc.gnu.org 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=fIHDyYpFCr/W1skFmG3kDC0vHvRWfGoXZjHAdE03CzV0Ezq/fX 38kIS9QKTnb0H3YaUTIJGG9tYoFDrjxITxwaGVq2tVc3tRxCWwCQcjVGW70I8opS 05RZmCNpekFaAuTOR5hRnnuepVniukIKMxH4abJVOiZLAzjvSw3vpI4pA= 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=kU7605L169REB9z22mw4 JevTzCEJs7WPvBCjnAsuGT5PELPFKYowFEBOdgodKMW/bjY+AigItGNe2Z0mApa9 zpDKfrTU8CQBzoLFNsM0H6BB4dXHoSnbpzgqhvWTM7Lw428qZXNF05zutPHoP49M ojdm0ucxC/ZdyxNxfYSMF8s= 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))