Home | History | Annotate | Download | only in ldscripts
      1 /* Script for -N: mix text and data on same page; don't align data */
      2 /* Copyright (C) 2014 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-bigarm", "elf32-bigarm",
      7 	      "elf32-littlearm")
      8 OUTPUT_ARCH(arm)
      9 ENTRY(_start)
     10 SECTIONS
     11 {
     12   /* Read-only sections, merged into text segment: */
     13   PROVIDE (__executable_start = 0x8000); . = 0x8000;
     14   .interp         : { *(.interp) }
     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   .rel.init       : { *(.rel.init) }
     24   .rela.init      : { *(.rela.init) }
     25   .rel.text       : { *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) }
     26   .rela.text      : { *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) }
     27   .rel.fini       : { *(.rel.fini) }
     28   .rela.fini      : { *(.rela.fini) }
     29   .rel.rodata     : { *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) }
     30   .rela.rodata    : { *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) }
     31   .rel.data.rel.ro   : { *(.rel.data.rel.ro .rel.data.rel.ro.* .rel.gnu.linkonce.d.rel.ro.*) }
     32   .rela.data.rel.ro   : { *(.rela.data.rel.ro .rela.data.rel.ro.* .rela.gnu.linkonce.d.rel.ro.*) }
     33   .rel.data       : { *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) }
     34   .rela.data      : { *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) }
     35   .rel.tdata	  : { *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) }
     36   .rela.tdata	  : { *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) }
     37   .rel.tbss	  : { *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) }
     38   .rela.tbss	  : { *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) }
     39   .rel.ctors      : { *(.rel.ctors) }
     40   .rela.ctors     : { *(.rela.ctors) }
     41   .rel.dtors      : { *(.rel.dtors) }
     42   .rela.dtors     : { *(.rela.dtors) }
     43   .rel.got        : { *(.rel.got) }
     44   .rela.got       : { *(.rela.got) }
     45   .rel.bss        : { *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) }
     46   .rela.bss       : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) }
     47   .rel.iplt       :
     48     {
     49       PROVIDE_HIDDEN (__rel_iplt_start = .);
     50       *(.rel.iplt)
     51       PROVIDE_HIDDEN (__rel_iplt_end = .);
     52     }
     53   .rela.iplt      :
     54     {
     55       PROVIDE_HIDDEN (__rela_iplt_start = .);
     56       *(.rela.iplt)
     57       PROVIDE_HIDDEN (__rela_iplt_end = .);
     58     }
     59   .rel.plt        :
     60     {
     61       *(.rel.plt)
     62     }
     63   .rela.plt       :
     64     {
     65       *(.rela.plt)
     66     }
     67   .init           :
     68   {
     69     KEEP (*(SORT_NONE(.init)))
     70   }
     71   .plt            : { *(.plt) }
     72   .iplt           : { *(.iplt) }
     73   .text           :
     74   {
     75     *(.text.unlikely .text.*_unlikely .text.unlikely.*)
     76     *(.text.exit .text.exit.*)
     77     *(.text.startup .text.startup.*)
     78     *(.text.hot .text.hot.*)
     79     *(.text .stub .text.* .gnu.linkonce.t.*)
     80     /* .gnu.warning sections are handled specially by elf32.em.  */
     81     *(.gnu.warning)
     82     *(.glue_7t) *(.glue_7) *(.vfp11_veneer) *(.v4_bx)
     83   }
     84   .fini           :
     85   {
     86     KEEP (*(SORT_NONE(.fini)))
     87   }
     88   PROVIDE (__etext = .);
     89   PROVIDE (_etext = .);
     90   PROVIDE (etext = .);
     91   .rodata         : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
     92   .rodata1        : { *(.rodata1) }
     93   .ARM.extab   : { *(.ARM.extab* .gnu.linkonce.armextab.*) }
     94    PROVIDE_HIDDEN (__exidx_start = .);
     95   .ARM.exidx   : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) }
     96    PROVIDE_HIDDEN (__exidx_end = .);
     97   .eh_frame_hdr : { *(.eh_frame_hdr) }
     98   .eh_frame       : ONLY_IF_RO { KEEP (*(.eh_frame)) }
     99   .gcc_except_table   : ONLY_IF_RO { *(.gcc_except_table
    100   .gcc_except_table.*) }
    101   /* These sections are generated by the Sun/Oracle C++ compiler.  */
    102   .exception_ranges   : ONLY_IF_RO { *(.exception_ranges
    103   .exception_ranges*) }
    104   /* Adjust the address for the data segment.  For 32 bits we want to align
    105   at exactly a page boundary to make life easier for apriori. */
    106   . = .;
    107   /* Exception handling  */
    108   .eh_frame       : ONLY_IF_RW { KEEP (*(.eh_frame)) }
    109   .gcc_except_table   : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) }
    110   .exception_ranges   : ONLY_IF_RW { *(.exception_ranges .exception_ranges*) }
    111   /* Thread Local Storage sections  */
    112   .tdata	  : { *(.tdata .tdata.* .gnu.linkonce.td.*) }
    113   .tbss		  : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
    114   /* Ensure the __preinit_array_start label is properly aligned.  We
    115      could instead move the label definition inside the section, but
    116      the linker would then create the section even if it turns out to
    117      be empty, which isn't pretty.  */
    118   . = ALIGN(32 / 8);
    119   PROVIDE_HIDDEN (__preinit_array_start = .);
    120   .preinit_array     :
    121   {
    122     KEEP (*(.preinit_array))
    123   }
    124   PROVIDE_HIDDEN (__preinit_array_end = .);
    125   PROVIDE_HIDDEN (__init_array_start = .);
    126   .init_array     :
    127   {
    128     KEEP (*crtbegin*.o(.init_array))
    129     KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
    130     KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin*.o *crtend.o *crtend*.o ) .ctors))
    131   }
    132   PROVIDE_HIDDEN (__init_array_end = .);
    133   PROVIDE_HIDDEN (__fini_array_start = .);
    134   .fini_array     :
    135   {
    136     KEEP (*crtbegin*.o(.fini_array))
    137     KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))
    138     KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin*.o *crtend.o *crtend*.o ) .dtors))
    139   }
    140   PROVIDE_HIDDEN (__fini_array_end = .);
    141   .ctors          :
    142   {
    143     /* gcc uses crtbegin.o to find the start of
    144        the constructors, so we make sure it is
    145        first.  Because this is a wildcard, it
    146        doesn't matter if the user does not
    147        actually link against crtbegin.o; the
    148        linker won't look for a file to match a
    149        wildcard.  The wildcard also means that it
    150        doesn't matter which directory crtbegin.o
    151        is in.  */
    152     KEEP (*crtbegin.o(.ctors))
    153     KEEP (*crtbegin*.o(.ctors))
    154     /* We don't want to include the .ctor section from
    155        the crtend.o file until after the sorted ctors.
    156        The .ctor section from the crtend file contains the
    157        end of ctors marker and it must be last */
    158     KEEP (*(EXCLUDE_FILE (*crtend.o *crtend*.o ) .ctors))
    159     KEEP (*(SORT(.ctors.*)))
    160     KEEP (*(.ctors))
    161   }
    162   .dtors          :
    163   {
    164     KEEP (*crtbegin.o(.dtors))
    165     KEEP (*crtbegin*.o(.dtors))
    166     KEEP (*(EXCLUDE_FILE (*crtend.o *crtend*.o ) .dtors))
    167     KEEP (*(SORT(.dtors.*)))
    168     KEEP (*(.dtors))
    169   }
    170   .jcr            : { KEEP (*(.jcr)) }
    171   .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) }
    172   .dynamic        : { *(.dynamic) }
    173   .got            : { *(.got.plt) *(.igot.plt) *(.got) *(.igot) }
    174   .data           :
    175   {
    176     __data_start = . ;
    177     *(.data .data.* .gnu.linkonce.d.*)
    178     SORT(CONSTRUCTORS)
    179   }
    180   .data1          : { *(.data1) }
    181   _edata = .; PROVIDE (edata = .);
    182   __bss_start = .;
    183   __bss_start__ = .;
    184   .bss            :
    185   {
    186    *(.dynbss)
    187    *(.bss .bss.* .gnu.linkonce.b.*)
    188    *(COMMON)
    189    /* Align here to ensure that the .bss section occupies space up to
    190       _end.  Align after .bss to ensure correct alignment even if the
    191       .bss section disappears because there are no input sections.  */
    192    . = ALIGN(32 / 8);
    193   }
    194   _bss_end__ = . ; __bss_end__ = . ;
    195   . = ALIGN(32 / 8);
    196   . = SEGMENT_START("ldata-segment", .);
    197   . = ALIGN(32 / 8);
    198   __end__ = . ;
    199   _end = .;
    200   _bss_end__ = . ; __bss_end__ = . ; __end__ = . ;
    201   PROVIDE (end = .);
    202   /* Stabs debugging sections.  */
    203   .stab          0 : { *(.stab) }
    204   .stabstr       0 : { *(.stabstr) }
    205   .stab.excl     0 : { *(.stab.excl) }
    206   .stab.exclstr  0 : { *(.stab.exclstr) }
    207   .stab.index    0 : { *(.stab.index) }
    208   .stab.indexstr 0 : { *(.stab.indexstr) }
    209   .comment       0 : { *(.comment) }
    210   /* DWARF debug sections.
    211      Symbols in the DWARF debugging sections are relative to the beginning
    212      of the section so we begin them at 0.  */
    213   /* DWARF 1 */
    214   .debug          0 : { *(.debug) }
    215   .line           0 : { *(.line) }
    216   /* GNU DWARF 1 extensions */
    217   .debug_srcinfo  0 : { *(.debug_srcinfo) }
    218   .debug_sfnames  0 : { *(.debug_sfnames) }
    219   /* DWARF 1.1 and DWARF 2 */
    220   .debug_aranges  0 : { *(.debug_aranges) }
    221   .debug_pubnames 0 : { *(.debug_pubnames) }
    222   /* DWARF 2 */
    223   .debug_info     0 : { *(.debug_info .gnu.linkonce.wi.*) }
    224   .debug_abbrev   0 : { *(.debug_abbrev) }
    225   .debug_line     0 : { *(.debug_line .debug_line.* .debug_line_end ) }
    226   .debug_frame    0 : { *(.debug_frame) }
    227   .debug_str      0 : { *(.debug_str) }
    228   .debug_loc      0 : { *(.debug_loc) }
    229   .debug_macinfo  0 : { *(.debug_macinfo) }
    230   /* SGI/MIPS DWARF 2 extensions */
    231   .debug_weaknames 0 : { *(.debug_weaknames) }
    232   .debug_funcnames 0 : { *(.debug_funcnames) }
    233   .debug_typenames 0 : { *(.debug_typenames) }
    234   .debug_varnames  0 : { *(.debug_varnames) }
    235   /* DWARF 3 */
    236   .debug_pubtypes 0 : { *(.debug_pubtypes) }
    237   .debug_ranges   0 : { *(.debug_ranges) }
    238   /* DWARF Extension.  */
    239   .debug_macro    0 : { *(.debug_macro) }
    240     .stack         0x80000 :
    241   {
    242     _stack = .;
    243     *(.stack)
    244   }
    245   .ARM.attributes 0 : { KEEP (*(.ARM.attributes)) KEEP (*(.gnu.attributes)) }
    246   .note.gnu.arm.ident 0 : { KEEP (*(.note.gnu.arm.ident)) }
    247   /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) *(.mdebug.*) }
    248 }
    249