[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] [Fwd: building gcc/g++]
From: |
Peter Jansen |
Subject: |
Re: [avr-gcc-list] [Fwd: building gcc/g++] |
Date: |
Thu, 10 Jan 2002 11:35:11 +1100 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:0.9.4) Gecko/20011019 Netscape6/6.2 |
Reinhard,
Sorry I had done that work, attached is my patch, including the mega128
support.
Also attached is a new piece of startup code, and linker script.
address@hidden wrote:
On Wed, 09 Jan 2002, Peter Jansen wrote:
<snip>
I have found the __CTOR_LIST__ in the asm output.
Is anybody working on a solution of this problem?
Yes we have just come across this problem, today we have fixed g++ to
make this all work om the mega128 (which is what we are using).
It required the following fixes,
1. Put the con/destructor table in .ctors/.dtors sections, and make the
linker script handle them.
I did:
Changes to avr.h:
I have added the definitions of ASM_OUTPUT_CONSTRUCTOR,
ASM_OUTPUT_DESTRUCTOR and added in_ctors, in_dtors to
EXTRA_SECTIONS. In EXTRA_SECTION_FUNCTIONS I added the
functions to emit the ctors and dtors sections.
I got them from elfos.h.
2. Write a do_global_constructors function.
I defined __do_global_ctors and __do_global_dtors functions in libgcc.S.
3. Call the do_global_constructors from the startup code.
I don't know where and how to add this? I am analysing how the m86hc11 does
this. As far as I have understand this, it uses a .global with the function
name in the file where it defines the constructor table. For the do_global_xxx
funktions it defines a new section in the linke script, so that the are
inserted just befor the main code.
I like this solution, because it needs no changes to the startup code in the
libc. How have you solved the problem?
As I linked a program I got the error that the data section and the ctors do
overlay. I am not familar with the linker scripts, but maybe you have a hint?
This may be that you have run out of space in the one of the sections.
Maybe it's better to wait until you are ready and then try it with the smaller
avr's?
Attached is a start, I have changes to binutils to undate the linker
scripts, and avr-lib to update the startup code.
The startup code does not load the stack pointer, which is fixed in the
attached start up code attached.
I'm quite busy at the moment, but I will try and make patches for this,
I still have to do something for the other avr's (unless you would like to)
As I wrote in one of my previous mails, I am not so familar with the avr. I
still have to learn the assember.
here are the two messages to avr-gcc-list with the 3.0.2 patches for the
mega128 support, these wont patch againsed the current CVS tree I don't
think.
http://avr.jpk.co.nz/pipermail/avr-gcc-list/2001-November/001048.html
http://avr.jpk.co.nz/pipermail/avr-gcc-list/2001-November/001049.html
Thank you!
When I finish the constructor/destructor stuff, Ill get the latest CVS
source update the patches and send them to the gcc/binutils maintainers.
The stuff for avr-libc is already in the latest avr-libc for the
ATmega128 at
Reinhard
--
Peter Jansen
Smart Container
Level 1, NIC Building
Eveleigh
NSW 1430
AUSTRALIA
diff -c3Pr gcc-3.0.2/gcc/ChangeLog gcc-3.0.2-patch-0.2/gcc/ChangeLog
*** gcc-3.0.2/gcc/ChangeLog Wed Oct 24 03:19:18 2001
--- gcc-3.0.2-patch-0.2/gcc/ChangeLog Thu Jan 10 09:57:38 2002
***************
*** 1,3 ****
--- 1,11 ----
+ 2001-11-07 Peter Jansen <address@hidden>
+
+ * gcc/config/avr/avr.c - added mega128 to list of avr5 types
+ * gcc/config/avr/avr.h - Ditto, Added C++ constructor stuff
+ * gcc/config/avr/libgcc.S - added C++ constructor functions
+ * gcc/config/avr/t-avr - added C++ object compile
+
+
2001-10-23 Release Manager
* GCC 3.0.2 Released.
diff -c3Pr gcc-3.0.2/gcc/config/avr/avr.c
gcc-3.0.2-patch-0.2/gcc/config/avr/avr.c
*** gcc-3.0.2/gcc/config/avr/avr.c Thu Jun 28 07:35:37 2001
--- gcc-3.0.2-patch-0.2/gcc/config/avr/avr.c Wed Jan 9 12:31:04 2002
***************
*** 153,158 ****
--- 153,159 ----
{ "atmega163", AVR5 },
{ "atmega32", AVR5 },
{ "at94k", AVR5 },
+ { "atmega128", AVR5 },
/* Assembler only. */
{ "avr1", AVR1 },
{ "at90s1200", AVR1 },
***************
*** 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.2/gcc/config/avr/avr.h
gcc-3.0.2-patch-0.2/gcc/config/avr/avr.h
*** gcc-3.0.2/gcc/config/avr/avr.h Tue Apr 17 04:25:42 2001
--- gcc-3.0.2-patch-0.2/gcc/config/avr/avr.h Wed Jan 9 14:11:19 2002
***************
*** 1981,1987 ****
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. */
--- 1981,1987 ----
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. */
***************
*** 1991,2003 ****
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)
\
{ \
--- 1991,2059 ----
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 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, "%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, "%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)
\
{ \
***************
*** 2011,2016 ****
--- 2067,2111 ----
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
***************
*** 2973,2978 ****
--- 3068,3074 ----
%{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__} \
***************
*** 3051,3056 ****
--- 3147,3153 ----
%{!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} \
***************
*** 3130,3135 ****
--- 3227,3233 ----
%{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.2/gcc/config/avr/libgcc.S
gcc-3.0.2-patch-0.2/gcc/config/avr/libgcc.S
*** gcc-3.0.2/gcc/config/avr/libgcc.S Wed Jan 9 11:25:27 2002
--- gcc-3.0.2-patch-0.2/gcc/config/avr/libgcc.S Wed Jan 9 18:22:32 2002
***************
*** 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.
***************
*** 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) */
***************
*** 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
***************
*** 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) */
***************
*** 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:
***************
*** 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
***************
*** 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)
*******************************************************/
***************
*** 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
***************
*** 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)
*******************************************************/
***************
*** 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)
***************
*** 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)
*******************************************************/
***************
*** 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)
***************
*** 674,676 ****
--- 675,753 ----
.endfunc
#endif /* defined (L_tablejump) */
+ #ifdef L_ctor
+
+ ; End of constructor table
+ .sect .init,"ax",@progbits
+ .globl __do_global_ctors
+ __do_global_ctors:
+ #if defined (__AVR_ENHANCED__) && defined (__AVR_MEGA__)
+ ldi r28, lo8(__CTOR_LIST__)
+ ldi r29, hi8(__CTOR_LIST__)
+ movw r30, r28
+ ; ldi r16, 0 ; const value of 0
+ ; ldi r17, 0 ; const value of 1
+ ldi r16, hh8(__CTOR_LIST__) ; init the RAMPZ value
+ out __RAMPZ__, r16
+ _ctorsLoop:
+ cpi r30, lo8(__CTOR_END__)
+ brne _do_ctor ; Branch if ZL not equal to low byte of CTOR_END
+ cpi r31, hi8(__CTOR_END__)
+ brne _do_ctor ; Branch if ZH not equal to high byte of CTOR_END
+ jmp _ctors_done
+ _do_ctor:
+ ; out __RAMPZ__, r16
+ ; sbrc r29, 7 ; if msb is set then do the same for RAMPZ
+ ; out __RAMPZ__, r17
+ elpm r26, Z+
+ ; elpm r27, Z
+ elpm r27, Z+ ; post-increment will automatically handle RAMPZ
+ push r30
+ push r31
+ movw r30, r26
+ icall
+ pop r31
+ pop r30
+ ; adiw r28, 2
+ ; movw r30, r28
+ jmp _ctorsLoop
+ #endif
+ _ctors_done:
+ ret
+
+ #endif /* L_ctor */
+
+ #ifdef L_dtor
+
+ .sect .fini,"ax",@progbits
+ .globl __do_global_dtors
+
+ ;;
+ ;; This piece of code is inserted in the _exit() code by the linker.
+ ;;
+ ;; void *p;
+ ;; for (p = __DTOR_LIST__; *p; p++)
+ ;; {
+ ;; (*p)();
+ ;; }
+ __do_global_dtors:
+ push r28
+ push r29
+ ldi r28,lo8(__DTOR_LIST__)
+ ldi r29,hi8(__DTOR_LIST__)
+ lds r30,__DTOR_LIST__
+ lds r31,(__DTOR_LIST__)+1
+ sbiw r30,0
+ breq .dtors_done
+ .dtors_loop:
+ icall
+ adiw r28,2
+ ld r30,Y
+ ldd r31,Y+1
+ sbiw r30,0
+ brne .dtors_loop
+ .dtors_done:
+ pop r29
+ pop r28
+
+ #endif /* L_dtor */
diff -c3Pr gcc-3.0.2/gcc/config/avr/t-avr
gcc-3.0.2-patch-0.2/gcc/config/avr/t-avr
*** gcc-3.0.2/gcc/config/avr/t-avr Sun Jan 21 03:49:01 2001
--- gcc-3.0.2-patch-0.2/gcc/config/avr/t-avr Tue Jan 8 19:34:41 2002
***************
*** 18,24 ****
_epilogue \
_exit \
_cleanup \
! _tablejump
# libgcc...
LIBGCC1_TEST =
--- 18,26 ----
_epilogue \
_exit \
_cleanup \
! _tablejump \
! _ctor \
! _dtor
# libgcc...
LIBGCC1_TEST =
***************
*** 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 =
Only in gcc-3.0.2/gcc/po: stamp-cat-id
diff -c3Pr gcc-3.0.2/gcc/tm.h gcc-3.0.2-patch-0.2/gcc/tm.h
*** gcc-3.0.2/gcc/tm.h Thu Jan 1 10:00:00 1970
--- gcc-3.0.2-patch-0.2/gcc/tm.h Tue Jan 8 19:04:45 2002
***************
*** 0 ****
--- 1,9 ----
+ #ifdef IN_GCC
+ # include "gansidecl.h"
+ # include "avr/avr.h"
+ # include "defaults.h"
+ #endif
+ #ifndef GENERATOR_FILE
+ #include "insn-codes.h"
+ #include "insn-flags.h"
+ #endif
Only in gcc-3.0.2: libstdc++-v3
/* ---------------------------------------------------------------------
* avrmega128.x
* ---------------------------------------------------------------------
*
* Copyright (C) 2001 Smart Container. All Rights Reserved
*
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF Smart Container.
* The copyright notice above does not evidence any
* actual or intended publication of such source code.
*
* OneLiner: This file is the linker script for the repeater cpu.
*
* DevUnit: flasher/script/avrmega128.x
* Author: Matthew Lee
*/
OUTPUT_FORMAT("elf32-avr","elf32-avr","elf32-avr")
OUTPUT_ARCH(avr:5)
MEMORY
{
text (rx) : ORIGIN = 0, LENGTH = 128K
/* Data space is restricted to first page of external RAM */
data (rw!x) : ORIGIN = 0x800100, LENGTH = 0x07ef8
eeprom (rw!x) : ORIGIN = 0x810000, LENGTH = 4K
}
SECTIONS
{
/* Read-only sections, merged into text segment: */
.hash : { *(.hash) }
.dynsym : { *(.dynsym) }
.dynstr : { *(.dynstr) }
.gnu.version : { *(.gnu.version) }
.gnu.version_d : { *(.gnu.version_d) }
.gnu.version_r : { *(.gnu.version_r) }
.rel.init : { *(.rel.init) }
.rela.init : { *(.rela.init) }
.rel.text :
{
*(.rel.text)
*(.rel.text.*)
*(.rel.gnu.linkonce.t*)
}
.rela.text :
{
*(.rela.text)
*(.rela.text.*)
*(.rela.gnu.linkonce.t*)
}
.rel.fini : { *(.rel.fini) }
.rela.fini : { *(.rela.fini) }
.rel.rodata :
{
*(.rel.rodata)
*(.rel.rodata.*)
*(.rel.gnu.linkonce.r*)
}
.rela.rodata :
{
*(.rela.rodata)
*(.rela.rodata.*)
*(.rela.gnu.linkonce.r*)
}
.rel.data :
{
*(.rel.data)
*(.rel.data.*)
*(.rel.gnu.linkonce.d*)
}
.rela.data :
{
*(.rela.data)
*(.rela.data.*)
*(.rela.gnu.linkonce.d*)
}
.rel.ctors : { *(.rel.ctors) }
.rela.ctors : { *(.rela.ctors) }
.rel.dtors : { *(.rel.dtors) }
.rela.dtors : { *(.rela.dtors) }
.rel.got : { *(.rel.got) }
.rela.got : { *(.rela.got) }
.rel.bss : { *(.rel.bss) }
.rela.bss : { *(.rela.bss) }
.rel.plt : { *(.rel.plt) }
.rela.plt : { *(.rela.plt) }
/* Internal text space or external memory */
.text :
{
*(.init)
*(.progmem.gcc*)
*(.progmem*)
. = ALIGN(2);
*(.text)
. = ALIGN(2);
*(.text.*)
. = ALIGN(2);
*(.fini)
. = ALIGN(2);
__CTOR_LIST__ = .;
*(.ctors)
__CTOR_END__ = .;
__DTOR_LIST__ = .;
*(.dtors)
__DTOR_END__ = .;
_etext = . ;
} > text
.data : AT (ADDR (.text) + SIZEOF (.text))
{
PROVIDE (__data_start = .) ;
/* Put bootloader section at start of data */
*(.bootload)
*(.data)
*(.gnu.linkonce.d*)
. = ALIGN(2);
_edata = . ;
} > data
.bss SIZEOF(.data) + ADDR(.data) :
{
PROVIDE (__bss_start = .) ;
*(.bss)
*(COMMON)
PROVIDE (__bss_end = .) ;
_end = . ;
} > data
.eeprom :
AT (ADDR (.text) + SIZEOF (.text) + SIZEOF (.data))
{
*(.eeprom*)
__eeprom_end = . ;
} > eeprom
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
/* DWARF debug sections.
Symbols in the DWARF debugging sections are relative to the beginning
of the section so we begin them at 0. */
/* DWARF 1 */
.debug 0 : { *(.debug) }
.line 0 : { *(.line) }
/* GNU DWARF 1 extensions */
.debug_srcinfo 0 : { *(.debug_srcinfo) }
.debug_sfnames 0 : { *(.debug_sfnames) }
/* DWARF 1.1 and DWARF 2 */
.debug_aranges 0 : { *(.debug_aranges) }
.debug_pubnames 0 : { *(.debug_pubnames) }
/* DWARF 2 */
.debug_info 0 : { *(.debug_info) *(.gnu.linkonce.wi.*) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_line 0 : { *(.debug_line) }
.debug_frame 0 : { *(.debug_frame) }
.debug_str 0 : { *(.debug_str) }
.debug_loc 0 : { *(.debug_loc) }
.debug_macinfo 0 : { *(.debug_macinfo) }
PROVIDE (__stack = 0x7FF7) ;
/* The following enables the external memory bus. */
__init_mcucr__ = 0x80 ;
}
/* Copyright (C) 1999 Denis Chertykov <address@hidden>
This file is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any
later version.
In addition to the permissions in the GNU General Public License, the
author gives you unlimited permission to link the
compiled version of this file into combinations with other programs,
and to distribute those combinations without any restriction coming
from the use of this file. (The General Public License restrictions
do apply in other respects; for example, they cover modification of
the file, and distribution when not linked into a combine
executable.)
This file is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details. */
/* Hacked a lot by Marek Michalkiewicz <address@hidden> to add
support for many MCU types, etc. These changes are public domain. */
;; -*- mode: asm -*-
#include <avr/hdr/macros.inc>
#if !defined (__AVR_ASM_ONLY__)
; not required by gas, but still a nice way to show referenced symbols
.extern _U(main)
.extern _etext
.extern __data_start
.extern _edata
.extern __bss_start
.extern __bss_end
; Stack init in main() (can override with avr-ld --defsym __stack=...)
; .weak __stack
;__stack = RAMEND
.extern __stack
; These too can be set with the avr-ld --defsym name=value option
; (MCUCR must be set up correctly to enable external SRAM).
.weak __init_mcucr__
.weak __init_emcucr__
.weak __init_wdtcr__
; You can plug in your own code to handle unexpected
; interrupts (which usually indicate a bug - if the program
; enables an interrupt for which there is no handler).
.weak _U(_unexpected_)
#endif /* if !defined (__AVR_ASM_ONLY__) */
; You can plug in your own asm code that runs immediately
; after reset, without any initialization at all. When done,
; it should jump to _real_init_.
.weak _U(_init_)
;
; Vector table macros
;
.set no_vect, 0
.macro VEC name
.if (END_VECTOR > no_vect)
.weak _U(\name)
#if !defined (__AVR_ASM_ONLY__)
.set _U(\name), _unexpected_1_
#endif
XJMP _U(\name)
.endif
.set no_vect, no_vect + 1
.endm
; reset and interrupt vectors, starting at absolute address 0
.section .init, "ax", @progbits
.func .__start_of_init__
.__start_of_init__:
XJMP _U(_init_)
VEC _vector_1
VEC _vector_2
VEC _vector_3
VEC _vector_4
VEC _vector_5
VEC _vector_6
VEC _vector_7
VEC _vector_8
VEC _vector_9
VEC _vector_10
VEC _vector_11
VEC _vector_12
VEC _vector_13
VEC _vector_14
VEC _vector_15
VEC _vector_16
VEC _vector_17
VEC _vector_18
VEC _vector_19
VEC _vector_20
VEC _vector_21
VEC _vector_22
VEC _vector_23
VEC _vector_24
VEC _vector_25
VEC _vector_26
VEC _vector_27
VEC _vector_28
VEC _vector_29
VEC _vector_30
VEC _vector_31
VEC _vector_32
VEC _vector_33
VEC _vector_34
VEC _vector_35
VEC _vector_36
VEC _vector_37
VEC _vector_38
VEC _vector_39
/* extra check */
; .if . - .__start_of_init__ - INT_VECT_SIZE
; .err
; .endif
.endfunc
#if !defined (__AVR_ASM_ONLY__)
.section .text, "ax", @progbits
.func .__c_startup__
.__c_startup__:
; two remporary registers (usable with ldi, not pointer registers)
#define r_tmp1 r18
#define r_tmp2 r19
/*
* I/O instructions below (out) require an address < 0x40.
* If an SFR offset is being used, the register address needs to be
* scaled back from its DATA memory address to its I/O memory address.
*/
#ifndef __SFR_OFFSET
#define __SFR_OFFSET 0
#endif /* !__SFR_OFFSET */
.global _U(_real_init_)
_U(_real_init_):
_U(_init_):
clr __zero_reg__
out (SREG - __SFR_OFFSET), __zero_reg__
#ifdef WDTCR
ldi r_tmp1, lo8(__init_wdtcr__)
wdr
out (WDTCR - __SFR_OFFSET), r_tmp1
#endif
#ifdef MCUCR
ldi r_tmp1, lo8(__init_mcucr__)
out (MCUCR - __SFR_OFFSET), r_tmp1
#endif
#ifdef EMCUCR
ldi r_tmp1, lo8(__init_emcucr__)
out (EMCUCR - __SFR_OFFSET), r_tmp1
#endif
;; Set up the stack
ldi r_tmp1, lo8(__stack)
out (SPL - __SFR_OFFSET), r_tmp1
ldi r_tmp1, hi8(__stack)
out (SPH - __SFR_OFFSET), r_tmp1
; XXX should we also read, save and clear MCUSR (if present) here?
; (datasheets suggest to do it as soon as possible after reset)
ldi ZL, lo8(_etext); load the end of .text segment
ldi ZH, hi8(_etext); this is a start of .data image
#if BIG_CODE
ldi r_tmp2, hh8(_etext) ; this will be in RAMPZ for "elpm"
#endif
ldi XL, lo8(__data_start) ; load start of ram
ldi XH, hi8(__data_start)
#if XRAMEND > 0x100 /* don't bother with high byte if we know it must be 0 */
ldi r_tmp1, hi8(_edata)
#endif
LPM_R0_ZPLUS_INIT r_tmp2
rjmp .copy_data_start
.copy_data_loop:
LPM_R0_ZPLUS_NEXT r_tmp2
st X+, r0
.copy_data_start:
cpi XL, lo8(_edata)
#if XRAMEND > 0x100
cpc XH, r_tmp1 ; hi8(_edata)
#endif
brne .copy_data_loop
;; avr-ld always put .bss after .data
; If the above is true, then no need to load X again below.
; But there are two separate symbols _edata and __bss_start
; which seem to have the same value but are initialized
; in two different places in the linker script.
#if 1
ldi XL, lo8(__bss_start)
ldi XH, hi8(__bss_start)
#endif
#if XRAMEND > 0x100
ldi r_tmp1, hi8(__bss_end)
#endif
rjmp .zero_bss_start
.zero_bss_loop:
st X+, __zero_reg__
.zero_bss_start:
cpi XL, lo8(__bss_end)
#if XRAMEND > 0x100
cpc XH, r_tmp1 ; hi8(__bss_end)
#endif
brne .zero_bss_loop
call _U(__do_global_ctors)
XJMP _U(main)
_unexpected_1_:
XJMP _U(_unexpected_)
_U(_unexpected_):
reti
.endfunc
#endif /* if !defined (__AVR_ASM_ONLY__) */
- [avr-gcc-list] [Fwd: building gcc/g++], Peter Jansen, 2002/01/09
- Message not available
- Re: [avr-gcc-list] [Fwd: building gcc/g++], Peter Jansen, 2002/01/09
- Re: [avr-gcc-list] [Fwd: building gcc/g++], reinhard . jessich, 2002/01/09
- Re: [avr-gcc-list] [Fwd: building gcc/g++], Peter Jansen, 2002/01/09
- Re: [avr-gcc-list] [Fwd: building gcc/g++], reinhard . jessich, 2002/01/12
- Re: [avr-gcc-list] [Fwd: building gcc/g++],
Peter Jansen <=
- Re: [avr-gcc-list] [Fwd: building gcc/g++], reinhard . jessich, 2002/01/12
- Re: [avr-gcc-list] [Fwd: building gcc/g++], Peter Jansen, 2002/01/12