Home | History | Annotate | Download | only in scripttempl
      1 # Copyright (C) 2014 Free Software Foundation, Inc.
      2 # 
      3 # Copying and distribution of this file, with or without modification,
      4 # are permitted in any medium without royalty provided the copyright
      5 # notice and this notice are preserved.
      6 
      7 cat <<EOF
      8 /* Copyright (C) 2014 Free Software Foundation, Inc.
      9 
     10    Copying and distribution of this script, with or without modification,
     11    are permitted in any medium without royalty provided the copyright
     12    notice and this notice are preserved.  */
     13 
     14 OUTPUT_FORMAT("${OUTPUT_FORMAT}","${OUTPUT_FORMAT}","${OUTPUT_FORMAT}")
     15 OUTPUT_ARCH(${ARCH})
     16 
     17 MEMORY
     18 {
     19   text   (rx)   : ORIGIN = 0, LENGTH = $TEXT_LENGTH
     20   data   (rw!x) : ORIGIN = $DATA_ORIGIN, LENGTH = $DATA_LENGTH
     21   eeprom (rw!x) : ORIGIN = 0x810000, LENGTH = 64K
     22   fuse      (rw!x) : ORIGIN = 0x820000, LENGTH = 1K
     23   lock      (rw!x) : ORIGIN = 0x830000, LENGTH = 1K
     24   signature (rw!x) : ORIGIN = 0x840000, LENGTH = 1K
     25 }
     26 
     27 SECTIONS
     28 {
     29   /* Read-only sections, merged into text segment: */
     30   ${TEXT_DYNAMIC+${DYNAMIC}}
     31   .hash        ${RELOCATING-0} : { *(.hash)		}
     32   .dynsym      ${RELOCATING-0} : { *(.dynsym)		}
     33   .dynstr      ${RELOCATING-0} : { *(.dynstr)		}
     34   .gnu.version ${RELOCATING-0} : { *(.gnu.version)	}
     35   .gnu.version_d ${RELOCATING-0} : { *(.gnu.version_d)	}
     36   .gnu.version_r ${RELOCATING-0} : { *(.gnu.version_r)	}
     37 
     38   .rel.init    ${RELOCATING-0} : { *(.rel.init)		}
     39   .rela.init   ${RELOCATING-0} : { *(.rela.init)	}
     40   .rel.text    ${RELOCATING-0} :
     41     {
     42       *(.rel.text)
     43       ${RELOCATING+*(.rel.text.*)}
     44       ${RELOCATING+*(.rel.gnu.linkonce.t*)}
     45     }
     46   .rela.text   ${RELOCATING-0} :
     47     {
     48       *(.rela.text)
     49       ${RELOCATING+*(.rela.text.*)}
     50       ${RELOCATING+*(.rela.gnu.linkonce.t*)}
     51     }
     52   .rel.fini    ${RELOCATING-0} : { *(.rel.fini)		}
     53   .rela.fini   ${RELOCATING-0} : { *(.rela.fini)	}
     54   .rel.rodata  ${RELOCATING-0} :
     55     {
     56       *(.rel.rodata)
     57       ${RELOCATING+*(.rel.rodata.*)}
     58       ${RELOCATING+*(.rel.gnu.linkonce.r*)}
     59     }
     60   .rela.rodata ${RELOCATING-0} :
     61     {
     62       *(.rela.rodata)
     63       ${RELOCATING+*(.rela.rodata.*)}
     64       ${RELOCATING+*(.rela.gnu.linkonce.r*)}
     65     }
     66   .rel.data    ${RELOCATING-0} :
     67     {
     68       *(.rel.data)
     69       ${RELOCATING+*(.rel.data.*)}
     70       ${RELOCATING+*(.rel.gnu.linkonce.d*)}
     71     }
     72   .rela.data   ${RELOCATING-0} :
     73     {
     74       *(.rela.data)
     75       ${RELOCATING+*(.rela.data.*)}
     76       ${RELOCATING+*(.rela.gnu.linkonce.d*)}
     77     }
     78   .rel.ctors   ${RELOCATING-0} : { *(.rel.ctors)	}
     79   .rela.ctors  ${RELOCATING-0} : { *(.rela.ctors)	}
     80   .rel.dtors   ${RELOCATING-0} : { *(.rel.dtors)	}
     81   .rela.dtors  ${RELOCATING-0} : { *(.rela.dtors)	}
     82   .rel.got     ${RELOCATING-0} : { *(.rel.got)		}
     83   .rela.got    ${RELOCATING-0} : { *(.rela.got)		}
     84   .rel.bss     ${RELOCATING-0} : { *(.rel.bss)		}
     85   .rela.bss    ${RELOCATING-0} : { *(.rela.bss)		}
     86   .rel.plt     ${RELOCATING-0} : { *(.rel.plt)		}
     87   .rela.plt    ${RELOCATING-0} : { *(.rela.plt)		}
     88 
     89   /* Internal text space or external memory.  */
     90   .text ${RELOCATING-0} :
     91   {
     92     *(.vectors)
     93     KEEP(*(.vectors))
     94 
     95     /* For data that needs to reside in the lower 64k of progmem.  */
     96     ${RELOCATING+ *(.progmem.gcc*)}
     97 
     98     /* PR 13812: Placing the trampolines here gives a better chance
     99        that they will be in range of the code that uses them.  */
    100     ${RELOCATING+. = ALIGN(2);}
    101     ${CONSTRUCTING+ __trampolines_start = . ; }
    102     /* The jump trampolines for the 16-bit limited relocs will reside here.  */
    103     *(.trampolines)
    104     ${RELOCATING+ *(.trampolines*)}
    105     ${CONSTRUCTING+ __trampolines_end = . ; }
    106 
    107     ${RELOCATING+ *(.progmem*)}
    108     
    109     ${RELOCATING+. = ALIGN(2);}
    110 
    111     /* For future tablejump instruction arrays for 3 byte pc devices.
    112        We don't relax jump/call instructions within these sections.  */
    113     *(.jumptables) 
    114     ${RELOCATING+ *(.jumptables*)}
    115 
    116     /* For code that needs to reside in the lower 128k progmem.  */
    117     *(.lowtext)
    118     ${RELOCATING+ *(.lowtext*)}
    119 
    120     ${CONSTRUCTING+ __ctors_start = . ; }
    121     ${CONSTRUCTING+ *(.ctors) }
    122     ${CONSTRUCTING+ __ctors_end = . ; }
    123     ${CONSTRUCTING+ __dtors_start = . ; }
    124     ${CONSTRUCTING+ *(.dtors) }
    125     ${CONSTRUCTING+ __dtors_end = . ; }
    126     KEEP(SORT(*)(.ctors))
    127     KEEP(SORT(*)(.dtors))
    128 
    129     /* From this point on, we don't bother about wether the insns are
    130        below or above the 16 bits boundary.  */
    131     *(.init0)  /* Start here after reset.  */
    132     KEEP (*(.init0))
    133     *(.init1)
    134     KEEP (*(.init1))
    135     *(.init2)  /* Clear __zero_reg__, set up stack pointer.  */
    136     KEEP (*(.init2))
    137     *(.init3)
    138     KEEP (*(.init3))
    139     *(.init4)  /* Initialize data and BSS.  */
    140     KEEP (*(.init4))
    141     *(.init5)
    142     KEEP (*(.init5))
    143     *(.init6)  /* C++ constructors.  */
    144     KEEP (*(.init6))
    145     *(.init7)
    146     KEEP (*(.init7))
    147     *(.init8)
    148     KEEP (*(.init8))
    149     *(.init9)  /* Call main().  */
    150     KEEP (*(.init9))
    151     *(.text)
    152     ${RELOCATING+. = ALIGN(2);}
    153     ${RELOCATING+ *(.text.*)}
    154     ${RELOCATING+. = ALIGN(2);}
    155     *(.fini9)  /* _exit() starts here.  */
    156     KEEP (*(.fini9))
    157     *(.fini8)
    158     KEEP (*(.fini8))
    159     *(.fini7)
    160     KEEP (*(.fini7))
    161     *(.fini6)  /* C++ destructors.  */
    162     KEEP (*(.fini6))
    163     *(.fini5)
    164     KEEP (*(.fini5))
    165     *(.fini4)
    166     KEEP (*(.fini4))
    167     *(.fini3)
    168     KEEP (*(.fini3))
    169     *(.fini2)
    170     KEEP (*(.fini2))
    171     *(.fini1)
    172     KEEP (*(.fini1))
    173     *(.fini0)  /* Infinite loop after program termination.  */
    174     KEEP (*(.fini0))
    175     ${RELOCATING+ _etext = . ; }
    176   } ${RELOCATING+ > text}
    177 
    178   .data        ${RELOCATING-0} :
    179   {
    180     ${RELOCATING+ PROVIDE (__data_start = .) ; }
    181     *(.data)
    182     ${RELOCATING+ *(.data*)}
    183     *(.rodata)  /* We need to include .rodata here if gcc is used */
    184     ${RELOCATING+ *(.rodata*)} /* with -fdata-sections.  */
    185     *(.gnu.linkonce.d*)
    186     ${RELOCATING+. = ALIGN(2);}
    187     ${RELOCATING+ _edata = . ; }
    188     ${RELOCATING+ PROVIDE (__data_end = .) ; }
    189   } ${RELOCATING+ > data ${RELOCATING+AT> text}}
    190 
    191   .bss ${RELOCATING+ ADDR(.data) + SIZEOF (.data)} ${RELOCATING-0} :${RELOCATING+ AT (ADDR (.bss))}
    192   {
    193     ${RELOCATING+ PROVIDE (__bss_start = .) ; }
    194     *(.bss)
    195     ${RELOCATING+ *(.bss*)}
    196     *(COMMON)
    197     ${RELOCATING+ PROVIDE (__bss_end = .) ; }
    198   } ${RELOCATING+ > data}
    199 
    200   ${RELOCATING+ __data_load_start = LOADADDR(.data); }
    201   ${RELOCATING+ __data_load_end = __data_load_start + SIZEOF(.data); }
    202 
    203   /* Global data not cleared after reset.  */
    204   .noinit ${RELOCATING-0}:
    205   {
    206     ${RELOCATING+ PROVIDE (__noinit_start = .) ; }
    207     *(.noinit*)
    208     ${RELOCATING+ PROVIDE (__noinit_end = .) ; }
    209     ${RELOCATING+ _end = . ;  }
    210     ${RELOCATING+ PROVIDE (__heap_start = .) ; }
    211   } ${RELOCATING+ > data}
    212 
    213   .eeprom ${RELOCATING-0}:
    214   {
    215     /* See .data above...  */
    216     KEEP(*(.eeprom*))
    217     ${RELOCATING+ __eeprom_end = . ; }
    218   } ${RELOCATING+ > eeprom}
    219 
    220   .fuse ${RELOCATING-0}:
    221   {
    222     KEEP(*(.fuse))
    223     KEEP(*(.lfuse))
    224     KEEP(*(.hfuse))
    225     KEEP(*(.efuse))
    226   } ${RELOCATING+ > fuse}
    227 
    228   .lock ${RELOCATING-0}:
    229   {
    230     KEEP(*(.lock*))
    231   } ${RELOCATING+ > lock}
    232 
    233   .signature ${RELOCATING-0}:
    234   {
    235     KEEP(*(.signature*))
    236   } ${RELOCATING+ > signature}
    237 
    238   /* Stabs debugging sections.  */
    239   .stab 0 : { *(.stab) }
    240   .stabstr 0 : { *(.stabstr) }
    241   .stab.excl 0 : { *(.stab.excl) }
    242   .stab.exclstr 0 : { *(.stab.exclstr) }
    243   .stab.index 0 : { *(.stab.index) }
    244   .stab.indexstr 0 : { *(.stab.indexstr) }
    245   .comment 0 : { *(.comment) } 
    246   .note.gnu.build-id : { *(.note.gnu.build-id) }
    247 EOF
    248 
    249 . $srcdir/scripttempl/DWARF.sc
    250 
    251 cat <<EOF
    252 }
    253 EOF
    254