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