Home | History | Annotate | Download | only in ldscripts
      1 /* Script for -z combreloc -z now -z relro: combine and sort reloc sections */
      2 OUTPUT_FORMAT("elf32-i386", "elf32-i386",
      3 	      "elf32-i386")
      4 OUTPUT_ARCH(i386)
      5 ENTRY(_start)
      6 SECTIONS
      7 {
      8   /* Read-only sections, merged into text segment: */
      9   PROVIDE (__executable_start = 0x08048000); . = 0x08048000 + SIZEOF_HEADERS;
     10   .interp         : { *(.interp) }
     11   .note.gnu.build-id : { *(.note.gnu.build-id) }
     12   .hash           : { *(.hash) }
     13   .gnu.hash       : { *(.gnu.hash) }
     14   .dynsym         : { *(.dynsym) }
     15   .dynstr         : { *(.dynstr) }
     16   .gnu.version    : { *(.gnu.version) }
     17   .gnu.version_d  : { *(.gnu.version_d) }
     18   .gnu.version_r  : { *(.gnu.version_r) }
     19   .rel.dyn        :
     20     {
     21       *(.rel.init)
     22       *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*)
     23       *(.rel.fini)
     24       *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*)
     25       *(.rel.data.rel.ro* .rel.gnu.linkonce.d.rel.ro.*)
     26       *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*)
     27       *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*)
     28       *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*)
     29       *(.rel.ctors)
     30       *(.rel.dtors)
     31       *(.rel.got)
     32       *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*)
     33       *(.rel.ifunc)
     34     }
     35   .rel.plt        :
     36     {
     37       *(.rel.plt)
     38       PROVIDE_HIDDEN (__rel_iplt_start = .);
     39       *(.rel.iplt)
     40       PROVIDE_HIDDEN (__rel_iplt_end = .);
     41     }
     42   .init           :
     43   {
     44     KEEP (*(.init))
     45   } =0x90909090
     46   .plt            : { *(.plt) *(.iplt) }
     47   .text           :
     48   {
     49     *(.text.unlikely .text.*_unlikely)
     50     *(.text.exit .text.exit.*)
     51     *(.text.startup .text.startup.*)
     52     *(.text.hot .text.hot.*)
     53     *(.text .stub .text.* .gnu.linkonce.t.*)
     54     /* .gnu.warning sections are handled specially by elf32.em.  */
     55     *(.gnu.warning)
     56   } =0x90909090
     57   .fini           :
     58   {
     59     KEEP (*(.fini))
     60   } =0x90909090
     61   PROVIDE (__etext = .);
     62   PROVIDE (_etext = .);
     63   PROVIDE (etext = .);
     64   .rodata         : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
     65   .rodata1        : { *(.rodata1) }
     66   .eh_frame_hdr : { *(.eh_frame_hdr) }
     67   .eh_frame       : ONLY_IF_RO { KEEP (*(.eh_frame)) }
     68   .gcc_except_table   : ONLY_IF_RO { *(.gcc_except_table .gcc_except_table.*) }
     69   /* Adjust the address for the data segment.  We want to align at exactly
     70      a page boundary to make life easier for apriori. */
     71   . = ALIGN (CONSTANT (MAXPAGESIZE)); . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE));
     72   /* Exception handling  */
     73   .eh_frame       : ONLY_IF_RW { KEEP (*(.eh_frame)) }
     74   .gcc_except_table   : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) }
     75   /* Thread Local Storage sections  */
     76   .tdata	  : { *(.tdata .tdata.* .gnu.linkonce.td.*) }
     77   .tbss		  : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
     78   /* Ensure the __preinit_array_start label is properly aligned.  We
     79      could instead move the label definition inside the section, but
     80      the linker would then create the section even if it turns out to
     81      be empty, which isn't pretty.  */
     82   . = ALIGN(32 / 8);
     83   PROVIDE_HIDDEN (__preinit_array_start = .);
     84   .preinit_array     :
     85   {
     86     KEEP (*(.preinit_array))
     87   }
     88   PROVIDE_HIDDEN (__preinit_array_end = .);
     89   PROVIDE_HIDDEN (__init_array_start = .);
     90   .init_array     :
     91   {
     92     KEEP (*crtbegin*.o(.init_array))
     93     KEEP (*(SORT(.init_array.*)))
     94     KEEP (*(.init_array))
     95   }
     96   PROVIDE_HIDDEN (__init_array_end = .);
     97   PROVIDE_HIDDEN (__fini_array_start = .);
     98   .fini_array     :
     99   {
    100     KEEP (*crtbegin*.o(.fini_array))
    101     KEEP (*(SORT(.fini_array.*)))
    102     KEEP (*(.fini_array))
    103   }
    104   PROVIDE_HIDDEN (__fini_array_end = .);
    105   .ctors          :
    106   {
    107     /* gcc uses crtbegin.o to find the start of
    108        the constructors, so we make sure it is
    109        first.  Because this is a wildcard, it
    110        doesn't matter if the user does not
    111        actually link against crtbegin.o; the
    112        linker won't look for a file to match a
    113        wildcard.  The wildcard also means that it
    114        doesn't matter which directory crtbegin.o
    115        is in.  */
    116     KEEP (*crtbegin.o(.ctors))
    117     KEEP (*crtbegin*.o(.ctors))
    118     /* We don't want to include the .ctor section from
    119        the crtend.o file until after the sorted ctors.
    120        The .ctor section from the crtend file contains the
    121        end of ctors marker and it must be last */
    122     KEEP (*(EXCLUDE_FILE (*crtend.o *crtend*.o ) .ctors))
    123     KEEP (*(SORT(.ctors.*)))
    124     KEEP (*(.ctors))
    125   }
    126   .dtors          :
    127   {
    128     KEEP (*crtbegin.o(.dtors))
    129     KEEP (*crtbegin*.o(.dtors))
    130     KEEP (*(EXCLUDE_FILE (*crtend.o *crtend*.o ) .dtors))
    131     KEEP (*(SORT(.dtors.*)))
    132     KEEP (*(.dtors))
    133   }
    134   .jcr            : { KEEP (*(.jcr)) }
    135   .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*) }
    136   .dynamic        : { *(.dynamic) }
    137   .got            : { *(.got.plt) *(.igot.plt) *(.got) *(.igot) }
    138   . = DATA_SEGMENT_RELRO_END (0, .);
    139   .data           :
    140   {
    141     *(.data .data.* .gnu.linkonce.d.*)
    142     SORT(CONSTRUCTORS)
    143   }
    144   .data1          : { *(.data1) }
    145   _edata = .; PROVIDE (edata = .);
    146   __bss_start = .;
    147   .bss            :
    148   {
    149    *(.dynbss)
    150    *(.bss .bss.* .gnu.linkonce.b.*)
    151    *(COMMON)
    152    /* Align here to ensure that the .bss section occupies space up to
    153       _end.  Align after .bss to ensure correct alignment even if the
    154       .bss section disappears because there are no input sections.  */
    155    . = ALIGN(32 / 8);
    156   }
    157   . = ALIGN(32 / 8);
    158   . = ALIGN(32 / 8);
    159   _end = .;
    160   _bss_end__ = . ; __bss_end__ = . ; __end__ = . ;
    161   PROVIDE (end = .);
    162   . = DATA_SEGMENT_END (.);
    163   /* Stabs debugging sections.  */
    164   .stab          0 : { *(.stab) }
    165   .stabstr       0 : { *(.stabstr) }
    166   .stab.excl     0 : { *(.stab.excl) }
    167   .stab.exclstr  0 : { *(.stab.exclstr) }
    168   .stab.index    0 : { *(.stab.index) }
    169   .stab.indexstr 0 : { *(.stab.indexstr) }
    170   .comment       0 : { *(.comment) }
    171   /* DWARF debug sections.
    172      Symbols in the DWARF debugging sections are relative to the beginning
    173      of the section so we begin them at 0.  */
    174   /* DWARF 1 */
    175   .debug          0 : { *(.debug) }
    176   .line           0 : { *(.line) }
    177   /* GNU DWARF 1 extensions */
    178   .debug_srcinfo  0 : { *(.debug_srcinfo .zdebug_srcinfo) }
    179   .debug_sfnames  0 : { *(.debug_sfnames .zdebug_sfnames) }
    180   /* DWARF 1.1 and DWARF 2 */
    181   .debug_aranges  0 : { *(.debug_aranges .zdebug_aranges) }
    182   .debug_pubnames 0 : { *(.debug_pubnames .zdebug_pubnames) }
    183   /* DWARF 2 */
    184   .debug_info     0 : { *(.debug_info .gnu.linkonce.wi.* .zdebug_info) }
    185   .debug_abbrev   0 : { *(.debug_abbrev .zdebug_abbrev) }
    186   .debug_line     0 : { *(.debug_line .zdebug_line) }
    187   .debug_frame    0 : { *(.debug_frame .zdebug_frame) }
    188   .debug_str      0 : { *(.debug_str .zdebug_str) }
    189   .debug_loc      0 : { *(.debug_loc .zdebug_loc) }
    190   .debug_macinfo  0 : { *(.debug_macinfo .zdebug_macinfo) }
    191   /* SGI/MIPS DWARF 2 extensions */
    192   .debug_weaknames 0 : { *(.debug_weaknames .zdebug_weaknames) }
    193   .debug_funcnames 0 : { *(.debug_funcnames .zdebug_funcnames) }
    194   .debug_typenames 0 : { *(.debug_typenames .zdebug_typenames) }
    195   .debug_varnames  0 : { *(.debug_varnames .zdebug_varnames) }
    196   /* DWARF 3 */
    197   .debug_pubtypes 0 : { *(.debug_pubtypes .zdebug_pubtypes) }
    198   .debug_ranges   0 : { *(.debug_ranges .zdebug_ranges) }
    199   .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }
    200   /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) *(.mdebug.*) }
    201 }
    202