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