Make __{e,g}p correctly start relative to the beginning of the section; Cleanup
[deliverable/binutils-gdb.git] / ld / scripttempl / elf.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 if [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH}; else OUTPUT_ARCH=${ARCH}:${MACHINE}; fi
27 test "$LD_FLAG" = "N" && DATA_ADDR=.
28 INTERP=".interp ${RELOCATING-0} : { *(.interp) }"
29 PLT=".plt ${RELOCATING-0} : { *(.plt) }"
30 cat <<EOF
31 OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}",
32 "${LITTLE_OUTPUT_FORMAT}")
33 OUTPUT_ARCH(${OUTPUT_ARCH})
34 ENTRY(${ENTRY})
35
36 ${RELOCATING+${LIB_SEARCH_DIRS}}
37 ${RELOCATING+/* Do we need any of these for elf?
38 __DYNAMIC = 0; ${STACKZERO+${STACKZERO}} ${SHLIB_PATH+${SHLIB_PATH}} */}
39 ${RELOCATING+${EXECUTABLE_SYMBOLS}}
40 ${RELOCATING- /* For some reason, the Solaris linker makes bad executables
41 if gld -r is used and the intermediate file has sections starting
42 at non-zero addresses. Could be a Solaris ld bug, could be a GNU ld
43 bug. But for now assigning the zero vmas works. */}
44 SECTIONS
45 {
46 /* Read-only sections, merged into text segment: */
47 ${CREATE_SHLIB-${RELOCATING+. = ${TEXT_START_ADDR} + SIZEOF_HEADERS;}}
48 ${CREATE_SHLIB+${RELOCATING+. = SIZEOF_HEADERS;}}
49 ${CREATE_SHLIB-${INTERP}}
50 .hash ${RELOCATING-0} : { *(.hash) }
51 .dynsym ${RELOCATING-0} : { *(.dynsym) }
52 .dynstr ${RELOCATING-0} : { *(.dynstr) }
53 .rel.text ${RELOCATING-0} : { *(.rel.text) }
54 .rela.text ${RELOCATING-0} : { *(.rela.text) }
55 .rel.data ${RELOCATING-0} : { *(.rel.data) }
56 .rela.data ${RELOCATING-0} : { *(.rela.data) }
57 .rel.rodata ${RELOCATING-0} : { *(.rel.rodata) }
58 .rela.rodata ${RELOCATING-0} : { *(.rela.rodata) }
59 .rel.got ${RELOCATING-0} : { *(.rel.got) }
60 .rela.got ${RELOCATING-0} : { *(.rela.got) }
61 .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) }
62 .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) }
63 .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) }
64 .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) }
65 .rel.init ${RELOCATING-0} : { *(.rel.init) }
66 .rela.init ${RELOCATING-0} : { *(.rela.init) }
67 .rel.fini ${RELOCATING-0} : { *(.rel.fini) }
68 .rela.fini ${RELOCATING-0} : { *(.rela.fini) }
69 .rel.bss ${RELOCATING-0} : { *(.rel.bss) }
70 .rela.bss ${RELOCATING-0} : { *(.rela.bss) }
71 .rel.plt ${RELOCATING-0} : { *(.rel.plt) }
72 .rela.plt ${RELOCATING-0} : { *(.rela.plt) }
73 .init ${RELOCATING-0} : { *(.init) } =${NOP-0}
74 ${DATA_PLT-${PLT}}
75 .text ${RELOCATING-0} :
76 {
77 ${RELOCATING+${TEXT_START_SYMBOLS}}
78 *(.text)
79 /* .gnu.warning sections are handled specially by elf32.em. */
80 *(.gnu.warning)
81 *(.gnu.linkonce*)
82 } =${NOP-0}
83 ${RELOCATING+_etext = .;}
84 ${RELOCATING+PROVIDE (etext = .);}
85 .fini ${RELOCATING-0} : { *(.fini) } =${NOP-0}
86 .rodata ${RELOCATING-0} : { *(.rodata) }
87 .rodata1 ${RELOCATING-0} : { *(.rodata1) }
88 ${RELOCATING+${OTHER_READONLY_SECTIONS}}
89
90 /* Adjust the address for the data segment. We want to adjust up to
91 the same address within the page on the next page up. */
92 ${RELOCATING+. = ${DATA_ADDR-ALIGN(${MAXPAGESIZE}) + (ALIGN(8) & (${MAXPAGESIZE} - 1))};}
93
94 .data ${RELOCATING-0} :
95 {
96 ${RELOCATING+${DATA_START_SYMBOLS}}
97 *(.data)
98 ${CONSTRUCTING+CONSTRUCTORS}
99 }
100 .data1 ${RELOCATING-0} : { *(.data1) }
101 ${RELOCATING+${OTHER_READWRITE_SECTIONS}}
102 .ctors ${RELOCATING-0} : { *(.ctors) }
103 .dtors ${RELOCATING-0} : { *(.dtors) }
104 .got ${RELOCATING-0} : { *(.got.plt) *(.got) }
105 .dynamic ${RELOCATING-0} : { *(.dynamic) }
106 ${DATA_PLT+${PLT}}
107 /* We want the small data sections together, so single-instruction offsets
108 can access them all, and initialized data all before uninitialized, so
109 we can shorten the on-disk segment size. */
110 .sdata ${RELOCATING-0} : { *(.sdata) }
111 ${RELOCATING+_edata = .;}
112 ${RELOCATING+PROVIDE (edata = .);}
113 ${RELOCATING+__bss_start = .;}
114 ${RELOCATING+${OTHER_BSS_SYMBOLS}}
115 .sbss ${RELOCATING-0} : { *(.sbss) *(.scommon) }
116 .bss ${RELOCATING-0} :
117 {
118 *(.dynbss)
119 *(.bss)
120 *(COMMON)
121 }
122 ${RELOCATING+_end = . ;}
123 ${RELOCATING+PROVIDE (end = .);}
124
125 /* Stabs debugging sections. */
126 .stab 0 : { *(.stab) }
127 .stabstr 0 : { *(.stabstr) }
128 .stab.excl 0 : { *(.stab.excl) }
129 .stab.exclstr 0 : { *(.stab.exclstr) }
130 .stab.index 0 : { *(.stab.index) }
131 .stab.indexstr 0 : { *(.stab.indexstr) }
132
133 .comment 0 : { *(.comment) }
134
135 /* DWARF debug sections.
136 Symbols in the .debug DWARF section are relative to the beginning of the
137 section so we begin .debug at 0. It's not clear yet what needs to happen
138 for the others. */
139 .debug 0 : { *(.debug) }
140 .debug_srcinfo 0 : { *(.debug_srcinfo) }
141 .debug_aranges 0 : { *(.debug_aranges) }
142 .debug_pubnames 0 : { *(.debug_pubnames) }
143 .debug_sfnames 0 : { *(.debug_sfnames) }
144 .line 0 : { *(.line) }
145
146 /* These must appear regardless of ${RELOCATING}. */
147 ${OTHER_SECTIONS}
148 }
149 EOF
This page took 0.033584 seconds and 4 git commands to generate.