Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug
Bug#: 29141
Product:  
Component:  
Status: RESOLVED
Resolution: FIXED
Assigned To: Not yet assigned to anyone <unassigned@gcc.gnu.org>
Host:
Reported against  
Priority:  
Severity:  
Target Milestone:  
 
 
Target:
Reporter: Jörg Diederich <joerg.diederich@graffiti.net>
Add CC:
CC:
Remove selected CCs
Build:
URL:
Summary:
Keywords:
Known to work:
Known to fail:

Attachment Description Type Created Size Actions
a_test.cpp example source file text/x-c++src 2006-09-19 13:28 193 bytes Edit
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 29141 depends on: Show dependency tree
Show dependency graph
Bug 29141 blocks:

Additional Comments:






View Bug Activity   |   Format For Printing   |   Clone This Bug


Description:   Last confirmed: 2008-10-30 16:03 Opened: 2006-09-19 13:26
Contruction of global static objects fails while using flash adresses over
0xFFFF, e.g. for bootloader purposes. avr mcu hangs completly before main or
even the called constructor itself.

minimal gcc call: 
avr-c++ -c -mmcu=at90can128 -I. -I. -g -O0 -Wall -Wextra -Wshadow
-Wpointer-arith -Wcast-align -Wsign-compare -Waggregate-return -Wunused
 -fno-exceptions  a_test.cpp -o a_test.o

linked with the following options
-Wl,-Map=a_test.map,--cref,--section-start=.text=0x1F000

short example code in attachment.

------- Comment #1 From Jörg Diederich 2006-09-19 13:28 -------
Created an attachment (id=12297) [edit]
example source file

------- Comment #2 From Jörg Diederich 2006-09-19 13:36 -------
thanks to joerg wunsch, additional information is already available.

#ifdef L_ctors
        .section .init6,"ax",@progbits
        .global __do_global_ctors
__do_global_ctors:
        ldi     r17, hi8(__ctors_start)
        ldi     r28, lo8(__ctors_end)
        ldi     r29, hi8(__ctors_end)
        rjmp    .do_global_ctors_start
.do_global_ctors_loop:
        sbiw    r28, 2
        mov_h   r31, r29
        mov_l   r30, r28
        XCALL   __tablejump__
.do_global_ctors_start:
        cpi     r28, lo8(__ctors_start)
        cpc     r29, r17
        brne    .do_global_ctors_loop
#endif /* L_ctors */

using r28/r29 only works for data <64k. r30/r31 are filled with wrong data in
return, in detail 64k less than intended.

------- Comment #3 From Pete Vavaroutsos 2007-02-02 22:19 -------
I too have ran into this problem. The code in __tablejump__ that calls the
constructors is using LPM instructions instead of ELPM, so the value in the
RAMPZ register is being ignored. Thus a bad pointer to the constructor is
fetched.

------- Comment #4 From Eric Weddington 2008-10-30 16:03 -------
See also WinAVR bug #2209796 on SourceForge:
https://sourceforge.net/tracker/?func=detail&atid=520074&aid=2209796&group_id=68108

------- Comment #5 From aesok@gcc.gnu.org 2009-01-12 20:42 -------
Subject: Bug 29141

Author: aesok
Date: Mon Jan 12 20:41:57 2009
New Revision: 143306

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=143306
Log:
        PR target/29141
        * config/avr/t-avr (LIB1ASMFUNCS): Add _tablejump_elpm.
        * config/avr/libgcc.S (__do_global_ctors, __do_global_dtors): Add
        variant for devices with 3-byte PC.
        (__tablejump_elpm__) : New.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/avr/libgcc.S
    trunk/gcc/config/avr/t-avr

------- Comment #6 From aesok@gcc.gnu.org 2009-01-28 17:53 -------
Fixed.

Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug