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