Home | History | Annotate | Line # | Download | only in scripttempl
      1 # Copyright (C) 2014-2025 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-2025 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("elf32-v850-rh850", "elf32-v850-rh850",
     15 	      "elf32-v850-rh850")
     16 OUTPUT_ARCH(v850:rh850)
     17 ${RELOCATING+ENTRY(_start)}
     18 SEARCH_DIR(.);
     19 ${RELOCATING+EXTERN(__ctbp __ep __gp)};
     20 SECTIONS
     21 {
     22   /* PR 32100: GDB makes use of the fact that the .note.gnu.build-id
     23      section is typically placed next to the ELF headers.  */
     24   .note.gnu.build-id ${RELOCATING-0}: { *(.note.gnu.build-id) }
     25 
     26   /* This saves a little space in the ELF file, since the zda starts
     27      at a higher location that the ELF headers take up.  */
     28 
     29   .zdata ${RELOCATING+${ZDATA_START_ADDR}} :
     30   {
     31 	*(.zdata)
     32 	${RELOCATING+*(.zdata23)
     33 	*(.zbss)
     34 	*(.zbss23)
     35 	*(reszdata)
     36 	*(.zcommon)}
     37   }
     38 
     39   /* This is the read only part of the zero data area.
     40      Having it as a separate section prevents its
     41      attributes from being inherited by the zdata
     42      section.  Specifically it prevents the zdata
     43      section from being marked READONLY.  */
     44 
     45   .rozdata ${RELOCATING+${ROZDATA_START_ADDR}} :
     46   {
     47 	*(.rozdata)
     48 	${RELOCATING+*(romzdata)
     49 	*(romzbss)
     50 	*(.zconst)
     51 	*(.zconst23)}
     52   }
     53 
     54   /* Read-only sections, merged into text segment.  */
     55   ${RELOCATING+. = ${TEXT_START_ADDR};}
     56   .interp	: { *(.interp) }
     57   .hash		: { *(.hash) }
     58   .dynsym	: { *(.dynsym) }
     59   .dynstr	: { *(.dynstr) }
     60   .rel.text	: { *(.rel.text) }
     61   .rela.text	: { *(.rela.text) }
     62   .rel.data	: { *(.rel.data) }
     63   .rela.data	: { *(.rela.data) }
     64   .rel.rodata	: { *(.rel.rodata) }
     65   .rela.rodata	: { *(.rela.rodata) }
     66   .rel.gcc_except_table : { *(.rel.gcc_except_table) }
     67   .rela.gcc_except_table : { *(.rela.gcc_except_table) }
     68   .rel.got	: { *(.rel.got) }
     69   .rela.got	: { *(.rela.got) }
     70   .rel.ctors	: { *(.rel.ctors) }
     71   .rela.ctors	: { *(.rela.ctors) }
     72   .rel.dtors	: { *(.rel.dtors) }
     73   .rela.dtors	: { *(.rela.dtors) }
     74   .rel.init	: { *(.rel.init) }
     75   .rela.init	: { *(.rela.init) }
     76   .rel.fini	: { *(.rel.fini) }
     77   .rela.fini	: { *(.rela.fini) }
     78   .rel.bss	: { *(.rel.bss) }
     79   .rela.bss	: { *(.rela.bss) }
     80   .rel.plt	: { *(.rel.plt) }
     81   .rela.plt	: { *(.rela.plt) }
     82   .init		: { KEEP (*(SORT_NONE(.init))) } =0
     83   .plt		: { *(.plt) }
     84 
     85   .text		:
     86   {
     87     *(.text)
     88     ${RELOCATING+*(.text.*)}
     89 
     90     /* .gnu.warning sections are handled specially by elf.em.  */
     91     *(.gnu.warning)
     92     ${RELOCATING+*(.gnu.linkonce.t*)}
     93   } =0
     94 
     95   ${RELOCATING+_etext = .;}
     96   ${RELOCATING+PROVIDE (etext = .);}
     97 
     98    /* This is special code area at the end of the normal text section.
     99       It contains a small lookup table at the start followed by the
    100       code pointed to by entries in the lookup table.  */
    101 
    102   .call_table_data ${RELOCATING+${CALL_TABLE_START_ADDR}} :
    103   {
    104     ${RELOCATING+PROVIDE(__ctbp = .);}
    105     *(.call_table_data)
    106   } = 0xff   /* Fill gaps with 0xff.  */
    107 
    108   .call_table_text :
    109   {
    110     *(.call_table_text)
    111   }
    112 
    113   .fini		: { KEEP (*(SORT_NONE(.fini))) } =0
    114   .rodata	:
    115   {
    116 	*(.rodata)
    117 	${RELOCATING+*(.rodata.*)
    118 	*(.gnu.linkonce.r*)
    119 	*(.const)}
    120   }
    121   .rodata1	: { *(.rodata1) }
    122 
    123   .data		:
    124   {
    125     *(.data)
    126     ${RELOCATING+*(.data.*)
    127     *(.gnu.linkonce.d*)}
    128     ${CONSTRUCTING+CONSTRUCTORS}
    129   }
    130   .data1	: { *(.data1) }
    131   .ctors	:
    132   {
    133     ${CONSTRUCTING+___ctors = .;}
    134     KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
    135     ${RELOCATING+KEEP (*(SORT(.ctors.*)))}
    136     KEEP (*crtend(.ctors))
    137     ${CONSTRUCTING+___ctors_end = .;}
    138   }
    139   .dtors	:
    140   {
    141     ${CONSTRUCTING+___dtors = .;}
    142     KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
    143     ${RELOCATING+KEEP (*(SORT(.dtors.*)))}
    144     KEEP (*crtend.o(.dtors))
    145     ${CONSTRUCTING+___dtors_end = .;}
    146   }
    147   .jcr		:
    148   {
    149     KEEP (*(.jcr))
    150   }
    151 
    152   .gcc_except_table : { *(.gcc_except_table) }
    153 
    154   .got		: {${RELOCATING+ *(.got.plt)} *(.got) }
    155   .dynamic	: { *(.dynamic) }
    156 
    157   .tdata ${RELOCATING+${TDATA_START_ADDR}} :
    158   {
    159 	${RELOCATING+PROVIDE (__ep = .);
    160 	*(.edata)
    161 	*(.edata23)
    162 	*(.tbyte)
    163 	*(.tcommon_byte)}
    164 	*(.tdata)
    165 	${RELOCATING+*(.tdata*)
    166 	*(.ebss)
    167 	*(.ebss23)
    168 	*(.tbss)
    169 	*(.tbss*)
    170 	*(.tcommon)}
    171   }
    172 
    173   /* We want the small data sections together, so single-instruction offsets
    174      can access them all, and initialized data all before uninitialized, so
    175      we can shorten the on-disk segment size.  */
    176 
    177   .sdata ${RELOCATING+${SDATA_START_ADDR}} :
    178   {
    179 	${RELOCATING+PROVIDE (__gp = . + 0x8000);}
    180 	*(.sdata)
    181 	${RELOCATING+*(.sdata23)}
    182    }
    183 
    184   /* See comment about .rozdata. */
    185   .rosdata ${RELOCATING+${ROSDATA_START_ADDR}} :
    186   {
    187 	*(.rosdata)
    188 	${RELOCATING+*(.sconst)
    189 	*(.sconst23)}
    190   }
    191 
    192   /* We place the .sbss data section AFTER the .rosdata section, so that
    193      it can directly precede the .bss section.  This allows runtime startup
    194      code to initialise all the zero-data sections by simply taking the
    195      value of '_edata' and zeroing until it reaches '_end'.  */
    196 
    197   .sbss :
    198   {
    199 	${RELOCATING+__sbss_start = .;}
    200 	*(.sbss)
    201 	${RELOCATING+*(.sbss23)
    202 	*(.scommon)}
    203   }
    204 
    205   ${RELOCATING+_edata  = DEFINED (__sbss_start) ? __sbss_start : . ;}
    206   ${RELOCATING+PROVIDE (edata = _edata);}
    207 
    208   .bss       :
    209   {
    210 	${RELOCATING+__bss_start = DEFINED (__sbss_start) ? __sbss_start : . ;}
    211 	${RELOCATING+__real_bss_start = . ;}
    212 	${RELOCATING+*(.dynbss)}
    213 	*(.bss)
    214 	${RELOCATING+*(COMMON)}
    215   }
    216 
    217   ${RELOCATING+_end = . ;}
    218   ${RELOCATING+PROVIDE (end = .);}
    219   ${RELOCATING+PROVIDE (_heap_start = .);}
    220 
    221   .note.renesas 0 : { KEEP(*(.note.renesas)) }
    222 
    223 EOF
    224 
    225 source_sh $srcdir/scripttempl/misc-sections.sc
    226 source_sh $srcdir/scripttempl/DWARF.sc
    227 
    228 cat <<EOF
    229   /* User stack.  */
    230   .stack 0x200000	:
    231   {
    232 	${RELOCATING+__stack = .;}
    233 	*(.stack)
    234   }
    235 }
    236 EOF
    237