]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/binutils/ld/scripttempl/elf.sc
unfinished sblive driver, playback/mixer only for now - not enabled in
[FreeBSD/FreeBSD.git] / contrib / binutils / 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 #       INITIAL_READONLY_SECTIONS - at start of text segment
6 #       OTHER_READONLY_SECTIONS - other than .text .init .rodata ...
7 #               (e.g., .PARISC.milli)
8 #       OTHER_TEXT_SECTIONS - these get put in .text when relocating
9 #       OTHER_READWRITE_SECTIONS - other than .data .bss .ctors .sdata ...
10 #               (e.g., .PARISC.global)
11 #       OTHER_SECTIONS - at the end
12 #       EXECUTABLE_SYMBOLS - symbols that must be defined for an
13 #               executable (e.g., _DYNAMIC_LINK)
14 #       TEXT_START_SYMBOLS - symbols that appear at the start of the
15 #               .text section.
16 #       DATA_START_SYMBOLS - symbols that appear at the start of the
17 #               .data section.
18 #       OTHER_GOT_SYMBOLS - symbols defined just before .got.
19 #       OTHER_GOT_SECTIONS - sections just after .got and .sdata.
20 #       OTHER_BSS_SYMBOLS - symbols that appear at the start of the
21 #               .bss section besides __bss_start.
22 #       DATA_PLT - .plt should be in data segment, not text segment.
23 #       TEXT_DYNAMIC - .dynamic in text segment, not data segment.
24 #       EMBEDDED - whether this is for an embedded system. 
25 #       SHLIB_TEXT_START_ADDR - if set, add to SIZEOF_HEADERS to set
26 #               start address of shared library.
27 #
28 # When adding sections, do note that the names of some sections are used
29 # when specifying the start address of the next.
30 #
31
32 test -z "$ENTRY" && ENTRY=_start
33 test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT}
34 test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT}
35 if [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH}; else OUTPUT_ARCH=${ARCH}:${MACHINE}; fi
36 test -z "${ELFSIZE}" && ELFSIZE=32
37 test "$LD_FLAG" = "N" && DATA_ADDR=.
38 INTERP=".interp   ${RELOCATING-0} : { *(.interp)        }"
39 PLT=".plt    ${RELOCATING-0} : { *(.plt)        }"
40 DYNAMIC=".dynamic     ${RELOCATING-0} : { *(.dynamic) }"
41
42 # if this is for an embedded system, don't add SIZEOF_HEADERS.
43 if [ -z "$EMBEDDED" ]; then
44    test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR} + SIZEOF_HEADERS"
45 else
46    test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR}"
47 fi
48
49 cat <<EOF
50 OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}",
51               "${LITTLE_OUTPUT_FORMAT}")
52 OUTPUT_ARCH(${OUTPUT_ARCH})
53 ENTRY(${ENTRY})
54
55 ${RELOCATING+${LIB_SEARCH_DIRS}}
56 ${RELOCATING+/* Do we need any of these for elf?
57    __DYNAMIC = 0; ${STACKZERO+${STACKZERO}} ${SHLIB_PATH+${SHLIB_PATH}}  */}
58 ${RELOCATING+${EXECUTABLE_SYMBOLS}}
59 ${RELOCATING- /* For some reason, the Solaris linker makes bad executables
60   if gld -r is used and the intermediate file has sections starting
61   at non-zero addresses.  Could be a Solaris ld bug, could be a GNU ld
62   bug.  But for now assigning the zero vmas works.  */}
63 SECTIONS
64 {
65   /* Read-only sections, merged into text segment: */
66   ${CREATE_SHLIB-${RELOCATING+. = ${TEXT_BASE_ADDRESS};}}
67   ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR:-0} + SIZEOF_HEADERS;}}
68   ${CREATE_SHLIB-${INTERP}}
69   ${INITIAL_READONLY_SECTIONS}
70   ${TEXT_DYNAMIC+${DYNAMIC}}
71   .hash        ${RELOCATING-0} : { *(.hash)             }
72   .dynsym      ${RELOCATING-0} : { *(.dynsym)           }
73   .dynstr      ${RELOCATING-0} : { *(.dynstr)           }
74   .gnu.version ${RELOCATING-0} : { *(.gnu.version)      }
75   .gnu.version_d ${RELOCATING-0} : { *(.gnu.version_d)  }
76   .gnu.version_r ${RELOCATING-0} : { *(.gnu.version_r)  }
77   .rel.text    ${RELOCATING-0} :
78     { *(.rel.text) ${RELOCATING+*(.rel.gnu.linkonce.t*)} }
79   .rela.text   ${RELOCATING-0} :
80     { *(.rela.text) ${RELOCATING+*(.rela.gnu.linkonce.t*)} }
81   .rel.data    ${RELOCATING-0} :
82     { *(.rel.data) ${RELOCATING+*(.rel.gnu.linkonce.d*)} }
83   .rela.data   ${RELOCATING-0} :
84     { *(.rela.data) ${RELOCATING+*(.rela.gnu.linkonce.d*)} }
85   .rel.rodata  ${RELOCATING-0} :
86     { *(.rel.rodata) ${RELOCATING+*(.rel.gnu.linkonce.r*)} }
87   .rela.rodata ${RELOCATING-0} :
88     { *(.rela.rodata) ${RELOCATING+*(.rela.gnu.linkonce.r*)} }
89   .rel.got     ${RELOCATING-0} : { *(.rel.got)          }
90   .rela.got    ${RELOCATING-0} : { *(.rela.got)         }
91   .rel.ctors   ${RELOCATING-0} : { *(.rel.ctors)        }
92   .rela.ctors  ${RELOCATING-0} : { *(.rela.ctors)       }
93   .rel.dtors   ${RELOCATING-0} : { *(.rel.dtors)        }
94   .rela.dtors  ${RELOCATING-0} : { *(.rela.dtors)       }
95   .rel.init    ${RELOCATING-0} : { *(.rel.init) }
96   .rela.init   ${RELOCATING-0} : { *(.rela.init)        }
97   .rel.fini    ${RELOCATING-0} : { *(.rel.fini) }
98   .rela.fini   ${RELOCATING-0} : { *(.rela.fini)        }
99   .rel.bss     ${RELOCATING-0} : { *(.rel.bss)          }
100   .rela.bss    ${RELOCATING-0} : { *(.rela.bss)         }
101   .rel.plt     ${RELOCATING-0} : { *(.rel.plt)          }
102   .rela.plt    ${RELOCATING-0} : { *(.rela.plt)         }
103   .init        ${RELOCATING-0} : { *(.init)     } =${NOP-0}
104   ${DATA_PLT-${PLT}}
105   .text    ${RELOCATING-0} :
106   {
107     ${RELOCATING+${TEXT_START_SYMBOLS}}
108     *(.text)
109     *(.stub)
110     /* .gnu.warning sections are handled specially by elf32.em.  */
111     *(.gnu.warning)
112     ${RELOCATING+*(.gnu.linkonce.t*)}
113     ${RELOCATING+${OTHER_TEXT_SECTIONS}}
114   } =${NOP-0}
115   ${RELOCATING+_etext = .;}
116   ${RELOCATING+PROVIDE (etext = .);}
117   .fini    ${RELOCATING-0} : { *(.fini)    } =${NOP-0}
118   .rodata  ${RELOCATING-0} : { *(.rodata) ${RELOCATING+*(.gnu.linkonce.r*)} }
119   .rodata1 ${RELOCATING-0} : { *(.rodata1) }
120   ${RELOCATING+${OTHER_READONLY_SECTIONS}}
121
122   /* Adjust the address for the data segment.  We want to adjust up to
123      the same address within the page on the next page up.  */
124   ${CREATE_SHLIB-${RELOCATING+. = ${DATA_ADDR-ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))};}}
125   ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_DATA_ADDR-ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))};}}
126
127   .data  ${RELOCATING-0} :
128   {
129     ${RELOCATING+${DATA_START_SYMBOLS}}
130     *(.data)
131     ${RELOCATING+*(.gnu.linkonce.d*)}
132     ${CONSTRUCTING+CONSTRUCTORS}
133   }
134   .data1 ${RELOCATING-0} : { *(.data1) }
135   ${RELOCATING+${OTHER_READWRITE_SECTIONS}}
136   .ctors       ${RELOCATING-0} :
137   {
138     ${CONSTRUCTING+${CTOR_START}}
139     *(.ctors)
140     ${CONSTRUCTING+${CTOR_END}}
141   }
142   .dtors       ${RELOCATING-0} :
143   {
144     ${CONSTRUCTING+${DTOR_START}}
145     *(.dtors)
146     ${CONSTRUCTING+${DTOR_END}}
147   }
148   ${DATA_PLT+${PLT}}
149   ${RELOCATING+${OTHER_GOT_SYMBOLS}}
150   .got         ${RELOCATING-0} : { *(.got.plt) *(.got) }
151   ${TEXT_DYNAMIC-${DYNAMIC}}
152   /* We want the small data sections together, so single-instruction offsets
153      can access them all, and initialized data all before uninitialized, so
154      we can shorten the on-disk segment size.  */
155   .sdata   ${RELOCATING-0} : { *(.sdata) }
156   ${RELOCATING+${OTHER_GOT_SECTIONS}}
157   ${RELOCATING+_edata  =  .;}
158   ${RELOCATING+PROVIDE (edata = .);}
159   ${RELOCATING+__bss_start = .;}
160   ${RELOCATING+${OTHER_BSS_SYMBOLS}}
161   .sbss    ${RELOCATING-0} : { *(.sbss) *(.scommon) }
162   .bss     ${RELOCATING-0} :
163   {
164    *(.dynbss)
165    *(.bss)
166    *(COMMON)
167   }
168   ${RELOCATING+. = ALIGN(${ELFSIZE} / 8);}
169   ${RELOCATING+_end = . ;}
170   ${RELOCATING+PROVIDE (end = .);}
171
172   /* Stabs debugging sections.  */
173   .stab 0 : { *(.stab) }
174   .stabstr 0 : { *(.stabstr) }
175   .stab.excl 0 : { *(.stab.excl) }
176   .stab.exclstr 0 : { *(.stab.exclstr) }
177   .stab.index 0 : { *(.stab.index) }
178   .stab.indexstr 0 : { *(.stab.indexstr) }
179
180   .comment 0 : { *(.comment) }
181
182   /* DWARF debug sections.
183      Symbols in the DWARF debugging sections are relative to the beginning
184      of the section so we begin them at 0.  */
185
186   /* DWARF 1 */
187   .debug          0 : { *(.debug) }
188   .line           0 : { *(.line) }
189
190   /* GNU DWARF 1 extensions */
191   .debug_srcinfo  0 : { *(.debug_srcinfo) }
192   .debug_sfnames  0 : { *(.debug_sfnames) }
193
194   /* DWARF 1.1 and DWARF 2 */
195   .debug_aranges  0 : { *(.debug_aranges) }
196   .debug_pubnames 0 : { *(.debug_pubnames) }
197
198   /* DWARF 2 */
199   .debug_info     0 : { *(.debug_info) }
200   .debug_abbrev   0 : { *(.debug_abbrev) }
201   .debug_line     0 : { *(.debug_line) }
202   .debug_frame    0 : { *(.debug_frame) }
203   .debug_str      0 : { *(.debug_str) }
204   .debug_loc      0 : { *(.debug_loc) }
205   .debug_macinfo  0 : { *(.debug_macinfo) }
206
207   /* SGI/MIPS DWARF 2 extensions */
208   .debug_weaknames 0 : { *(.debug_weaknames) }
209   .debug_funcnames 0 : { *(.debug_funcnames) }
210   .debug_typenames 0 : { *(.debug_typenames) }
211   .debug_varnames  0 : { *(.debug_varnames) }
212
213   ${RELOCATING+${OTHER_RELOCATING_SECTIONS}}
214
215   /* These must appear regardless of ${RELOCATING}.  */
216   ${OTHER_SECTIONS}
217 }
218 EOF