Home | History | Annotate | Line # | Download | only in scripttempl
      1   1.1  christos # Linker script for PE.
      2   1.3  christos #
      3  1.10  christos # Copyright (C) 2014-2025 Free Software Foundation, Inc.
      4   1.6  christos #
      5   1.3  christos # Copying and distribution of this file, with or without modification,
      6   1.3  christos # are permitted in any medium without royalty provided the copyright
      7   1.3  christos # notice and this notice are preserved.
      8   1.1  christos 
      9   1.1  christos if test -z "${RELOCATEABLE_OUTPUT_FORMAT}"; then
     10   1.1  christos   RELOCATEABLE_OUTPUT_FORMAT=${OUTPUT_FORMAT}
     11   1.1  christos fi
     12   1.1  christos 
     13   1.1  christos # We can't easily and portably get an unquoted $ in a shell
     14   1.1  christos # substitution, so we do this instead.
     15   1.1  christos if test "${RELOCATING}"; then
     16   1.1  christos   R_TEXT='*(.text$*)'
     17   1.1  christos   R_DATA='*(.data$*)'
     18   1.1  christos   R_RDATA='*(.rdata$*)'
     19   1.1  christos   R_IDATA='
     20   1.1  christos     *(.idata$2)
     21   1.1  christos     *(.idata$3)
     22   1.1  christos     /* These zeroes mark the end of the import list.  */
     23   1.1  christos     LONG (0); LONG (0); LONG (0); LONG (0); LONG (0);
     24   1.1  christos     *(.idata$4)
     25   1.1  christos     *(.idata$5)
     26   1.1  christos     *(.idata$6)
     27   1.1  christos     *(.idata$7)'
     28   1.1  christos   R_CRT='*(.CRT$*)'
     29   1.1  christos   R_RSRC='*(.rsrc$*)'
     30   1.1  christos   R_EXC='*(.exc$*)'
     31   1.1  christos else
     32   1.1  christos   R_TEXT=
     33   1.1  christos   R_DATA=
     34   1.1  christos   R_RDATA=
     35   1.1  christos   R_IDATA=
     36   1.1  christos   R_CRT=
     37   1.1  christos   R_RSRC=
     38   1.1  christos   R_EXC=
     39   1.1  christos fi
     40   1.1  christos 
     41   1.1  christos cat <<EOF
     42  1.10  christos /* Copyright (C) 2014-2025 Free Software Foundation, Inc.
     43   1.3  christos 
     44   1.3  christos    Copying and distribution of this script, with or without modification,
     45   1.3  christos    are permitted in any medium without royalty provided the copyright
     46   1.3  christos    notice and this notice are preserved.  */
     47   1.3  christos 
     48   1.1  christos ${RELOCATING+OUTPUT_FORMAT(${OUTPUT_FORMAT})}
     49   1.1  christos ${RELOCATING-OUTPUT_FORMAT(${RELOCATEABLE_OUTPUT_FORMAT})}
     50   1.1  christos 
     51   1.1  christos ${LIB_SEARCH_DIRS}
     52   1.1  christos 
     53   1.1  christos ${RELOCATING+ENTRY (__start)}
     54   1.1  christos ${RELOCATING+header = .;}
     55   1.1  christos ${RELOCATING+__fltused = .; /* set up floating pt for MS .obj\'s */}
     56   1.1  christos ${RELOCATING+__ldused = .;}
     57   1.1  christos SECTIONS
     58   1.1  christos {
     59   1.6  christos   .text ${RELOCATING+ __image_base__ + __section_alignment__ } :
     60   1.1  christos   {
     61   1.1  christos     ${RELOCATING+ __text_start__ = . ;}
     62   1.7  christos     ${RELOCATING+ KEEP (*(SORT_NONE(.init)))}
     63   1.1  christos     *(.text)
     64   1.1  christos     ${R_TEXT}
     65   1.1  christos     *(.glue_7t)
     66   1.1  christos     *(.glue_7)
     67   1.6  christos     ${CONSTRUCTING+ ___CTOR_LIST__ = .; __CTOR_LIST__ = . ;
     68   1.1  christos 			LONG (-1); *(.ctors); *(.ctor); LONG (0); }
     69   1.6  christos     ${CONSTRUCTING+ ___DTOR_LIST__ = .; __DTOR_LIST__ = . ;
     70   1.1  christos 			LONG (-1); *(.dtors); *(.dtor);  LONG (0); }
     71   1.7  christos     ${RELOCATING+ KEEP (*(SORT_NONE(.fini)))}
     72   1.7  christos     ${RELOCATING+/* ??? Why is .gcc_exc here?  */}
     73   1.1  christos     ${RELOCATING+ *(.gcc_exc)}
     74   1.1  christos     ${RELOCATING+ etext = .;}
     75   1.1  christos     ${RELOCATING+ __text_end__ = .;}
     76   1.1  christos     *(.gcc_except_table)
     77   1.1  christos   }
     78   1.1  christos 
     79   1.1  christos   /* The Cygwin32 library uses a section to avoid copying certain data
     80   1.1  christos      on fork.  This used to be named ".data$nocopy".  The linker used
     81   1.1  christos      to include this between __data_start__ and __data_end__, but that
     82   1.1  christos      breaks building the cygwin32 dll.  Instead, we name the section
     83   1.1  christos      ".data_cygwin_nocopy" and explicitly include it after __data_end__. */
     84   1.1  christos 
     85   1.6  christos   .data ${RELOCATING+BLOCK(__section_alignment__)} :
     86   1.1  christos   {
     87   1.1  christos     ${RELOCATING+__data_start__ = . ;}
     88   1.1  christos     *(.data)
     89   1.1  christos     *(.data2)
     90   1.1  christos     ${R_DATA}
     91   1.1  christos     ${RELOCATING+__data_end__ = . ;}
     92   1.1  christos     ${RELOCATING+*(.data_cygwin_nocopy)}
     93   1.1  christos   }
     94   1.1  christos 
     95   1.1  christos   .bss ${RELOCATING+BLOCK(__section_alignment__)} :
     96   1.1  christos   {
     97   1.1  christos     ${RELOCATING+__bss_start__ = . ;}
     98   1.1  christos     *(.bss)
     99   1.1  christos     *(COMMON)
    100   1.1  christos     /* link.exe apparently pulls in .obj's because of UNDEF common
    101   1.1  christos 	symbols, which is not the coff way, but that's MS for you. */
    102   1.1  christos     *(.CRT\$XCA)
    103   1.1  christos     *(.CRT\$XCZ)
    104   1.1  christos     *(.CRT\$XIA)
    105   1.1  christos     *(.CRT\$XIZ)
    106   1.1  christos     ${RELOCATING+__bss_end__ = . ;}
    107   1.1  christos   }
    108   1.1  christos 
    109   1.1  christos   .rdata ${RELOCATING+BLOCK(__section_alignment__)} :
    110   1.1  christos   {
    111   1.1  christos     *(.rdata)
    112   1.1  christos     ${R_RDATA}
    113   1.1  christos     *(.eh_frame)
    114   1.1  christos   }
    115   1.1  christos 
    116   1.1  christos   .edata ${RELOCATING+BLOCK(__section_alignment__)} :
    117   1.1  christos   {
    118   1.1  christos     *(.edata)
    119   1.1  christos   }
    120   1.1  christos 
    121   1.1  christos   /DISCARD/ :
    122   1.1  christos   {
    123   1.1  christos     *(.debug\$S)
    124   1.1  christos     *(.debug\$T)
    125   1.1  christos     *(.debug\$F)
    126   1.1  christos     *(.drectve)
    127   1.1  christos     *(.debug*)
    128   1.1  christos   }
    129   1.1  christos 
    130   1.1  christos   .idata ${RELOCATING+BLOCK(__section_alignment__)} :
    131   1.1  christos   {
    132   1.1  christos     /* This cannot currently be handled with grouped sections.
    133   1.1  christos 	See pe.em:sort_sections.  */
    134   1.1  christos     ${R_IDATA}
    135   1.1  christos   }
    136   1.1  christos   .CRT ${RELOCATING+BLOCK(__section_alignment__)} :
    137   1.6  christos   {
    138   1.1  christos     ${R_CRT}
    139   1.1  christos   }
    140   1.1  christos 
    141   1.1  christos   .endjunk ${RELOCATING+BLOCK(__section_alignment__)} :
    142   1.1  christos   {
    143   1.1  christos     /* end is deprecated, don't use it */
    144   1.1  christos     ${RELOCATING+ end = .;}
    145   1.1  christos     ${RELOCATING+ _end = .;}
    146   1.1  christos     ${RELOCATING+ __end__ = .;}
    147   1.1  christos   }
    148   1.1  christos 
    149   1.1  christos   .reloc ${RELOCATING+BLOCK(__section_alignment__)} :
    150   1.6  christos   {
    151   1.1  christos     *(.reloc)
    152   1.1  christos   }
    153   1.1  christos 
    154   1.1  christos   .rsrc ${RELOCATING+BLOCK(__section_alignment__)} :
    155   1.6  christos   {
    156   1.1  christos     *(.rsrc)
    157   1.1  christos     ${R_RSRC}
    158   1.1  christos   }
    159   1.1  christos 
    160   1.1  christos   .exc ${RELOCATING+BLOCK(__section_alignment__)} :
    161   1.6  christos   {
    162   1.1  christos     *(.exc)
    163   1.1  christos     ${R_EXC}
    164   1.1  christos   }
    165   1.1  christos 
    166   1.1  christos   .stab ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
    167   1.1  christos   {
    168   1.1  christos     [ .stab ]
    169   1.1  christos   }
    170   1.1  christos 
    171   1.1  christos   .stabstr ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
    172   1.1  christos   {
    173   1.1  christos     [ .stabstr ]
    174   1.1  christos   }
    175   1.3  christos EOF
    176   1.1  christos 
    177   1.9  christos source_sh $srcdir/scripttempl/DWARF.sc
    178   1.3  christos 
    179   1.3  christos cat <<EOF
    180   1.1  christos }
    181   1.1  christos EOF
    182