Home | History | Annotate | Download | only in ldscripts
      1 /* Script for -pie -z combreloc: position independent executable, combine & sort relocs */
      2 /* Copyright (C) 2014-2016 Free Software Foundation, Inc.
      3    Copying and distribution of this script, with or without modification,
      4    are permitted in any medium without royalty provided the copyright
      5    notice and this notice are preserved.  */
      6 OUTPUT_FORMAT("elf32-i386", "elf32-i386",
      7 	      "elf32-i386")
      8 OUTPUT_ARCH(i386)
      9 ENTRY(_start)
     10 SEARCH_DIR("=/tmp/1285d9c885c98a78fb8e48ce0e3cec51/i386-linux-android/lib32"); SEARCH_DIR("=/usr/local/lib32"); SEARCH_DIR("=/lib32"); SEARCH_DIR("=/usr/lib32"); SEARCH_DIR("=/tmp/1285d9c885c98a78fb8e48ce0e3cec51/i386-linux-android/lib"); SEARCH_DIR("=/usr/local/lib"); SEARCH_DIR("=/lib"); SEARCH_DIR("=/usr/lib");
     11 SECTIONS
     12 {
     13   /* Read-only sections, merged into text segment: */
     14   PROVIDE (__executable_start = SEGMENT_START("text-segment", 0)); . = SEGMENT_START("text-segment", 0) + SIZEOF_HEADERS;
     15   .interp         : { *(.interp) }
     16   .note.gnu.build-id : { *(.note.gnu.build-id) }
     17   .hash           : { *(.hash) }
     18   .gnu.hash       : { *(.gnu.hash) }
     19   .dynsym         : { *(.dynsym) }
     20   .dynstr         : { *(.dynstr) }
     21   .gnu.version    : { *(.gnu.version) }
     22   .gnu.version_d  : { *(.gnu.version_d) }
     23   .gnu.version_r  : { *(.gnu.version_r) }
     24   .rel.dyn        :
     25     {
     26       *(.rel.init)
     27       *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*)
     28       *(.rel.fini)
     29       *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*)
     30       *(.rel.data.rel.ro .rel.data.rel.ro.* .rel.gnu.linkonce.d.rel.ro.*)
     31       *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*)
     32       *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*)
     33       *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*)
     34       *(.rel.ctors)
     35       *(.rel.dtors)
     36       *(.rel.got)
     37       *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*)
     38       *(.rel.ifunc)
     39     }
     40   .rel.plt        :
     41     {
     42       *(.rel.plt)
     43       PROVIDE_HIDDEN (__rel_iplt_start = .);
     44       *(.rel.iplt)
     45       PROVIDE_HIDDEN (__rel_iplt_end = .);
     46     }
     47   .init           :
     48   {
     49     KEEP (*(SORT_NONE(.init)))
     50   }
     51   .plt            : { *(.plt) *(.iplt) }
     52 .plt.got        : { *(.plt.got) }
     53   .text           :
     54   {
     55     *(.text.unlikely .text.*_unlikely .text.unlikely.*)
     56     *(.text.exit .text.exit.*)
     57     *(.text.startup .text.startup.*)
     58     *(.text.hot .text.hot.*)
     59     *(.text .stub .text.* .gnu.linkonce.t.*)
     60     /* .gnu.warning sections are handled specially by elf32.em.  */
     61     *(.gnu.warning)
     62   }
     63   .fini           :
     64   {
     65     KEEP (*(SORT_NONE(.fini)))
     66   }
     67   PROVIDE (__etext = .);
     68   PROVIDE (_etext = .);
     69   PROVIDE (etext = .);
     70   .rodata         : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
     71   .rodata1        : { *(.rodata1) }
     72   .eh_frame_hdr : { *(.eh_frame_hdr) *(.eh_frame_entry .eh_frame_entry.*) }
     73   .eh_frame       : ONLY_IF_RO { KEEP (*(.eh_frame)) *(.eh_frame.*) }
     74   .gcc_except_table   : ONLY_IF_RO { *(.gcc_except_table
     75   .gcc_except_table.*) }
     76   .gnu_extab   : ONLY_IF_RO { *(.gnu_extab*) }
     77   /* These sections are generated by the Sun/Oracle C++ compiler.  */
     78   .exception_ranges   : ONLY_IF_RO { *(.exception_ranges
     79   .exception_ranges*) }
     80   /* Adjust the address for the data segment.  We want to adjust up to
     81      the same address within the page on the next page up.  */
     82   . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE));
     83   /* Exception handling  */
     84   .eh_frame       : ONLY_IF_RW { KEEP (*(.eh_frame)) *(.eh_frame.*) }
     85   .gnu_extab      : ONLY_IF_RW { *(.gnu_extab) }
     86   .gcc_except_table   : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) }
     87   .exception_ranges   : ONLY_IF_RW { *(.exception_ranges .exception_ranges*) }
     88   /* Thread Local Storage sections  */
     89   .tdata	  : { *(.tdata .tdata.* .gnu.linkonce.td.*) }
     90   .tbss		  : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
     91   .preinit_array     :
     92   {
     93     PROVIDE_HIDDEN (__preinit_array_start = .);
     94     KEEP (*(.preinit_array))
     95     PROVIDE_HIDDEN (__preinit_array_end = .);
     96   }
     97   .init_array     :
     98   {
     99     PROVIDE_HIDDEN (__init_array_start = .);
    100     KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
    101     KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors))
    102     PROVIDE_HIDDEN (__init_array_end = .);
    103   }
    104   .fini_array     :
    105   {
    106     PROVIDE_HIDDEN (__fini_array_start = .);
    107     KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))
    108     KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors))
    109     PROVIDE_HIDDEN (__fini_array_end = .);
    110   }
    111   .ctors          :
    112   {
    113     /* gcc uses crtbegin.o to find the start of
    114        the constructors, so we make sure it is
    115        first.  Because this is a wildcard, it
    116        doesn't matter if the user does not
    117        actually link against crtbegin.o; the
    118        linker won't look for a file to match a
    119        wildcard.  The wildcard also means that it
    120        doesn't matter which directory crtbegin.o
    121        is in.  */
    122     KEEP (*crtbegin.o(.ctors))
    123     KEEP (*crtbegin?.o(.ctors))
    124     /* We don't want to include the .ctor section from
    125        the crtend.o file until after the sorted ctors.
    126        The .ctor section from the crtend file contains the
    127        end of ctors marker and it must be last */
    128     KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))
    129     KEEP (*(SORT(.ctors.*)))
    130     KEEP (*(.ctors))
    131   }
    132   .dtors          :
    133   {
    134     KEEP (*crtbegin.o(.dtors))
    135     KEEP (*crtbegin?.o(.dtors))
    136     KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
    137     KEEP (*(SORT(.dtors.*)))
    138     KEEP (*(.dtors))
    139   }
    140   .jcr            : { KEEP (*(.jcr)) }
    141   .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) }
    142   .dynamic        : { *(.dynamic) }
    143   .got            : { *(.got) *(.igot) }
    144   . = DATA_SEGMENT_RELRO_END (SIZEOF (.got.plt) >= 12 ? 12 : 0, .);
    145   .got.plt        : { *(.got.plt)  *(.igot.plt) }
    146   .data           :
    147   {
    148     *(.data .data.* .gnu.linkonce.d.*)
    149     SORT(CONSTRUCTORS)
    150   }
    151   .data1          : { *(.data1) }
    152   _edata = .; PROVIDE (edata = .);
    153   __bss_start = .;
    154   .bss            :
    155   {
    156    *(.dynbss)
    157    *(.bss .bss.* .gnu.linkonce.b.*)
    158    *(COMMON)
    159    /* Align here to ensure that the .bss section occupies space up to
    160       _end.  Align after .bss to ensure correct alignment even if the
    161       .bss section disappears because there are no input sections.
    162       FIXME: Why do we need it? When there is no .bss section, we don't
    163       pad the .data section.  */
    164    . = ALIGN(. != 0 ? 32 / 8 : 1);
    165   }
    166   . = ALIGN(32 / 8);
    167   . = SEGMENT_START("ldata-segment", .);
    168   . = ALIGN(32 / 8);
    169   _end = .; PROVIDE (end = .);
    170   . = DATA_SEGMENT_END (.);
    171   /* Stabs debugging sections.  */
    172   .stab          0 : { *(.stab) }
    173   .stabstr       0 : { *(.stabstr) }
    174   .stab.excl     0 : { *(.stab.excl) }
    175   .stab.exclstr  0 : { *(.stab.exclstr) }
    176   .stab.index    0 : { *(.stab.index) }
    177   .stab.indexstr 0 : { *(.stab.indexstr) }
    178   .comment       0 : { *(.comment) }
    179   /* DWARF debug sections.
    180      Symbols in the DWARF debugging sections are relative to the beginning
    181      of the section so we begin them at 0.  */
    182   /* DWARF 1 */
    183   .debug          0 : { *(.debug) }
    184   .line           0 : { *(.line) }
    185   /* GNU DWARF 1 extensions */
    186   .debug_srcinfo  0 : { *(.debug_srcinfo) }
    187   .debug_sfnames  0 : { *(.debug_sfnames) }
    188   /* DWARF 1.1 and DWARF 2 */
    189   .debug_aranges  0 : { *(.debug_aranges) }
    190   .debug_pubnames 0 : { *(.debug_pubnames) }
    191   /* DWARF 2 */
    192   .debug_info     0 : { *(.debug_info .gnu.linkonce.wi.*) }
    193   .debug_abbrev   0 : { *(.debug_abbrev) }
    194   .debug_line     0 : { *(.debug_line .debug_line.* .debug_line_end ) }
    195   .debug_frame    0 : { *(.debug_frame) }
    196   .debug_str      0 : { *(.debug_str) }
    197   .debug_loc      0 : { *(.debug_loc) }
    198   .debug_macinfo  0 : { *(.debug_macinfo) }
    199   /* SGI/MIPS DWARF 2 extensions */
    200   .debug_weaknames 0 : { *(.debug_weaknames) }
    201   .debug_funcnames 0 : { *(.debug_funcnames) }
    202   .debug_typenames 0 : { *(.debug_typenames) }
    203   .debug_varnames  0 : { *(.debug_varnames) }
    204   /* DWARF 3 */
    205   .debug_pubtypes 0 : { *(.debug_pubtypes) }
    206   .debug_ranges   0 : { *(.debug_ranges) }
    207   /* DWARF Extension.  */
    208   .debug_macro    0 : { *(.debug_macro) }
    209   .debug_addr     0 : { *(.debug_addr) }
    210   .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }
    211   /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }
    212 }
    213