avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-gcc-list] C++/ATmega128 support for gcc-3.0.3


From: Peter Jansen
Subject: [avr-gcc-list] C++/ATmega128 support for gcc-3.0.3
Date: Tue, 05 Feb 2002 17:52:56 +1100

Hi All,

Attached is a patch for gcc-3.0.3 with all the ATmeg128 stuff in it and
the C++ stuff in it.

The destructor function run the destructors in the wrong direction, does
anyone have any ideas on how to fix it in libgcc.S? would anyone ever
use the destructors on an embedded system?

Can we get this into gcc-3.0.4 which is due to released 15 Feb?

Regards,

-- 
Peter Jansen
Smart Container
Level 1, NIC Building
Eveleigh
NSW       1430
AUSTRALIA
diff -c3pr gcc-3.0.3/ChangeLog gcc-3.0.3-patch-0.1/ChangeLog
*** gcc-3.0.3/ChangeLog Fri Dec 21 06:20:57 2001
--- gcc-3.0.3-patch-0.1/ChangeLog       Tue Feb  5 17:01:23 2002
***************
*** 1,3 ****
--- 1,7 ----
+ 2002-02-05  Peter Jansen <address@hidden>
+ 
+       * Changed AVR build not to build libstdc++, libiberty for target
+ 
  2001-12-20  Release Manager
  
        * GCC 3.0.3 Released.
diff -c3pr gcc-3.0.3/configure.in gcc-3.0.3-patch-0.1/configure.in
*** gcc-3.0.3/configure.in      Tue Aug 14 02:14:49 2001
--- gcc-3.0.3-patch-0.1/configure.in    Tue Feb  5 10:41:18 2002
*************** case "${target}" in
*** 713,718 ****
--- 713,721 ----
    arm-*-riscix*)
      noconfigdirs="$noconfigdirs ld target-libgloss ${libgcj}"
      ;;
+   avr-*-*)
+     noconfigdirs="$noconfigdirs target-libiberty ${libstdcxx_version} 
${libgcj}"
+     ;;
    d10v-*-*)
      noconfigdirs="$noconfigdirs target-librx ${libstdcxx_version} 
target-libgloss ${libgcj}"
      ;;
diff -c3pr gcc-3.0.3/gcc/ChangeLog gcc-3.0.3-patch-0.1/gcc/ChangeLog
*** gcc-3.0.3/gcc/ChangeLog     Fri Dec 21 06:21:30 2001
--- gcc-3.0.3-patch-0.1/gcc/ChangeLog   Tue Feb  5 17:00:17 2002
***************
*** 1,3 ****
--- 1,11 ----
+ 2002-02-05  Peter Jansen <address@hidden>
+ 
+       * config/avr.h Added ATmega128 Support, C++ support
+       * config/libgcc.S Added C++ constructor/destructor functions
+       * config/avr/t-avr Added C++ constrcutor/destructor objects
+       Also added ATmega128 support.
+       * config/avr/avr.c Added ATmega128 Support
+ 
  2001-12-20  Release Manager
  
        * GCC 3.0.3 Released.
diff -c3pr gcc-3.0.3/gcc/config/avr/avr.c 
gcc-3.0.3-patch-0.1/gcc/config/avr/avr.c
*** gcc-3.0.3/gcc/config/avr/avr.c      Thu Jun 28 07:35:37 2001
--- gcc-3.0.3-patch-0.1/gcc/config/avr/avr.c    Tue Feb  5 10:37:05 2002
*************** static const struct mcu_type_s avr_mcu_t
*** 153,158 ****
--- 153,159 ----
    { "atmega163", AVR5 },
    { "atmega32",  AVR5 },
    { "at94k",     AVR5 },
+   { "atmega128", AVR5 },
      /* Assembler only.  */
    { "avr1",      AVR1 },
    { "at90s1200", AVR1 },
*************** class_max_nregs (class, mode)
*** 1164,1170 ****
  /* Choose mode for jump insn:
     1 - relative jump in range -63 <= x <= 62 ;
     2 - relative jump in range -2046 <= x <= 2045 ;
!    3 - absolute jump (only for ATmega[16]03).  */
  
  int
  avr_jump_mode (x, insn)
--- 1165,1171 ----
  /* Choose mode for jump insn:
     1 - relative jump in range -63 <= x <= 62 ;
     2 - relative jump in range -2046 <= x <= 2045 ;
!    3 - absolute jump (only for ATmega1[6][03][28]).  */
  
  int
  avr_jump_mode (x, insn)
diff -c3pr gcc-3.0.3/gcc/config/avr/avr.h 
gcc-3.0.3-patch-0.1/gcc/config/avr/avr.h
*** gcc-3.0.3/gcc/config/avr/avr.h      Tue Apr 17 04:25:42 2001
--- gcc-3.0.3-patch-0.1/gcc/config/avr/avr.h    Tue Feb  5 16:33:55 2002
*************** do {                                                            
            \
*** 1981,2003 ****
     scheduling priorities of insns.  */
  
  
! #define TEXT_SECTION_ASM_OP "\t.text"
  /* A C expression whose value is a string containing the assembler
     operation that should precede instructions and read-only data.
     Normally `"\t.text"' is right.  */
  
  #define DATA_SECTION_ASM_OP "\t.data"
  /* A C expression whose value is a string containing the assembler
     operation to identify the following data as writable initialized
     data.  Normally `"\t.data"' is right.  */
  
! #define EXTRA_SECTIONS in_progmem
  /* A list of names for sections other than the standard two, which are
     `in_text' and `in_data'.  You need not define this macro on a
     system with no other sections (that GCC needs to use).  */
  
! #define EXTRA_SECTION_FUNCTIONS                                               
      \
!                                                                             \
  void                                                                        \
  progmem_section (void)                                                        
      \
  {                                                                           \
--- 1981,2065 ----
     scheduling priorities of insns.  */
  
  
! #define TEXT_SECTION_ASM_OP "\t.text\t"
! 
  /* A C expression whose value is a string containing the assembler
     operation that should precede instructions and read-only data.
     Normally `"\t.text"' is right.  */
  
  #define DATA_SECTION_ASM_OP "\t.data"
+ 
  /* A C expression whose value is a string containing the assembler
     operation to identify the following data as writable initialized
     data.  Normally `"\t.data"' is right.  */
  
! #define CONST_SECTION_ASM_OP  "\t.section\t.rodata"
! 
! #define BSS_SECTION_ASM_OP    "\t.section\t.bss"
! 
! /* Define the pseudo-ops used to switch to the .ctors and .dtors sections.
! 
!    Note that we want to give these sections the SHF_WRITE attribute
!    because these sections will actually contain data (i.e. tables of
!    addresses of functions in the current root executable or shared library
!    file) and, in the case of a shared library, the relocatable addresses
!    will have to be properly resolved/relocated (and then written into) by
!    the dynamic linker when it actually attaches the given shared library
!    to the executing process.  (Note that on SVR4, you may wish to use the
!    `-z text' option to the ELF linker, when building a shared library, as
!    an additional check that you are doing everything right.  But if you do
!    use the `-z text' option when building a shared library, you will get
!    errors unless the .ctors and .dtors sections are marked as writable
!    via the SHF_WRITE attribute.)  */
! 
! #define CTORS_SECTION_ASM_OP  "\t.section\t.ctors,\"aw\""
! #define DTORS_SECTION_ASM_OP  "\t.section\t.dtors,\"aw\""
! 
! /* On svr4, we *do* have support for the .init and .fini sections, and we
!    can put stuff in there to be executed before and after `main'.  We let
!    crtstuff.c and other files know this by defining the following symbols.
!    The definitions say how to change sections to the .init and .fini
!    sections.  This is the same for all known svr4 assemblers.  */
! 
! #define INIT_SECTION_ASM_OP   "\t.section\t.init"
! #define FINI_SECTION_ASM_OP   "\t.section\t.fini"
! 
! #define CTORS_SECTION_FUNCTION                                        \
! void                                                          \
! ctors_section ()                                              \
! {                                                             \
!   if (in_section != in_ctors)                                 \
!     {                                                         \
!       fprintf (asm_out_file, "\t.globl\t__do_global_ctors\n");  \
!       fprintf (asm_out_file, "%s\n", CTORS_SECTION_ASM_OP);   \
!       in_section = in_ctors;                                  \
!     }                                                         \
! }
! 
! #define DTORS_SECTION_FUNCTION                                        \
! void                                                          \
! dtors_section ()                                              \
! {                                                             \
!   if (in_section != in_dtors)                                 \
!     {                                                         \
!       fprintf (asm_out_file, "\t.globl\t__do_global_dtors\n");  \
!       fprintf (asm_out_file, "%s\n", DTORS_SECTION_ASM_OP);   \
!       in_section = in_dtors;                                  \
!     }                                                         \
! }
! 
! #define EXTRA_SECTIONS in_progmem, in_ctors, in_dtors
  /* A list of names for sections other than the standard two, which are
     `in_text' and `in_data'.  You need not define this macro on a
     system with no other sections (that GCC needs to use).  */
  
! #undef  EXTRA_SECTION_FUNCTIONS
! #define EXTRA_SECTION_FUNCTIONS \
!       PROGMEM_SECTION_FUNCTION \
!       CTORS_SECTION_FUNCTION \
!       DTORS_SECTION_FUNCTION
! 
! #define PROGMEM_SECTION_FUNCTION                                            \
  void                                                                        \
  progmem_section (void)                                                        
      \
  {                                                                           \
*************** progmem_section (void)                                          
              \
*** 2011,2016 ****
--- 2073,2117 ----
        in_section = in_progmem;                                                
      \
      }                                                                       \
  }
+ 
+ /* This is the pseudo-op used to generate a reference to a specific
+    symbol in some section.  It is only used in machine-specific
+    configuration files, typically only in ASM_OUTPUT_CONSTRUCTOR and
+    ASM_OUTPUT_DESTRUCTOR.  This is the same for all known svr4
+    assemblers, except those in targets that don't use 32-bit pointers.
+    Those should override INT_ASM_OP.  Yes, the name of the macro is
+    misleading.  */
+ 
+ #ifndef INT_ASM_OP
+ #define INT_ASM_OP            "\t.short\t"
+ #endif
+ 
+ 
+ /* A C statement (sans semicolon) to output an
+    element in the table of global constructors.  */
+ #define ASM_OUTPUT_CONSTRUCTOR(FILE, NAME)                    \
+   do                                                          \
+     {                                                         \
+       ctors_section ();                                               \
+       fprintf (FILE, "%spm(", INT_ASM_OP);                            \
+       assemble_name (FILE, NAME);                             \
+       fprintf (FILE, ")\t;; constructor is a word address\n");        \
+     }                                                         \
+   while (0)
+ 
+ /* A C statement (sans semicolon) to output an
+    element in the table of global destructors.  */
+ #define ASM_OUTPUT_DESTRUCTOR(FILE,NAME)                              \
+   do                                                          \
+     {                                                         \
+       dtors_section ();                                       \
+       fprintf (FILE, "%spm(", INT_ASM_OP);                            \
+       assemble_name (FILE, NAME);                                     \
+       fprintf (FILE, ")\t;; destructor is a word address\n");         \
+     }                                                         \
+   while (0)
+ 
+ 
  /* `EXTRA_SECTION_FUNCTIONS'
     One or more functions to be defined in `varasm.c'.  These
     functions should do jobs analogous to those of `text_section' and
*************** progmem_section (void)                                          
              \
*** 2244,2249 ****
--- 2345,2365 ----
     These macros are provided by `real.h' for writing the definitions of
     `ASM_OUTPUT_DOUBLE' and the like:  */
  
+ #define ASM_OUTPUT_BSS(STREAM, DECL, NAME, SIZE, ROUNDED)                \
+     asm_output_bss(STREAM, DECL, NAME, SIZE, ROUNDED)
+ 
+ /* A C statement (sans semicolon) to output to the stdio stream
+    STREAM the assembler definition of a bss named NAME whose
+    size is SIZE bytes.  The variable ROUNDED is the size rounded up
+    to whatever alignment the caller wants.
+ 
+    Use the expression `assemble_name (STREAM, NAME)' to output the
+    name itself; before and after that, output the additional
+    assembler syntax for defining the name, and a newline.
+ 
+    This macro controls how the assembler definitions of uninitialized
+    global variables are output.  */
+ 
  #define ASM_OUTPUT_COMMON(STREAM, NAME, SIZE, ROUNDED)                        
   \
  do {                                                                     \
       fputs ("\t.comm ", (STREAM));                                       \
*************** valid_machine_decl_attribute (DECL, ATTR
*** 2973,2978 ****
--- 3089,3095 ----
  %{mmcu=avr3:%(cpp_avr3)} \
  %{mmcu=atmega603:%(cpp_avr3) -D__AVR_ATmega603__} \
  %{mmcu=atmega103:%(cpp_avr3) -D__AVR_ATmega103__} \
+ %{mmcu=atmega128:%(cpp_avr5) -D__AVR_ATmega128__} \
  %{mmcu=avr4:%(cpp_avr4)} \
  %{mmcu=atmega83: %(cpp_avr4) -D__AVR_ATmega83__} \
  %{mmcu=atmega85: %(cpp_avr4) -D__AVR_ATmega85__} \
*************** valid_machine_decl_attribute (DECL, ATTR
*** 3051,3056 ****
--- 3168,3174 ----
  %{!mmcu*:-m avr85xx} \
  %{mmcu=atmega603:-m avrmega603} \
  %{mmcu=atmega103:-m avrmega103} \
+ %{mmcu=atmega128:-m avrmega128} \
  %{mmcu=atmega161:-m avrmega161} \
  %{mmcu=atmega163:-m avrmega161} \
  %{mmcu=atmega32:-m avr5} \
*************** valid_machine_decl_attribute (DECL, ATTR
*** 3086,3091 ****
--- 3204,3212 ----
     If this macro is not defined, a default is provided that loads the
     standard C library from the usual place.  See `gcc.c'.  */
  
+ #define LIBSTDCXX ""
+ /* library to add by default for c++ linkage, this defaults to -lstdc++ */
+ 
  #define LIBGCC_SPEC \
    "%{!mmcu=at90s1*:%{!mmcu=attiny1*:%{!mmcu=attiny28: -lgcc }}}"
  /* Another C string constant that tells the GNU CC driver program how
*************** valid_machine_decl_attribute (DECL, ATTR
*** 3130,3135 ****
--- 3251,3257 ----
  %{mmcu=at90c8534:crtc8534.o%s} \
  %{mmcu=at90s8535:crts8535.o%s} \
  %{mmcu=atmega103|mmcu=avr3:crtm103.o%s} \
+ %{mmcu=atmega128|mmcu=avr5:crtm128.o%s} \
  %{mmcu=atmega603:crtm603.o%s} \
  %{mmcu=atmega83|mmcu=avr4:crtm83.o%s} \
  %{mmcu=atmega85:crtm85.o%s} \
diff -c3pr gcc-3.0.3/gcc/config/avr/libgcc.S 
gcc-3.0.3-patch-0.1/gcc/config/avr/libgcc.S
*** gcc-3.0.3/gcc/config/avr/libgcc.S   Sun Apr  1 02:36:08 2001
--- gcc-3.0.3-patch-0.1/gcc/config/avr/libgcc.S Tue Feb  5 10:37:05 2002
*************** Boston, MA 02111-1307, USA.  */
*** 31,36 ****
--- 31,37 ----
  #define __SREG__ 0x3f
  #define __SP_H__ 0x3e
  #define __SP_L__ 0x3d
+ #define __RAMPZ__ 0x3b
  
  /* Most of the functions here are called directly from avr.md
     patterns, instead of using the standard libcall mechanisms.
*************** __mulqi3_loop:
*** 75,90 ****
        add     r_res,r_arg2
        add     r_arg2,r_arg2   ; shift multiplicand
        breq    __mulqi3_exit   ; while multiplicand != 0
!       lsr     r_arg1          ; 
        brne    __mulqi3_loop   ; exit if multiplier = 0
! __mulqi3_exit:        
        mov     r_arg1,r_res    ; result to return register
        ret
  
! #undef r_arg2  
! #undef r_arg1  
! #undef r_res   
!       
  .endfunc
  #endif        /* defined (L_mulqi3) */
  
--- 76,91 ----
        add     r_res,r_arg2
        add     r_arg2,r_arg2   ; shift multiplicand
        breq    __mulqi3_exit   ; while multiplicand != 0
!       lsr     r_arg1          ;
        brne    __mulqi3_loop   ; exit if multiplier = 0
! __mulqi3_exit:
        mov     r_arg1,r_res    ; result to return register
        ret
  
! #undef r_arg2
! #undef r_arg1
! #undef r_res
! 
  .endfunc
  #endif        /* defined (L_mulqi3) */
  
*************** __mulhi3_loop:
*** 133,139 ****
        rjmp    __mulhi3_skip1
        add     r_resL,r_arg2L  ; result + multiplicand
        adc     r_resH,r_arg2H
! __mulhi3_skip1:       
        add     r_arg2L,r_arg2L ; shift multiplicand
        adc     r_arg2H,r_arg2H
  
--- 134,140 ----
        rjmp    __mulhi3_skip1
        add     r_resL,r_arg2L  ; result + multiplicand
        adc     r_resH,r_arg2H
! __mulhi3_skip1:
        add     r_arg2L,r_arg2L ; shift multiplicand
        adc     r_arg2H,r_arg2H
  
*************** __mulhi3_exit:
*** 154,161 ****
  #undef r_arg1H
  #undef r_arg2L
  #undef r_arg2H
! #undef r_resL         
! #undef r_resH 
  
  .endfunc
  #endif /* defined (L_mulhi3) */
--- 155,162 ----
  #undef r_arg1H
  #undef r_arg2L
  #undef r_arg2H
! #undef r_resL
! #undef r_resH
  
  .endfunc
  #endif /* defined (L_mulhi3) */
*************** __umulhisi3:
*** 204,219 ****
  
  
  #define       r_arg2L  r18            /* multiplicand Low */
! #define       r_arg2H  r19    
  #define       r_arg2HL r20
  #define       r_arg2HH r21            /* multiplicand High */
!       
  #define r_resL         r26            /* result Low */
  #define r_resH   r27
  #define r_resHL        r30
  #define r_resHH  r31          /* result High */
  
!       
        .global __mulsi3
        .func   __mulsi3
  __mulsi3:
--- 205,220 ----
  
  
  #define       r_arg2L  r18            /* multiplicand Low */
! #define       r_arg2H  r19
  #define       r_arg2HL r20
  #define       r_arg2HH r21            /* multiplicand High */
! 
  #define r_resL         r26            /* result Low */
  #define r_resH   r27
  #define r_resHL        r30
  #define r_resHH  r31          /* result High */
  
! 
        .global __mulsi3
        .func   __mulsi3
  __mulsi3:
*************** __mulsi3_skip1:
*** 266,272 ****
        adc     r_arg2H,r_arg2H
        adc     r_arg2HL,r_arg2HL
        adc     r_arg2HH,r_arg2HH
!       
        lsr     r_arg1HH        ; gets LSB of multiplier
        ror     r_arg1HL
        ror     r_arg1H
--- 267,273 ----
        adc     r_arg2H,r_arg2H
        adc     r_arg2HL,r_arg2HL
        adc     r_arg2HH,r_arg2HH
! 
        lsr     r_arg1HH        ; gets LSB of multiplier
        ror     r_arg1HL
        ror     r_arg1H
*************** __mulsi3_exit:
*** 282,306 ****
        mov     r_arg1L,r_resL
        ret
  #endif /* !defined (__AVR_ENHANCED__) */
! #undef r_arg1L 
! #undef r_arg1H 
  #undef r_arg1HL
  #undef r_arg1HH
!              
!              
! #undef r_arg2L 
! #undef r_arg2H 
  #undef r_arg2HL
  #undef r_arg2HH
!              
! #undef r_resL  
! #undef r_resH  
! #undef r_resHL 
! #undef r_resHH 
  
  .endfunc
  #endif /* defined (L_mulsi3) */
!       
  /*******************************************************
         Division 8 / 8 => (result + remainder)
  *******************************************************/
--- 283,307 ----
        mov     r_arg1L,r_resL
        ret
  #endif /* !defined (__AVR_ENHANCED__) */
! #undef r_arg1L
! #undef r_arg1H
  #undef r_arg1HL
  #undef r_arg1HH
! 
! 
! #undef r_arg2L
! #undef r_arg2H
  #undef r_arg2HL
  #undef r_arg2HH
! 
! #undef r_resL
! #undef r_resH
! #undef r_resHL
! #undef r_resHH
  
  .endfunc
  #endif /* defined (L_mulsi3) */
! 
  /*******************************************************
         Division 8 / 8 => (result + remainder)
  *******************************************************/
*************** __udivmodqi4_ep:
*** 325,331 ****
        rol     r_arg1          ; shift dividend (with CARRY)
        dec     r_cnt           ; decrement loop counter
        brne    __udivmodqi4_loop
!       com     r_arg1          ; complement result 
                                ; because C flag was complemented in loop
        ret
        .endfunc
--- 326,332 ----
        rol     r_arg1          ; shift dividend (with CARRY)
        dec     r_cnt           ; decrement loop counter
        brne    __udivmodqi4_loop
!       com     r_arg1          ; complement result
                                ; because C flag was complemented in loop
        ret
        .endfunc
*************** __divmodqi4_exit:
*** 357,364 ****
  #undef r_arg1
  #undef r_arg2
  #undef r_cnt
!       
!               
  /*******************************************************
         Division 16 / 16 => (result + remainder)
  *******************************************************/
--- 358,365 ----
  #undef r_arg1
  #undef r_arg2
  #undef r_cnt
! 
! 
  /*******************************************************
         Division 16 / 16 => (result + remainder)
  *******************************************************/
*************** __divmodqi4_exit:
*** 372,378 ****
  /* return: quotient */
  #define       r_arg2L r22     /* divisor Low */
  #define       r_arg2H r23     /* divisor High */
!       
  #define       r_cnt   r21     /* loop count */
  
  #if defined (L_udivmodhi4)
--- 373,379 ----
  /* return: quotient */
  #define       r_arg2L r22     /* divisor Low */
  #define       r_arg2H r23     /* divisor High */
! 
  #define       r_cnt   r21     /* loop count */
  
  #if defined (L_udivmodhi4)
*************** __divmodhi4_neg1:
*** 438,454 ****
        .endfunc
  #endif /* defined (L_divmodhi4) */
  
! #undef r_remH  
! #undef r_remL  
!              
! #undef r_arg1H 
! #undef r_arg1L 
!              
! #undef r_arg2H 
! #undef r_arg2L 
!               
! #undef r_cnt          
!       
  /*******************************************************
         Division 32 / 32 => (result + remainder)
  *******************************************************/
--- 439,455 ----
        .endfunc
  #endif /* defined (L_divmodhi4) */
  
! #undef r_remH
! #undef r_remL
! 
! #undef r_arg1H
! #undef r_arg1L
! 
! #undef r_arg2H
! #undef r_arg2L
! 
! #undef r_cnt
! 
  /*******************************************************
         Division 32 / 32 => (result + remainder)
  *******************************************************/
*************** __divmodhi4_neg1:
*** 468,474 ****
  #define       r_arg2HL r20
  #define       r_arg2H  r19
  #define       r_arg2L  r18    /* divisor Low */
!       
  #define       r_cnt __zero_reg__  /* loop count (0 after the loop!) */
  
  #if defined (L_udivmodsi4)
--- 469,475 ----
  #define       r_arg2HL r20
  #define       r_arg2H  r19
  #define       r_arg2L  r18    /* divisor Low */
! 
  #define       r_cnt __zero_reg__  /* loop count (0 after the loop!) */
  
  #if defined (L_udivmodsi4)
*************** __tablejump2__:
*** 674,676 ****
--- 675,752 ----
  .endfunc
  #endif /* defined (L_tablejump) */
  
+ #ifdef L_ctor
+         .sect   .init3,"ax",@progbits
+         .globl  __do_global_ctors
+ ;;
+ ;; Run through constructor table.
+ ;; This needs to be run before main is called.
+ ;;
+ #define ZH r31
+ #define ZL r30
+ #define XH r27
+ #define XL r26
+ 
+ __do_global_ctors:
+ #if defined (__AVR_ENHANCED__) && defined (__AVR_MEGA__)
+       ldi     ZL, lo8(__CTOR_LIST__)
+       ldi     ZH, hi8(__CTOR_LIST__)
+       ldi     r16, hh8(__CTOR_LIST__) ; init the RAMPZ value
+       out     __RAMPZ__, r16
+ _ctorsLoop:
+       cpi     ZL, lo8(__CTOR_END__)
+       brne    _do_ctor    ; Branch if low Z not equal to CTOR_END
+       cpi     ZH, hi8(__CTOR_END__)
+       brne    _do_ctor    ; Branch if high Z not equal to CTOR_END
+       jmp     _ctors_done
+ _do_ctor:
+       elpm    XL, Z+
+       elpm    XH, Z+          ; post-increment will automatically handle RAMPZ
+       push    ZL
+       push    ZH
+       movw    ZL, XL
+       icall
+       pop     ZH
+       pop     ZL
+       jmp     _ctorsLoop
+ #endif                                /* AVR_ENHANCED, AVR_MEGA */
+ _ctors_done:
+ #endif                                /* L_ctor */
+ 
+ #ifdef L_dtor
+         .sect   .fini3,"ax",@progbits
+         .globl  __do_global_dtors
+ ;;
+ ;; Run through the destructor table.
+ ;; This needs to be run in the exit function.
+ ;;
+ #define ZH r31
+ #define ZL r30
+ #define XH r27
+ #define XL r26
+ 
+ __do_global_dtors:
+ #if defined (__AVR_ENHANCED__) && defined (__AVR_MEGA__)
+       ldi     ZL, lo8(__DTOR_LIST__)
+       ldi     ZH, hi8(__DTOR_LIST__)
+       ldi     r16, hh8(__DTOR_LIST__) ; init the RAMPZ value
+       out     __RAMPZ__, r16
+ _dtorsLoop:
+       cpi     r30, lo8(__DTOR_END__)
+       brne    _do_dtor    ; Branch if low Z not equal to DTOR_END
+       cpi     r31, hi8(__DTOR_END__)
+       brne    _do_dtor    ; Branch if high Z not equal to DTOR_END
+       jmp     _dtors_done
+ _do_dtor:
+       elpm    XL, Z+
+       elpm    XH, Z+          ; post-increment will automatically handle RAMPZ
+       push    ZL
+       push    ZH
+       movw    ZL, XL
+       icall
+       pop     ZH
+       pop     ZL
+       jmp     _dtorsLoop
+ #endif                                /* AVR_ENHANCED, AVR_MEGA */
+ _dtors_done:
+ #endif                                /* L_dtor */
diff -c3pr gcc-3.0.3/gcc/config/avr/t-avr 
gcc-3.0.3-patch-0.1/gcc/config/avr/t-avr
*** gcc-3.0.3/gcc/config/avr/t-avr      Sun Jan 21 03:49:01 2001
--- gcc-3.0.3-patch-0.1/gcc/config/avr/t-avr    Tue Feb  5 10:37:05 2002
*************** LIB1ASMFUNCS = \
*** 18,24 ****
        _epilogue \
        _exit \
        _cleanup \
!       _tablejump
  
  # libgcc...
  LIBGCC1_TEST =
--- 18,26 ----
        _epilogue \
        _exit \
        _cleanup \
!       _tablejump \
!       _ctor \
!       _dtor
  
  # libgcc...
  LIBGCC1_TEST =
*************** MULTILIB_MATCHES = \
*** 49,55 ****
        mmcu?avr3=mmcu?atmega103 mmcu?avr3=mmcu?atmega603 \
        mmcu?avr4=mmcu?atmega83  mmcu?avr4=mmcu?atmega85  \
        mmcu?avr5=mmcu?atmega161 mmcu?avr5=mmcu?atmega163 \
!       mmcu?avr5=mmcu?atmega32  mmcu?avr5=mmcu?at94k
  
  MULTILIB_EXCEPTIONS =
  
--- 51,58 ----
        mmcu?avr3=mmcu?atmega103 mmcu?avr3=mmcu?atmega603 \
        mmcu?avr4=mmcu?atmega83  mmcu?avr4=mmcu?atmega85  \
        mmcu?avr5=mmcu?atmega161 mmcu?avr5=mmcu?atmega163 \
!       mmcu?avr5=mmcu?atmega32  mmcu?avr5=mmcu?at94k \
!       mmcu?avr5=mmcu?atmega128
  
  MULTILIB_EXCEPTIONS =
  
diff -c3pr gcc-3.0.3/gcc/cp/ChangeLog gcc-3.0.3-patch-0.1/gcc/cp/ChangeLog
*** gcc-3.0.3/gcc/cp/ChangeLog  Fri Dec 21 06:21:50 2001
--- gcc-3.0.3-patch-0.1/gcc/cp/ChangeLog        Tue Feb  5 17:02:29 2002
***************
*** 1,3 ****
--- 1,7 ----
+ 2002-02-05  Peter Jansen <address@hidden>
+ 
+       * g++decl.c Changed so that LIBSTDCXX works for AVR
+ 
  2001-12-20  Release Manager
  
        * GCC 3.0.3 Released.
diff -c3pr gcc-3.0.3/gcc/cp/g++spec.c gcc-3.0.3-patch-0.1/gcc/cp/g++spec.c
*** gcc-3.0.3/gcc/cp/g++spec.c  Tue Feb  5 17:08:10 2002
--- gcc-3.0.3-patch-0.1/gcc/cp/g++spec.c        Tue Feb  5 17:10:58 2002
*************** lang_specific_driver (in_argc, in_argv, 
*** 255,266 ****
        j++;
      }
  
!   /* Add `-lstdc++' if we haven't already done so.  */
!   if (library)
!     {
!       arglist[j++] = LIBSTDCXX;
!       added_libraries++;
!     }
    if (saw_math)
      arglist[j++] = saw_math;
    else if (library && need_math)
--- 255,268 ----
        j++;
      }
  
!   /* Add `-lstdc++' if we haven't already done so and if the library
!    * name is defined.  */
!   if ((library) && (strlen (LIBSTDCXX) > 0))
!   {
!     arglist[j++] = LIBSTDCXX;
!     added_libraries++;
!   }
! 
    if (saw_math)
      arglist[j++] = saw_math;
    else if (library && need_math)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]