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