1 /* Script for --shared -z combreloc -z now -z relro: shared library, combine & sort relocs */ 2 OUTPUT_FORMAT("elf32-i386", "elf32-i386", 3 "elf32-i386") 4 OUTPUT_ARCH(i386) 5 ENTRY(_start) 6 SEARCH_DIR("=/usr/local/lib"); SEARCH_DIR("=/lib"); SEARCH_DIR("=/usr/lib"); 7 SECTIONS 8 { 9 /* Read-only sections, merged into text segment: */ 10 . = SEGMENT_START("text-segment", 0) + SIZEOF_HEADERS; 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 *(.rel.iplt) 39 } 40 .init : 41 { 42 KEEP (*(.init)) 43 } =0x90909090 44 .plt : { *(.plt) *(.iplt) } 45 .text : 46 { 47 *(.text.unlikely .text.*_unlikely) 48 *(.text .stub .text.* .gnu.linkonce.t.*) 49 /* .gnu.warning sections are handled specially by elf32.em. */ 50 *(.gnu.warning) 51 } =0x90909090 52 .fini : 53 { 54 KEEP (*(.fini)) 55 } =0x90909090 56 PROVIDE (__etext = .); 57 PROVIDE (_etext = .); 58 PROVIDE (etext = .); 59 .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) } 60 .rodata1 : { *(.rodata1) } 61 .eh_frame_hdr : { *(.eh_frame_hdr) } 62 .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) } 63 .gcc_except_table : ONLY_IF_RO { *(.gcc_except_table .gcc_except_table.*) } 64 /* Adjust the address for the data segment. We want to adjust up to 65 the same address within the page on the next page up. */ 66 . = ALIGN (CONSTANT (MAXPAGESIZE)) - ((CONSTANT (MAXPAGESIZE) - .) & (CONSTANT (MAXPAGESIZE) - 1)); . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE)); 67 /* Exception handling */ 68 .eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) } 69 .gcc_except_table : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) } 70 /* Thread Local Storage sections */ 71 .tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) } 72 .tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) } 73 .preinit_array : 74 { 75 KEEP (*(.preinit_array)) 76 } 77 .init_array : 78 { 79 KEEP (*(SORT(.init_array.*))) 80 KEEP (*(.init_array)) 81 } 82 .fini_array : 83 { 84 KEEP (*(.fini_array)) 85 KEEP (*(SORT(.fini_array.*))) 86 } 87 .ctors : 88 { 89 /* gcc uses crtbegin.o to find the start of 90 the constructors, so we make sure it is 91 first. Because this is a wildcard, it 92 doesn't matter if the user does not 93 actually link against crtbegin.o; the 94 linker won't look for a file to match a 95 wildcard. The wildcard also means that it 96 doesn't matter which directory crtbegin.o 97 is in. */ 98 KEEP (*crtbegin.o(.ctors)) 99 KEEP (*crtbegin?.o(.ctors)) 100 /* We don't want to include the .ctor section from 101 the crtend.o file until after the sorted ctors. 102 The .ctor section from the crtend file contains the 103 end of ctors marker and it must be last */ 104 KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors)) 105 KEEP (*(SORT(.ctors.*))) 106 KEEP (*(.ctors)) 107 } 108 .dtors : 109 { 110 KEEP (*crtbegin.o(.dtors)) 111 KEEP (*crtbegin?.o(.dtors)) 112 KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors)) 113 KEEP (*(SORT(.dtors.*))) 114 KEEP (*(.dtors)) 115 } 116 .jcr : { KEEP (*(.jcr)) } 117 .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*) } 118 .dynamic : { *(.dynamic) } 119 .got : { *(.got.plt) *(.igot.plt) *(.got) *(.igot) } 120 . = DATA_SEGMENT_RELRO_END (0, .); 121 .data : 122 { 123 *(.data .data.* .gnu.linkonce.d.*) 124 SORT(CONSTRUCTORS) 125 } 126 .data1 : { *(.data1) } 127 _edata = .; PROVIDE (edata = .); 128 __bss_start = .; 129 .bss : 130 { 131 *(.dynbss) 132 *(.bss .bss.* .gnu.linkonce.b.*) 133 *(COMMON) 134 /* Align here to ensure that the .bss section occupies space up to 135 _end. Align after .bss to ensure correct alignment even if the 136 .bss section disappears because there are no input sections. 137 FIXME: Why do we need it? When there is no .bss section, we don't 138 pad the .data section. */ 139 . = ALIGN(. != 0 ? 32 / 8 : 1); 140 } 141 . = ALIGN(32 / 8); 142 . = ALIGN(32 / 8); 143 _end = .; PROVIDE (end = .); 144 . = DATA_SEGMENT_END (.); 145 /* Stabs debugging sections. */ 146 .stab 0 : { *(.stab) } 147 .stabstr 0 : { *(.stabstr) } 148 .stab.excl 0 : { *(.stab.excl) } 149 .stab.exclstr 0 : { *(.stab.exclstr) } 150 .stab.index 0 : { *(.stab.index) } 151 .stab.indexstr 0 : { *(.stab.indexstr) } 152 .comment 0 : { *(.comment) } 153 /* DWARF debug sections. 154 Symbols in the DWARF debugging sections are relative to the beginning 155 of the section so we begin them at 0. */ 156 /* DWARF 1 */ 157 .debug 0 : { *(.debug) } 158 .line 0 : { *(.line) } 159 /* GNU DWARF 1 extensions */ 160 .debug_srcinfo 0 : { *(.debug_srcinfo) } 161 .debug_sfnames 0 : { *(.debug_sfnames) } 162 /* DWARF 1.1 and DWARF 2 */ 163 .debug_aranges 0 : { *(.debug_aranges) } 164 .debug_pubnames 0 : { *(.debug_pubnames) } 165 /* DWARF 2 */ 166 .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } 167 .debug_abbrev 0 : { *(.debug_abbrev) } 168 .debug_line 0 : { *(.debug_line) } 169 .debug_frame 0 : { *(.debug_frame) } 170 .debug_str 0 : { *(.debug_str) } 171 .debug_loc 0 : { *(.debug_loc) } 172 .debug_macinfo 0 : { *(.debug_macinfo) } 173 /* SGI/MIPS DWARF 2 extensions */ 174 .debug_weaknames 0 : { *(.debug_weaknames) } 175 .debug_funcnames 0 : { *(.debug_funcnames) } 176 .debug_typenames 0 : { *(.debug_typenames) } 177 .debug_varnames 0 : { *(.debug_varnames) } 178 /* DWARF 3 */ 179 .debug_pubtypes 0 : { *(.debug_pubtypes) } 180 .debug_ranges 0 : { *(.debug_ranges) } 181 .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) } 182 /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) } 183 } 184