From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31398 invoked by alias); 2 Nov 2010 20:26:03 -0000 Received: (qmail 31377 invoked by uid 22791); 2 Nov 2010 20:25:56 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,MISSING_MID X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 02 Nov 2010 20:25:52 +0000 From: "johnstonj@inn-soft.com" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/38549] [avr] eicall not properly set for > 128K program space X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: johnstonj@inn-soft.com X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: CC In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Tue, 02 Nov 2010 20:26:00 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2010-11/txt/msg00199.txt.bz2 Message-ID: <20101102202600.2NNkdK27QSl6iEKJZ0rW2CAokbBPQL441QdijrB4Nlg@z> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38549 johnstonj@inn-soft.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |johnstonj@inn-soft.com --- Comment #5 from johnstonj@inn-soft.com 2010-11-02 20:25:05 UTC --- I can confirm this is indeed a problem. I am developing a bootloader for ATxmega128A1 (128 KB app flash + 8 KB bootloader = 136 KB flash total). My code: #define PROG_START 0x0000 (*((void(*)(void))PROG_START))(); //jump This emits the following: # Notice on reset, EIND register is written to a 1 as shown here. # I searched the entire emitted disassembly and found no other # reference to the I/O address for EIND. 000202e0 <__ctors_end>: ... 202ec: 01 e0 ldi r16, 0x01 ; 1 202ee: 0c bf out 0x3c, r16 ; 60 # Notice that Z is set to 0, as expected. However, EIND is not # set to 0 and so the processor attempts to do the jump to # the location specified by EIND == 1 and Z == 0, which isn't a valid # place to jump to. (*((void(*)(void))PROG_START))(); //jump 20590: e0 e0 ldi r30, 0x00 ; 0 20592: f0 e0 ldi r31, 0x00 ; 0 20594: 19 95 eicall Presumably this will come up much more frequently now that the ATxmega processors are available: all of these have so much flash that I would imagine this will be a frequent problem. I assume the problem happens with EIJMP which also uses EIND. I notice that eicall / eijmp are used in libgcc.s. I wouldn't be surprised if there are bugs there, too - but did not investigate further. My fix is simple; just set EIND = 0 before my jump. However it leaves little faith in my compiler for the application itself, since I don't know if it will work reliably on AVR with large flash space for all jumps and calls, etc.