Home | History | Annotate | Download | only in scripttempl
      1 #
      2 # Unusual variables checked by this code:
      3 #	NOP - four byte opcode for no-op (defaults to 0)
      4 #	NO_SMALL_DATA - no .sbss/.sbss2/.sdata/.sdata2 sections if not
      5 #		empty.
      6 #	OTHER_READONLY_SECTIONS - other than .text .init .rodata ...
      7 #		(e.g., .PARISC.milli)
      8 # When adding sections, do note that the names of some sections are used
      9 # when specifying the start address of the next.
     10 #
     11 test -z "$ENTRY" && ENTRY=start
     12 test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT}
     13 test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT}
     14 # If we request a big endian toolchain, give a big endian linker
     15 test -z "$GOT" && GOT=".got          ${RELOCATING-0} : { *(.got.plt) *(.got) } ${RELOCATING+ > ${DATA_MEMORY}}"
     16 test "${ARC_ENDIAN}" == "big" && OUTPUT_FORMAT=${BIG_OUTPUT_FORMAT}
     17 if [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH}; else OUTPUT_ARCH=${ARCH}:${MACHINE}; fi
     18 test -z "${ELFSIZE}" && ELFSIZE=32
     19 test -z "${ALIGNMENT}" && ALIGNMENT="${ELFSIZE} / 8"
     20 test "$LD_FLAG" = "N" && DATA_ADDR=.
     21 
     22 CTOR=".ctors        ${CONSTRUCTING-0} : 
     23   {
     24     ${CONSTRUCTING+${CTOR_START}}
     25     /* gcc uses crtbegin.o to find the start of
     26        the constructors, so we make sure it is
     27        first.  Because this is a wildcard, it
     28        doesn't matter if the user does not
     29        actually link against crtbegin.o; the
     30        linker won't look for a file to match a
     31        wildcard.  The wildcard also means that it
     32        doesn't matter which directory crtbegin.o
     33        is in.  */
     34 
     35     KEEP (*crtbegin*.o(.ctors))
     36 
     37     /* We don't want to include the .ctor section from
     38        from the crtend.o file until after the sorted ctors.
     39        The .ctor section from the crtend file contains the
     40        end of ctors marker and it must be last */
     41 
     42     KEEP (*(EXCLUDE_FILE (*crtend*.o $OTHER_EXCLUDE_FILES) .ctors))
     43     KEEP (*(SORT(.ctors.*)))
     44     KEEP (*(.ctors))
     45     ${CONSTRUCTING+${CTOR_END}}
     46   } ${RELOCATING+ > ${DATA_MEMORY}}"
     47 DTOR=".dtors        ${CONSTRUCTING-0} :
     48   {
     49     ${CONSTRUCTING+${DTOR_START}}
     50     KEEP (*crtbegin*.o(.dtors))
     51     KEEP (*(EXCLUDE_FILE (*crtend*.o $OTHER_EXCLUDE_FILES) .dtors))
     52     KEEP (*(SORT(.dtors.*)))
     53     KEEP (*(.dtors))
     54     ${CONSTRUCTING+${DTOR_END}}
     55   } ${RELOCATING+ > ${DATA_MEMORY}}"
     56 
     57 if test -z "${NO_SMALL_DATA}"; then
     58   SBSS=".sbss         ${RELOCATING-0} :
     59   {
     60     ${RELOCATING+PROVIDE (__sbss_start = .);}
     61     ${RELOCATING+PROVIDE (___sbss_start = .);}
     62     *(.dynsbss)
     63     *(.sbss${RELOCATING+ .sbss.* .gnu.linkonce.sb.*})
     64     *(.scommon)
     65     ${RELOCATING+PROVIDE (__sbss_end = .);}
     66     ${RELOCATING+PROVIDE (___sbss_end = .);}
     67   } ${RELOCATING+ > ${SDATA_MEMORY}}"
     68   SBSS2=".sbss2        ${RELOCATING-0} : { *(.sbss2${RELOCATING+ .sbss2.* .gnu.linkonce.sb2.*}) } ${RELOCATING+ > ${SDATA_MEMORY}}"
     69   SDATA="/* We want the small data sections together, so single-instruction offsets
     70      can access them all, and initialized data all before uninitialized, so
     71      we can shorten the on-disk segment size.  */
     72   .sdata        ${RELOCATING-0} :
     73   {
     74     ${RELOCATING+${SDATA_START_SYMBOLS}}
     75     *(.sdata${RELOCATING+ .sdata.* .gnu.linkonce.s.*})
     76 
     77     ${RELOCATING+_edata  =  .;}
     78     ${RELOCATING+PROVIDE (edata = .);}
     79   } ${RELOCATING+ > ${SDATA_MEMORY}}"
     80   SDATA2=".sdata2       ${RELOCATING-0} : { *(.sdata2${RELOCATING+ .sdata2.* .gnu.linkonce.s2.*}) } ${RELOCATING+ > ${SDATA_MEMORY}}"
     81   REL_SDATA=".rel.sdata    ${RELOCATING-0} : { *(.rel.sdata${RELOCATING+ .rel.sdata.* .rel.gnu.linkonce.s.*}) }
     82   .rela.sdata   ${RELOCATING-0} : { *(.rela.sdata${RELOCATING+ .rela.sdata.* .rela.gnu.linkonce.s.*}) }"
     83   REL_SBSS=".rel.sbss     ${RELOCATING-0} : { *(.rel.sbss${RELOCATING+ .rel.sbss.* .rel.gnu.linkonce.sb.*}) }
     84   .rela.sbss    ${RELOCATING-0} : { *(.rela.sbss${RELOCATING+ .rela.sbss.* .rela.gnu.linkonce.sb.*}) }"
     85   REL_SDATA2=".rel.sdata2   ${RELOCATING-0} : { *(.rel.sdata2${RELOCATING+ .rel.sdata2.* .rel.gnu.linkonce.s2.*}) }
     86   .rela.sdata2  ${RELOCATING-0} : { *(.rela.sdata2${RELOCATING+ .rela.sdata2.* .rela.gnu.linkonce.s2.*}) }"
     87   REL_SBSS2=".rel.sbss2    ${RELOCATING-0} : { *(.rel.sbss2${RELOCATING+ .rel.sbss2.* .rel.gnu.linkonce.sb2.*}) }
     88   .rela.sbss2   ${RELOCATING-0} : { *(.rela.sbss2${RELOCATING+ .rela.sbss2.* .rela.gnu.linkonce.sb2.*}) }"
     89 fi
     90 
     91 #
     92 # We provide two emulations: a fixed on that defines some memory banks
     93 # and a configurable one that includes a user provided memory definition.
     94 #
     95 case $GENERIC_BOARD in
     96   yes|1|YES)
     97 	MEMORY_DEF="
     98 /* Get memory banks definition from some user configuration file.
     99    This file must be located in some linker directory (search path
    100    with -L<dir>). See fixed memory banks emulation script.  */
    101 INCLUDE memory.x;
    102 "
    103 	;;
    104   *)
    105 MEMORY_DEF="
    106 /* Fixed definition of the available memory banks.
    107    See generic emulation script for a user defined configuration.  */
    108 MEMORY
    109 {
    110     ICCM : ORIGIN = 0x00000000, LENGTH = ${ICCM_SIZE}
    111     DCCM : ORIGIN = ${RAM_START_ADDR}, LENGTH = ${RAM_SIZE}
    112 }
    113 
    114 /* Setup the stack on the top of the data memory bank.  */
    115 PROVIDE (__stack_top = (${RAM_START_ADDR} + ${RAM_SIZE} - 1) & -4);
    116 PROVIDE (__end_heap = ${RAM_START_ADDR} + ${RAM_SIZE} - 1);
    117 "
    118 	;;
    119 esac
    120 
    121 cat <<EOF
    122 OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}", "${LITTLE_OUTPUT_FORMAT}")
    123 OUTPUT_ARCH(${OUTPUT_ARCH})
    124 ${RELOCATING+ENTRY(${ENTRY})}
    125 
    126 ${RELOCATING+${LIB_SEARCH_DIRS}}
    127 ${RELOCATING+${EXECUTABLE_SYMBOLS}}
    128 ${RELOCATING+${MEMORY_DEF}}
    129 
    130 SECTIONS
    131 {
    132   .ivt 0x00 :
    133   {
    134    KEEP (*(.ivt));
    135   } ${RELOCATING+ > ${STARTUP_MEMORY}}
    136 
    137   .startup 0x100:
    138   {
    139     KEEP (*crt0.o(.text.__startup))
    140   } ${RELOCATING+ > ${STARTUP_MEMORY}}
    141 
    142   /* Read-only sections, merged into text segment: */
    143   ${TEXT_DYNAMIC+${DYNAMIC}}
    144   .hash        ${RELOCATING-0} : { *(.hash)		}
    145   .dynsym      ${RELOCATING-0} : { *(.dynsym)		}
    146   .dynstr      ${RELOCATING-0} : { *(.dynstr)		}
    147   .gnu.version ${RELOCATING-0} : { *(.gnu.version)	}
    148   .gnu.version_d ${RELOCATING-0} : { *(.gnu.version_d)	}
    149   .gnu.version_r ${RELOCATING-0} : { *(.gnu.version_r)	}
    150 
    151   .rel.init     ${RELOCATING-0} : { *(.rel.init) }
    152   .rela.init    ${RELOCATING-0} : { *(.rela.init) }
    153   .rel.text     ${RELOCATING-0} : { *(.rel.text${RELOCATING+ .rel.text.* .rel.gnu.linkonce.t.*}) }
    154   .rela.text    ${RELOCATING-0} : { *(.rela.text${RELOCATING+ .rela.text.* .rela.gnu.linkonce.t.*}) }
    155   .rel.fini     ${RELOCATING-0} : { *(.rel.fini) }
    156   .rela.fini    ${RELOCATING-0} : { *(.rela.fini) }
    157   .rel.rodata   ${RELOCATING-0} : { *(.rel.rodata${RELOCATING+ .rel.rodata.* .rel.gnu.linkonce.r.*}) }
    158   .rela.rodata  ${RELOCATING-0} : { *(.rela.rodata${RELOCATING+ .rela.rodata.* .rela.gnu.linkonce.r.*}) }
    159   .rel.data     ${RELOCATING-0} : { *(.rel.data${RELOCATING+ .rel.data.* .rel.gnu.linkonce.d.*}) }
    160   .rela.data    ${RELOCATING-0} : { *(.rela.data${RELOCATING+ .rela.data.* .rela.gnu.linkonce.d.*}) }
    161   .rel.tdata	${RELOCATING-0} : { *(.rel.tdata${RELOCATING+ .rel.tdata.* .rel.gnu.linkonce.td.*}) }
    162   .rela.tdata	${RELOCATING-0} : { *(.rela.tdata${RELOCATING+ .rela.tdata.* .rela.gnu.linkonce.td.*}) }
    163   .rel.tbss	${RELOCATING-0} : { *(.rel.tbss${RELOCATING+ .rel.tbss.* .rel.gnu.linkonce.tb.*}) }
    164   .rela.tbss	${RELOCATING-0} : { *(.rela.tbss${RELOCATING+ .rela.tbss.* .rela.gnu.linkonce.tb.*}) }
    165   .rel.ctors    ${RELOCATING-0} : { *(.rel.ctors) }
    166   .rela.ctors   ${RELOCATING-0} : { *(.rela.ctors) }
    167   .rel.dtors    ${RELOCATING-0} : { *(.rel.dtors) }
    168   .rela.dtors   ${RELOCATING-0} : { *(.rela.dtors) }
    169   .rel.got      ${RELOCATING-0} : { *(.rel.got) }
    170   .rela.got     ${RELOCATING-0} : { *(.rela.got) }
    171   ${REL_SDATA}
    172   ${REL_SBSS}
    173   ${REL_SDATA2}
    174   ${REL_SBSS2}
    175   .rel.bss      ${RELOCATING-0} : { *(.rel.bss${RELOCATING+ .rel.bss.* .rel.gnu.linkonce.b.*}) }
    176   .rela.bss     ${RELOCATING-0} : { *(.rela.bss${RELOCATING+ .rela.bss.* .rela.gnu.linkonce.b.*}) }
    177 
    178   .jcr : { KEEP (*(.jcr)) } ${RELOCATING+> ${TEXT_MEMORY}}
    179   .eh_frame : { KEEP (*(.eh_frame)) } ${RELOCATING+> ${TEXT_MEMORY}}
    180   .gcc_except_table : { *(.gcc_except_table) *(.gcc_except_table.*) } ${RELOCATING+> ${TEXT_MEMORY}}
    181   .plt : { *(.plt) } ${RELOCATING+> ${TEXT_MEMORY}}
    182 
    183   .rodata ${RELOCATING-0} :
    184   {
    185     *(.rodata) ${RELOCATING+*(.rodata.*)} ${RELOCATING+*(.gnu.linkonce.r.*)}
    186   } ${RELOCATING+> ${TEXT_MEMORY}}
    187 
    188   .rodata1      ${RELOCATING-0} : { *(.rodata1) } ${RELOCATING+> ${TEXT_MEMORY}}
    189 
    190   .init         ${RELOCATING-0} :
    191   {
    192     ${RELOCATING+${INIT_START}}
    193     KEEP (*(.init))
    194     ${RELOCATING+${INIT_END}}
    195   } ${RELOCATING+ > ${TEXT_MEMORY}}  =${NOP-0}
    196 
    197   .text         ${RELOCATING-0} :
    198   {
    199     ${RELOCATING+${TEXT_START_SYMBOLS}}
    200 
    201     *(.text .stub${RELOCATING+ .text.* .gnu.linkonce.t.*})
    202     /* .gnu.warning sections are handled specially by elf32.em.  */
    203     *(.gnu.warning)
    204 
    205     ${RELOCATING+${OTHER_TEXT_SECTIONS}}
    206 
    207   } ${RELOCATING+ > ${TEXT_MEMORY}} =${NOP-0}
    208 
    209   .fini         ${RELOCATING-0} :
    210   {
    211     ${RELOCATING+${FINI_START}}
    212     KEEP (*(.fini))
    213     ${RELOCATING+${FINI_END}}
    214 
    215     ${RELOCATING+PROVIDE (__etext = .);}
    216     ${RELOCATING+PROVIDE (_etext = .);}
    217     ${RELOCATING+PROVIDE (etext = .);}
    218   } ${RELOCATING+ > ${TEXT_MEMORY}} =${NOP-0}
    219 
    220   ${RELOCATING+${OTHER_READONLY_SECTIONS}}
    221 
    222   /* Start of the data section image in ROM.  */
    223   ${RELOCATING+__data_image = .;}
    224   ${RELOCATING+PROVIDE (__data_image = .);}
    225 
    226   .data	${RELOCATING-0} :
    227   {
    228     ${RELOCATING+ PROVIDE (__data_start = .) ; }
    229     /* --gc-sections will delete empty .data. This leads to wrong start
    230        addresses for subsequent sections because -Tdata= from the command
    231        line will have no effect, see PR13697.  Thus, keep .data  */
    232     KEEP (*(.data))
    233     ${RELOCATING+${DATA_START_SYMBOLS}}
    234     *(.data${RELOCATING+ .data.* .gnu.linkonce.d.*})
    235     ${CONSTRUCTING+SORT(CONSTRUCTORS)}
    236 
    237   } ${RELOCATING+ > ${DATA_MEMORY}}
    238 
    239   ${GOT}
    240   ${RELOCATING+${CTOR}}
    241   ${RELOCATING+${DTOR}}
    242 
    243   ${RELOCATING+${SDATA}}
    244   ${RELOCATING+${SDATA2}}
    245   ${RELOCATING+${SBSS}}
    246   ${RELOCATING+${SBSS2}}
    247   .bss          ${RELOCATING-0} :
    248   {
    249    *(.dynbss)
    250    *(.bss${RELOCATING+ .bss.* .gnu.linkonce.b.*})
    251    *(COMMON)
    252    /* Align here to ensure that the .bss section occupies space up to
    253       _end.  Align after .bss to ensure correct alignment even if the
    254       .bss section disappears because there are no input sections.  */
    255    ${RELOCATING+. = ALIGN(${ALIGNMENT});}
    256    ${RELOCATING+_end = .;}
    257    ${RELOCATING+PROVIDE (end = .);}
    258   } ${RELOCATING+ > ${DATA_MEMORY}}
    259 
    260   /* Global data not cleared after reset.  */
    261   .noinit ${RELOCATING-0}:
    262   {
    263     *(.noinit*)
    264     ${RELOCATING+. = ALIGN(${ALIGNMENT});}
    265     ${RELOCATING+ PROVIDE (__start_heap = .) ; }
    266   } ${RELOCATING+ > ${DATA_MEMORY}}
    267 
    268 
    269   /* Stabs debugging sections.  */
    270   .stab          0 : { *(.stab) }
    271   .stabstr       0 : { *(.stabstr) }
    272   .stab.excl     0 : { *(.stab.excl) }
    273   .stab.exclstr  0 : { *(.stab.exclstr) }
    274   .stab.index    0 : { *(.stab.index) }
    275   .stab.indexstr 0 : { *(.stab.indexstr) }
    276 
    277   .comment       0 : { *(.comment) }
    278 
    279   /* DWARF debug sections.
    280      Symbols in the DWARF debugging sections are relative to the beginning
    281      of the section so we begin them at 0.  */
    282 
    283   /* DWARF 1 */
    284   .debug          0 : { *(.debug) }
    285   .line           0 : { *(.line) }
    286 
    287   /* GNU DWARF 1 extensions */
    288   .debug_srcinfo  0 : { *(.debug_srcinfo) }
    289   .debug_sfnames  0 : { *(.debug_sfnames) }
    290 
    291   /* DWARF 1.1 and DWARF 2 */
    292   .debug_aranges  0 : { *(.debug_aranges) }
    293   .debug_pubnames 0 : { *(.debug_pubnames) }
    294 
    295   /* DWARF 2 */
    296   .debug_info     0 : { *(.debug_info) *(.gnu.linkonce.wi.*) }
    297   .debug_abbrev   0 : { *(.debug_abbrev) }
    298   .debug_line     0 : { *(.debug_line) }
    299   .debug_frame    0 : { *(.debug_frame) }
    300   .debug_str      0 : { *(.debug_str) }
    301   .debug_loc      0 : { *(.debug_loc) }
    302   .debug_macinfo  0 : { *(.debug_macinfo) }
    303 
    304   /* DWARF 3 */
    305   .debug_pubtypes 0 : { *(.debug_pubtypes) }
    306   .debug_ranges   0 : { *(.debug_ranges) }
    307 
    308   /* DWARF Extension.  */
    309   .debug_macro    0 : { *(.debug_macro) }
    310 
    311   /* ARC Extension Sections */
    312   .arcextmap	  0 : { *(.gnu.linkonce.arcextmap.*) }
    313 }
    314 EOF
    315