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