1 # Copyright (C) 2014 Free Software Foundation, Inc. 2 # 3 # Copying and distribution of this file, with or without modification, 4 # are permitted in any medium without royalty provided the copyright 5 # notice and this notice are preserved. 6 # 7 # This is just a raw copy of elfppc.sc and has not been otherwise modified 8 # 9 # Unusual variables checked by this code: 10 # NOP - four byte opcode for no-op (defaults to 0) 11 # DATA_ADDR - if end-of-text-plus-one-page isn't right for data start 12 # OTHER_READONLY_SECTIONS - other than .text .init .rodata ... 13 # (e.g., .PARISC.milli) 14 # OTHER_READWRITE_SECTIONS - other than .data .bss .ctors .sdata ... 15 # (e.g., .PARISC.global) 16 # ATTRS_SECTIONS - at the end 17 # OTHER_SECTIONS - at the end 18 # EXECUTABLE_SYMBOLS - symbols that must be defined for an 19 # executable (e.g., _DYNAMIC_LINK) 20 # TEXT_START_SYMBOLS - symbols that appear at the start of the 21 # .text section. 22 # DATA_START_SYMBOLS - symbols that appear at the start of the 23 # .data section. 24 # OTHER_BSS_SYMBOLS - symbols that appear at the start of the 25 # .bss section besides __bss_start. 26 # 27 # When adding sections, do note that the names of some sections are used 28 # when specifying the start address of the next. 29 30 test -z "$ENTRY" && ENTRY=_start 31 test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT} 32 test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT} 33 test -z "$ATTRS_SECTIONS" && ATTRS_SECTIONS=".gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }" 34 test "$LD_FLAG" = "N" && DATA_ADDR=. 35 SBSS2=".sbss2 ${RELOCATING-0} : { *(.sbss2) }" 36 SDATA2=".sdata2 ${RELOCATING-0} : { *(.sdata2) }" 37 INTERP=".interp ${RELOCATING-0} : { *(.interp) }" 38 PLT=".plt ${RELOCATING-0} : { *(.plt) }" 39 40 cat <<EOF 41 /* Copyright (C) 2014 Free Software Foundation, Inc. 42 43 Copying and distribution of this script, with or without modification, 44 are permitted in any medium without royalty provided the copyright 45 notice and this notice are preserved. */ 46 47 OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}", 48 "${LITTLE_OUTPUT_FORMAT}") 49 OUTPUT_ARCH(${ARCH}) 50 ${RELOCATING+ENTRY(${ENTRY})} 51 52 ${RELOCATING+${LIB_SEARCH_DIRS}} 53 ${RELOCATING+/* Do we need any of these for elf? 54 __DYNAMIC = 0; ${STACKZERO+${STACKZERO}} ${SHLIB_PATH+${SHLIB_PATH}} */} 55 ${RELOCATING+${EXECUTABLE_SYMBOLS}} 56 ${RELOCATING- /* For some reason, the Solaris linker makes bad executables 57 if gld -r is used and the intermediate file has sections starting 58 at non-zero addresses. Could be a Solaris ld bug, could be a GNU ld 59 bug. But for now assigning the zero vmas works. */} 60 61 ${RELOCATING+PROVIDE (__stack = 0);} 62 SECTIONS 63 { 64 /* Read-only sections, merged into text segment: */ 65 ${CREATE_SHLIB-${RELOCATING+. = ${TEXT_START_ADDR} + SIZEOF_HEADERS;}} 66 ${CREATE_SHLIB+${RELOCATING+. = SIZEOF_HEADERS;}} 67 ${CREATE_SHLIB-${INTERP}} 68 .hash ${RELOCATING-0} : { *(.hash) } 69 .dynsym ${RELOCATING-0} : { *(.dynsym) } 70 .dynstr ${RELOCATING-0} : { *(.dynstr) } 71 .gnu.version ${RELOCATING-0} : { *(.gnu.version) } 72 .gnu.version_d ${RELOCATING-0} : { *(.gnu.version_d) } 73 .gnu.version_r ${RELOCATING-0} : { *(.gnu.version_r) } 74 .rela.text ${RELOCATING-0} : 75 { *(.rela.text) *(.rela.gnu.linkonce.t*) } 76 .rela.data ${RELOCATING-0} : 77 { *(.rela.data) *(.rela.gnu.linkonce.d*) } 78 .rela.rodata ${RELOCATING-0} : 79 { *(.rela.rodata) *(.rela.gnu.linkonce.r*) } 80 .rela.got ${RELOCATING-0} : { *(.rela.got) } 81 .rela.got1 ${RELOCATING-0} : { *(.rela.got1) } 82 .rela.got2 ${RELOCATING-0} : { *(.rela.got2) } 83 .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) } 84 .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) } 85 .rela.init ${RELOCATING-0} : { *(.rela.init) } 86 .rela.fini ${RELOCATING-0} : { *(.rela.fini) } 87 .rela.bss ${RELOCATING-0} : { *(.rela.bss) } 88 .rela.plt ${RELOCATING-0} : { *(.rela.plt) } 89 .rela.sdata ${RELOCATING-0} : { *(.rela.sdata) } 90 .rela.sbss ${RELOCATING-0} : { *(.rela.sbss) } 91 .rela.sdata2 ${RELOCATING-0} : { *(.rela.sdata2) } 92 .rela.sbss2 ${RELOCATING-0} : { *(.rela.sbss2) } 93 .text ${RELOCATING-0} : 94 { 95 ${RELOCATING+${TEXT_START_SYMBOLS}} 96 *(.text) 97 /* .gnu.warning sections are handled specially by elf32.em. */ 98 *(.gnu.warning) 99 *(.gnu.linkonce.t*) 100 } =${NOP-0} 101 .init ${RELOCATING-0} : { *(.init) } =${NOP-0} 102 .fini ${RELOCATING-0} : { *(.fini) } =${NOP-0} 103 .rodata ${RELOCATING-0} : { *(.rodata) *(.gnu.linkonce.r*) } 104 .rodata1 ${RELOCATING-0} : { *(.rodata1) } 105 ${RELOCATING+_etext = .;} 106 ${RELOCATING+PROVIDE (etext = .);} 107 ${CREATE_SHLIB-${SDATA2}} 108 ${CREATE_SHLIB-${SBSS2}} 109 ${OTHER_READONLY_SECTIONS} 110 111 /* Adjust the address for the data segment. We want to adjust up to 112 the same address within the page on the next page up. It would 113 be more correct to do this: 114 ${RELOCATING+. = ${DATA_ADDR-ALIGN(${MAXPAGESIZE}) + (ALIGN(8) & (${MAXPAGESIZE} - 1))};} 115 The current expression does not correctly handle the case of a 116 text segment ending precisely at the end of a page; it causes the 117 data segment to skip a page. The above expression does not have 118 this problem, but it will currently (2/95) cause BFD to allocate 119 a single segment, combining both text and data, for this case. 120 This will prevent the text segment from being shared among 121 multiple executions of the program; I think that is more 122 important than losing a page of the virtual address space (note 123 that no actual memory is lost; the page which is skipped can not 124 be referenced). */ 125 ${RELOCATING+. = ${DATA_ADDR- ALIGN(8) + ${MAXPAGESIZE}};} 126 127 .data ${RELOCATING-0} : 128 { 129 ${RELOCATING+${DATA_START_SYMBOLS}} 130 *(.data) 131 *(.gnu.linkonce.d*) 132 ${CONSTRUCTING+CONSTRUCTORS} 133 } 134 .data1 ${RELOCATING-0} : { *(.data1) } 135 ${OTHER_READWRITE_SECTIONS} 136 137 .got1 ${RELOCATING-0} : { *(.got1) } 138 .dynamic ${RELOCATING-0} : { *(.dynamic) } 139 140 /* Put .ctors and .dtors next to the .got2 section, so that the pointers 141 get relocated with -mrelocatable. Also put in the .fixup pointers. 142 The current compiler no longer needs this, but keep it around for 2.7.2 */ 143 144 ${RELOCATING+PROVIDE (_GOT2_START_ = .);} 145 .got2 ${RELOCATING-0} : { *(.got2) } 146 147 ${RELOCATING+PROVIDE (__CTOR_LIST__ = .);} 148 .ctors ${RELOCATING-0} : { *(.ctors) } 149 ${RELOCATING+PROVIDE (__CTOR_END__ = .);} 150 151 ${RELOCATING+PROVIDE (__DTOR_LIST__ = .);} 152 .dtors ${RELOCATING-0} : { *(.dtors) } 153 ${RELOCATING+PROVIDE (__DTOR_END__ = .);} 154 155 ${RELOCATING+PROVIDE (_FIXUP_START_ = .);} 156 .fixup ${RELOCATING-0} : { *(.fixup) } 157 ${RELOCATING+PROVIDE (_FIXUP_END_ = .);} 158 ${RELOCATING+PROVIDE (_GOT2_END_ = .);} 159 160 ${RELOCATING+PROVIDE (_GOT_START_ = .);} 161 .got ${RELOCATING-0} : { *(.got) } 162 .got.plt ${RELOCATING-0} : { *(.got.plt) } 163 ${CREATE_SHLIB+${SDATA2}} 164 ${CREATE_SHLIB+${SBSS2}} 165 ${RELOCATING+PROVIDE (_GOT_END_ = .);} 166 167 /* We want the small data sections together, so single-instruction offsets 168 can access them all, and initialized data all before uninitialized, so 169 we can shorten the on-disk segment size. */ 170 .sdata ${RELOCATING-0} : { *(.sdata) } 171 ${RELOCATING+_edata = .;} 172 ${RELOCATING+PROVIDE (edata = .);} 173 .sbss ${RELOCATING-0} : 174 { 175 ${RELOCATING+PROVIDE (__sbss_start = .);} 176 *(.sbss) 177 *(.scommon) 178 *(.dynsbss) 179 ${RELOCATING+PROVIDE (__sbss_end = .);} 180 } 181 ${PLT} 182 .bss ${RELOCATING-0} : 183 { 184 ${RELOCATING+${OTHER_BSS_SYMBOLS}} 185 ${RELOCATING+PROVIDE (__bss_start = .);} 186 *(.dynbss) 187 *(.bss) 188 *(COMMON) 189 } 190 ${RELOCATING+_end = . ;} 191 ${RELOCATING+PROVIDE (end = .);} 192 193 /* These are needed for ELF backends which have not yet been 194 converted to the new style linker. */ 195 .stab 0 : { *(.stab) } 196 .stabstr 0 : { *(.stabstr) } 197 198 EOF 199 200 . $srcdir/scripttempl/DWARF.sc 201 202 cat <<EOF 203 ${ATTRS_SECTIONS} 204 ${OTHER_SECTIONS} 205 } 206 EOF 207