Commit | Line | Data |
---|---|---|
2fa0b342 DHW |
1 | /* ldlang.h - |
2 | ||
3 | Copyright (C) 1991 Free Software Foundation, Inc. | |
4 | ||
5 | This file is part of GLD, the Gnu Linker. | |
6 | ||
7 | GLD is free software; you can redistribute it and/or modify | |
8 | it under the terms of the GNU General Public License as published by | |
9 | the Free Software Foundation; either version 1, or (at your option) | |
10 | any later version. | |
11 | ||
12 | GLD is distributed in the hope that it will be useful, | |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
18 | along with GLD; see the file COPYING. If not, write to | |
19 | the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
20 | ||
21 | ||
22 | typedef enum { | |
23 | lang_input_file_is_l_enum, | |
24 | lang_input_file_is_symbols_only_enum, | |
25 | lang_input_file_is_marker_enum, | |
26 | lang_input_file_is_fake_enum, | |
27 | lang_input_file_is_search_file_enum, | |
28 | lang_input_file_is_file_enum } lang_input_file_enum_type; | |
29 | ||
30 | typedef unsigned short fill_type; | |
31 | typedef struct statement_list { | |
32 | union lang_statement_union *head; | |
33 | union lang_statement_union **tail; | |
34 | } lang_statement_list_type; | |
35 | ||
36 | ||
37 | typedef struct { | |
38 | boolean flag_read; | |
39 | boolean flag_write; | |
40 | boolean flag_executable; | |
41 | boolean flag_loadable; | |
42 | } lang_section_flags_type; | |
43 | ||
44 | typedef struct memory_region_struct { | |
45 | char *name; | |
46 | struct memory_region_struct *next; | |
47 | bfd_vma origin; | |
48 | bfd_offset length; | |
49 | bfd_vma current; | |
50 | lang_section_flags_type flags; | |
51 | } lang_memory_region_type ; | |
52 | ||
53 | typedef struct lang_statement_header_struct | |
54 | { | |
55 | union lang_statement_union *next; | |
56 | enum statement_enum { | |
57 | lang_output_section_statement_enum, | |
58 | lang_assignment_statement_enum, | |
59 | lang_input_statement_enum, | |
60 | lang_address_statement_enum, | |
61 | lang_wild_statement_enum, | |
62 | lang_input_section_enum, | |
63 | lang_common_statement_enum, | |
64 | lang_object_symbols_statement_enum, | |
65 | lang_fill_statement_enum, | |
66 | lang_data_statement_enum, | |
67 | lang_target_statement_enum, | |
68 | lang_output_statement_enum, | |
69 | lang_padding_statement_enum, | |
70 | ||
71 | lang_afile_asection_pair_statement_enum | |
72 | } type; | |
73 | ||
74 | } lang_statement_header_type; | |
75 | ||
76 | ||
77 | typedef struct | |
78 | { | |
79 | lang_statement_header_type header; | |
80 | union etree_union *exp; | |
81 | } lang_assignment_statement_type; | |
82 | ||
83 | ||
84 | typedef struct lang_target_statement_struct { | |
85 | lang_statement_header_type header; | |
86 | char *target; | |
87 | } lang_target_statement_type; | |
88 | ||
89 | ||
90 | typedef struct lang_output_statement_struct { | |
91 | lang_statement_header_type header; | |
92 | char *name; | |
93 | } lang_output_statement_type; | |
94 | ||
95 | ||
96 | typedef struct lang_output_section_statement_struct | |
97 | { | |
98 | lang_statement_header_type header; | |
99 | union etree_union *addr_tree; | |
100 | lang_statement_list_type children; | |
101 | char *memspec; | |
102 | union lang_statement_union *next; | |
103 | char *name; | |
104 | unsigned long subsection_alignment; | |
105 | boolean processed; | |
106 | ||
107 | asection *bfd_section; | |
108 | lang_section_flags_type flags; | |
109 | struct memory_region_struct *region; | |
110 | size_t block_value; | |
111 | fill_type fill; | |
112 | } lang_output_section_statement_type; | |
113 | ||
114 | ||
115 | typedef struct { | |
116 | lang_statement_header_type header; | |
117 | } lang_common_statement_type; | |
118 | ||
119 | typedef struct { | |
120 | lang_statement_header_type header; | |
121 | } lang_object_symbols_statement_type; | |
122 | ||
123 | typedef struct { | |
124 | lang_statement_header_type header; | |
125 | fill_type fill; | |
126 | } lang_fill_statement_type; | |
127 | ||
128 | typedef struct { | |
129 | lang_statement_header_type header; | |
130 | unsigned int type; | |
131 | union etree_union *exp; | |
132 | bfd_vma value; | |
133 | asection *output_section; | |
134 | bfd_vma output_vma; | |
135 | } lang_data_statement_type; | |
136 | ||
137 | ||
138 | ||
139 | ||
140 | typedef struct lang_input_statement_struct | |
141 | { | |
142 | lang_statement_header_type header; | |
143 | /* Name of this file. */ | |
144 | char *filename; | |
145 | /* Name to use for the symbol giving address of text start */ | |
146 | /* Usually the same as filename, but for a file spec'd with -l | |
147 | this is the -l switch itself rather than the filename. */ | |
148 | char *local_sym_name; | |
149 | ||
150 | /* Describe the layout of the contents of the file */ | |
151 | ||
152 | /* The file's a.out header. */ | |
153 | /* struct exec header;*/ | |
154 | /* Offset in file of GDB symbol segment, or 0 if there is none. */ | |
155 | int symseg_offset; | |
156 | ||
157 | /* Describe data from the file loaded into core */ | |
158 | ||
159 | bfd *the_bfd; | |
160 | ||
161 | boolean closed; | |
162 | file_ptr passive_position; | |
163 | ||
164 | /* Symbol table of the file. */ | |
165 | asymbol **asymbols; | |
166 | unsigned int symbol_count; | |
167 | ||
168 | /* Next two used only if `relocatable_output' or if needed for */ | |
169 | /* output of undefined reference line numbers. */ | |
170 | /* Text reloc info saved by `write_text' for `coptxtrel'. */ | |
171 | ||
172 | ||
173 | /* Offset in bytes in the output file symbol table | |
174 | of the first local symbol for this file. Set by `write_file_symbols'. */ | |
175 | int local_syms_offset; | |
176 | ||
177 | /* For library members only */ | |
178 | ||
179 | /* For a library, points to chain of entries for the library members. */ | |
180 | struct lang_input_statement_struct *subfiles; | |
181 | /* For a library member, offset of the member within the archive. | |
182 | Zero for files that are not library members. */ | |
183 | /* int starting_offset;*/ | |
184 | /* Size of contents of this file, if library member. */ | |
185 | int total_size; | |
186 | /* For library member, points to the library's own entry. */ | |
187 | struct lang_input_statement_struct *superfile; | |
188 | /* For library member, points to next entry for next member. */ | |
189 | struct lang_input_statement_struct *chain; | |
190 | /* Point to the next file - whatever it is, wanders up and down archives */ | |
191 | union lang_statement_union *next; | |
192 | /* Point to the next file, but skips archive contents */ | |
193 | union lang_statement_union *next_real_file; | |
194 | ||
195 | boolean is_archive; | |
196 | ||
197 | /* 1 if file's header has been read into this structure. */ | |
198 | boolean header_read_flag; | |
199 | ||
200 | /* 1 means search a set of directories for this file. */ | |
201 | boolean search_dirs_flag; | |
202 | ||
203 | /* 1 means this is base file of incremental load. | |
204 | Do not load this file's text or data. | |
205 | Also default text_start to after this file's bss. */ | |
206 | boolean just_syms_flag; | |
207 | ||
208 | boolean loaded; | |
209 | ||
210 | ||
211 | /* unsigned int globals_in_this_file;*/ | |
212 | char *target; | |
213 | boolean real; | |
214 | ||
215 | asection *common_section; | |
216 | asection *common_output_section; | |
217 | } lang_input_statement_type; | |
218 | ||
219 | typedef struct { | |
220 | lang_statement_header_type header; | |
221 | asection *section; | |
222 | lang_input_statement_type *ifile; | |
223 | } lang_input_section_type; | |
224 | ||
225 | ||
226 | typedef struct { | |
227 | lang_statement_header_type header; | |
228 | asection *section; | |
229 | union lang_statement_union *file; | |
230 | } lang_afile_asection_pair_statement_type; | |
231 | ||
232 | typedef struct lang_wild_statement_struct { | |
233 | lang_statement_header_type header; | |
234 | char *section_name; | |
235 | char *filename; | |
236 | lang_statement_list_type children; | |
237 | } lang_wild_statement_type; | |
238 | ||
239 | typedef struct lang_address_statement_struct { | |
240 | lang_statement_header_type header; | |
241 | char *section_name; | |
242 | union etree_union *address; | |
243 | } lang_address_statement_type; | |
244 | ||
245 | typedef struct { | |
246 | lang_statement_header_type header; | |
247 | bfd_vma output_offset; | |
248 | size_t size; | |
249 | asection *output_section; | |
250 | fill_type fill; | |
251 | } lang_padding_statement_type; | |
252 | ||
253 | typedef union lang_statement_union | |
254 | { | |
255 | lang_statement_header_type header; | |
256 | union lang_statement_union *next; | |
257 | lang_wild_statement_type wild_statement; | |
258 | lang_data_statement_type data_statement; | |
259 | lang_address_statement_type address_statement; | |
260 | lang_output_section_statement_type output_section_statement; | |
261 | lang_afile_asection_pair_statement_type afile_asection_pair_statement; | |
262 | lang_assignment_statement_type assignment_statement; | |
263 | lang_input_statement_type input_statement; | |
264 | lang_target_statement_type target_statement; | |
265 | lang_output_statement_type output_statement; | |
266 | lang_input_section_type input_section; | |
267 | lang_common_statement_type common_statement; | |
268 | lang_object_symbols_statement_type object_symbols_statement; | |
269 | lang_fill_statement_type fill_statement; | |
270 | lang_padding_statement_type padding_statement; | |
271 | } lang_statement_union_type; | |
272 | ||
273 | ||
274 | ||
275 | PROTO(void,lang_init,(void)); | |
276 | PROTO(struct memory_region_struct ,*lang_memory_region_lookup,(char *)); | |
277 | PROTO(struct lang_output_section_statement_struct *,lang_output_section_find,(char *)); | |
278 | ||
279 | PROTO(void ,lang_map,(struct _iobuf *)); | |
280 | PROTO(void,lang_set_flags,(lang_section_flags_type *, char *)); | |
281 | PROTO(void,lang_add_output,(char *)); | |
282 | ||
283 | PROTO(void,lang_final,(void)); | |
284 | PROTO(struct symbol_cache_entry *,create_symbol,(char *, unsigned int, struct sec_struct *)); | |
285 | PROTO(void ,lang_process,(void)); | |
286 | PROTO(void ,lang_section_start,(char *, union etree_union *)); | |
287 | PROTO(void,lang_add_entry,(char *)); | |
288 | PROTO(void,lang_add_target,(char *)); | |
289 | PROTO(void,lang_add_wild,(char *, char *)); | |
290 | PROTO(void,lang_add_map,(char *)); | |
291 | PROTO(void,lang_add_fill,(int)); | |
292 | PROTO(void,lang_add_assignment,(union etree_union *)); | |
293 | PROTO(void,lang_add_attribute,(enum statement_enum)); | |
294 | PROTO(void,lang_startup,(char *)); | |
295 | PROTO(void,lang_float,(enum boolean)); | |
296 | PROTO(void,lang_leave_output_section_statement,(bfd_vma, char *)); | |
297 | PROTO(void,lang_abs_symbol_at_end_of,(char *, char *)); | |
298 | PROTO(void,lang_statement_append,(struct statement_list *, union lang_statement_union *, union lang_statement_union **)); | |
299 | PROTO(void, lang_for_each_file,(void (*dothis)(lang_input_statement_type *))); | |
300 | ||
301 | #define LANG_FOR_EACH_ASYMBOL(asymbol) \ | |
302 | ||
303 | #define LANG_FOR_EACH_INPUT_STATEMENT(statement) \ | |
304 | extern lang_statement_list_type file_chain; \ | |
305 | lang_input_statement_type *statement; \ | |
306 | for (statement = (lang_input_statement_type *)file_chain.head;\ | |
307 | statement != (lang_input_statement_type *)NULL; \ | |
308 | statement = (lang_input_statement_type *)statement->next)\ | |
309 | ||
310 | #define LANG_FOR_EACH_INPUT_SECTION(statement, abfd, section, x) \ | |
311 | { extern lang_statement_list_type file_chain; \ | |
312 | lang_input_statement_type *statement; \ | |
313 | for (statement = (lang_input_statement_type *)file_chain.head;\ | |
314 | statement != (lang_input_statement_type *)NULL; \ | |
315 | statement = (lang_input_statement_type *)statement->next)\ | |
316 | { \ | |
317 | asection *section; \ | |
318 | bfd *abfd = statement->the_bfd; \ | |
319 | for (section = abfd->sections; \ | |
320 | section != (asection *)NULL; \ | |
321 | section = section->next) { \ | |
322 | x; \ | |
323 | } \ | |
324 | } \ | |
325 | } | |
326 | ||
327 | #define LANG_FOR_EACH_OUTPUT_SECTION(section, x) \ | |
328 | { extern bfd *output_bfd; \ | |
329 | asection *section; \ | |
330 | for (section = output_bfd->sections; \ | |
331 | section != (asection *)NULL; \ | |
332 | section = section->next) \ | |
333 | { x; } \ | |
334 | } | |
335 | ||
336 | ||
337 | PROTO(void, lang_process,(void)); | |
338 | PROTO(void, ldlang_add_file,(lang_input_statement_type *)); | |
339 | ||
340 | PROTO(lang_output_section_statement_type *,lang_output_section_find,()); | |
341 | ||
342 | PROTO(lang_input_statement_type *, | |
343 | lang_add_input_file,(char *name, | |
344 | lang_input_file_enum_type file_type, | |
345 | char *target)); | |
346 | PROTO(lang_output_section_statement_type *, | |
347 | lang_output_section_statement_lookup,(char *name)); |