From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19220 invoked by alias); 13 Dec 2019 11:16:02 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 18956 invoked by uid 89); 13 Dec 2019 11:16:00 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-4.1 required=5.0 tests=AWL,BAYES_00,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mo4-p00-ob.smtp.rzone.de Received: from mo4-p00-ob.smtp.rzone.de (HELO mo4-p00-ob.smtp.rzone.de) (85.215.255.25) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 13 Dec 2019 11:15:58 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1576235755; s=strato-dkim-0002; d=gjlay.de; h=Date:Message-ID:Subject:From:To:X-RZG-CLASS-ID:X-RZG-AUTH:From: Subject:Sender; bh=WH/InWG/F5938Ee5tbXlVwclYqlOX2JotGZCK3PbEOM=; b=Q5B9BkvLaI/tFqBEpaTLULJkmw/mqSa0aOt2LRjld6kgJC1NTyp6ZzBBhs6+9Nl4Ka Bmxk3PH7T7q++PgCwwoQCnVV8sK5usLQc4mMPnTudPxJztLFzJYmTE8HS1p8mUJmGl9Y SBWjmolR8qVXoxo0KWgJ1ckNDQ/RMn3XNOWUHQIK8jS5M2zJbDB5gEve7C7AbtDWDmnW DclnybrdXLo9x5fRuub7Ox7V4MCpIKqahegdmvpIoxWh13sjvjVv7ghqMZbIWqojvcQj hYt0lmL+VnJTTxd2JisoZQBHJJ4CkoQx8FiOIZPJV0Errhk/mMhhacLDWlB8C+5TvaY8 lgFg== Received: from [192.168.22.245] by smtp.strato.de (RZmta 46.0.7 AUTH) with ESMTPSA id Y0651dvBDBFt7Pp (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256 bits)) (Client did not present a certificate) for ; Fri, 13 Dec 2019 12:15:55 +0100 (CET) To: gcc-help@gcc.gnu.org From: Georg-Johann Lay Subject: PR92606: Which target hook to disallow symbol aliasing? Message-ID: <83212247-3bcf-914d-34d0-175b268596fa@gjlay.de> Date: Fri, 13 Dec 2019 11:16:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2019-12/txt/msg00051.txt.bz2 Hi, gcc generates wrong code when it aliases symbols like in (For a complete test cases cf. PR92606): static const __attribute((progmem)) int xyz_prog[] = { 123, 123, 123 }; int xyz[] = { 123, 123, 123 }; for target avr. xyz and xyz_prog are binary the same, but the program accesses them with different instructions (LPM for the 1st to read from flash, LD in the 2nd case to read from RAM). The bug is that the compiler issues .section .progmem.data,"a",@progbits .type xyz_prog, @object .size xyz_prog, 12 xyz_prog: .byte 123 ... .set xyz,xyz_prog which is obviously wrong because the symbols MUST NOT alias each other. As I failed to find the target hook that disables such aliasing; please would someone point me to it? Johann FYI, the generated code is also wrong with names address spaces: static const __flash int xyz_prog[] = { 123, 123, 123 }; int xyz[] = { 123, 123, 123 }; again, PR92606 has a test case: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92606#c3