Commit | Line | Data |
---|---|---|
219d1afa | 1 | # Copyright (C) 2014-2018 Free Software Foundation, Inc. |
6c19b93b | 2 | # |
985743c7 NC |
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. | |
252b5132 RH |
6 | # |
7 | # Unusual variables checked by this code: | |
563e308f | 8 | # NOP - four byte opcode for no-op (defaults to 0) |
252b5132 RH |
9 | # DATA_ADDR - if end-of-text-plus-one-page isn't right for data start |
10 | # OTHER_READONLY_SECTIONS - other than .text .init .ctors .rodata ... | |
11 | # (e.g., .PARISC.milli) | |
12 | # OTHER_READWRITE_SECTIONS - other than .data .bss .sdata ... | |
13 | # (e.g., .PARISC.global) | |
14 | # OTHER_SECTIONS - at the end | |
15 | # EXECUTABLE_SYMBOLS - symbols that must be defined for an | |
16 | # executable (e.g., _DYNAMIC_LINK) | |
17 | # TEXT_START_SYMBOLS - symbols that appear at the start of the | |
18 | # .text section. | |
19 | # DATA_START_SYMBOLS - symbols that appear at the start of the | |
20 | # .data section. | |
21 | # OTHER_BSS_SYMBOLS - symbols that appear at the start of the | |
22 | # .bss section besides __bss_start. | |
23 | # DATA_PLT - .plt should be in data segment, not text segment. | |
24 | # | |
25 | # When adding sections, do note that the names of some sections are used | |
26 | # when specifying the start address of the next. | |
27 | # | |
985743c7 | 28 | |
252b5132 RH |
29 | test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT} |
30 | test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT} | |
31 | test "$LD_FLAG" = "N" && DATA_ADDR=. | |
6c19b93b AM |
32 | INTERP=".interp ${RELOCATING-0} : { *(.interp) }" |
33 | PLT=".plt ${RELOCATING-0} : { *(.plt) }" | |
985743c7 | 34 | |
252b5132 | 35 | cat <<EOF |
219d1afa | 36 | /* Copyright (C) 2014-2018 Free Software Foundation, Inc. |
985743c7 NC |
37 | |
38 | Copying and distribution of this script, with or without modification, | |
39 | are permitted in any medium without royalty provided the copyright | |
40 | notice and this notice are preserved. */ | |
41 | ||
252b5132 RH |
42 | OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}", |
43 | "${LITTLE_OUTPUT_FORMAT}") | |
44 | OUTPUT_ARCH(${ARCH}) | |
45 | ||
46 | ${RELOCATING+${LIB_SEARCH_DIRS}} | |
47 | ${RELOCATING+/* Do we need any of these for elf? | |
48 | __DYNAMIC = 0; ${STACKZERO+${STACKZERO}} ${SHLIB_PATH+${SHLIB_PATH}} */} | |
49 | ${RELOCATING+${EXECUTABLE_SYMBOLS}} | |
ec2d9b29 AM |
50 | ${RELOCATING- /* For some reason, the Solaris linker makes bad executables |
51 | if gld -r is used and the intermediate file has sections starting | |
52 | at non-zero addresses. Could be a Solaris ld bug, could be a GNU ld | |
53 | bug. But for now assigning the zero vmas works. */} | |
252b5132 RH |
54 | SECTIONS |
55 | { | |
56 | /* Read-only sections, merged into text segment: */ | |
57 | ${CREATE_SHLIB-${RELOCATING+. = ${TEXT_START_ADDR} + SIZEOF_HEADERS;}} | |
58 | ${CREATE_SHLIB+${RELOCATING+. = SIZEOF_HEADERS;}} | |
59 | ${CREATE_SHLIB-${INTERP}} | |
ec2d9b29 AM |
60 | .hash ${RELOCATING-0} : { *(.hash) } |
61 | .dynsym ${RELOCATING-0} : { *(.dynsym) } | |
62 | .dynstr ${RELOCATING-0} : { *(.dynstr) } | |
63 | .rel.text ${RELOCATING-0} : { *(.rel.text) } | |
6c19b93b | 64 | .rela.text ${RELOCATING-0} : { *(.rela.text) } |
ec2d9b29 | 65 | .rel.data ${RELOCATING-0} : { *(.rel.data) } |
6c19b93b AM |
66 | .rela.data ${RELOCATING-0} : { *(.rela.data) } |
67 | .rel.rodata ${RELOCATING-0} : { *(.rel.rodata) } | |
68 | .rela.rodata ${RELOCATING-0} : { *(.rela.rodata) } | |
ec2d9b29 AM |
69 | .rel.got ${RELOCATING-0} : { *(.rel.got) } |
70 | .rela.got ${RELOCATING-0} : { *(.rela.got) } | |
71 | .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) } | |
72 | .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) } | |
73 | .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) } | |
74 | .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) } | |
75 | .rel.bss ${RELOCATING-0} : { *(.rel.bss) } | |
76 | .rela.bss ${RELOCATING-0} : { *(.rela.bss) } | |
77 | .rel.plt ${RELOCATING-0} : { *(.rel.plt) } | |
78 | .rela.plt ${RELOCATING-0} : { *(.rela.plt) } | |
79 | .init ${RELOCATING-0} : { *(.init) } =${NOP-0} | |
252b5132 | 80 | ${DATA_PLT-${PLT}} |
ec2d9b29 | 81 | .text ${RELOCATING-0} : |
252b5132 RH |
82 | { |
83 | ${RELOCATING+${TEXT_START_SYMBOLS}} | |
84 | *(.text) | |
85 | ${CONSTRUCTING+ __CTOR_LIST__ = .;} | |
86 | ${CONSTRUCTING+ LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2)} | |
87 | ${CONSTRUCTING+ *(.ctors)} | |
88 | ${CONSTRUCTING+ LONG(0)} | |
89 | ${CONSTRUCTING+ __CTOR_END__ = .;} | |
90 | ${CONSTRUCTING+ __DTOR_LIST__ = .;} | |
91 | ${CONSTRUCTING+ LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2)} | |
92 | ${CONSTRUCTING+ *(.dtors)} | |
93 | ${CONSTRUCTING+ LONG(0)} | |
94 | ${CONSTRUCTING+ __DTOR_END__ = .;} | |
95 | } | |
96 | ${RELOCATING+_etext = .;} | |
97 | ${RELOCATING+PROVIDE (etext = .);} | |
ec2d9b29 AM |
98 | .fini ${RELOCATING-0} : { *(.fini) } =${NOP-0} |
99 | .ctors ${RELOCATING-0} : { *(.ctors) } | |
100 | .dtors ${RELOCATING-0} : { *(.dtors) } | |
101 | .rodata ${RELOCATING-0} : { *(.rodata) } | |
102 | .rodata1 ${RELOCATING-0} : { *(.rodata1) } | |
465bc359 | 103 | ${OTHER_READONLY_SECTIONS} |
252b5132 RH |
104 | |
105 | /* Read-write section, merged into data segment: */ | |
106 | ${RELOCATING+. = ${DATA_ADDR- ALIGN(8) + ${MAXPAGESIZE}};} | |
ec2d9b29 | 107 | .data ${RELOCATING-0} : |
252b5132 RH |
108 | { |
109 | ${RELOCATING+${DATA_START_SYMBOLS}} | |
110 | *(.data) | |
111 | ${CONSTRUCTING+CONSTRUCTORS} | |
112 | } | |
ec2d9b29 | 113 | .data1 ${RELOCATING-0} : { *(.data1) } |
465bc359 | 114 | ${OTHER_READWRITE_SECTIONS} |
ec2d9b29 AM |
115 | .got ${RELOCATING-0} : { *(.got.plt) *(.got) } |
116 | .dynamic ${RELOCATING-0} : { *(.dynamic) } | |
252b5132 RH |
117 | ${DATA_PLT+${PLT}} |
118 | /* We want the small data sections together, so single-instruction offsets | |
119 | can access them all, and initialized data all before uninitialized, so | |
120 | we can shorten the on-disk segment size. */ | |
ec2d9b29 | 121 | .sdata ${RELOCATING-0} : { *(.sdata) } |
252b5132 RH |
122 | ${RELOCATING+_edata = .;} |
123 | ${RELOCATING+PROVIDE (edata = .);} | |
124 | ${RELOCATING+__bss_start = .;} | |
125 | ${RELOCATING+${OTHER_BSS_SYMBOLS}} | |
ec2d9b29 AM |
126 | .sbss ${RELOCATING-0} : { *(.sbss) *(.scommon) } |
127 | .bss ${RELOCATING-0} : | |
252b5132 RH |
128 | { |
129 | *(.dynbss) | |
130 | *(.bss) | |
131 | *(COMMON) | |
132 | } | |
133 | ${RELOCATING+_end = . ;} | |
134 | ${RELOCATING+PROVIDE (end = .);} | |
135 | ||
136 | /* These are needed for ELF backends which have not yet been | |
137 | converted to the new style linker. */ | |
138 | .stab 0 : { *(.stab) } | |
139 | .stabstr 0 : { *(.stabstr) } | |
140 | ||
252b5132 RH |
141 | ${OTHER_SECTIONS} |
142 | } | |
143 | EOF |