3 Copyright (C) 1991 Free Software Foundation, Inc.
5 This file is part of GLD, the Gnu Linker.
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)
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.
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. */
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
;
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
;
40 boolean flag_executable
;
41 boolean flag_loadable
;
42 } lang_section_flags_type
;
44 typedef struct memory_region_struct
{
46 struct memory_region_struct
*next
;
50 lang_section_flags_type flags
;
51 } lang_memory_region_type
;
53 typedef struct lang_statement_header_struct
55 union lang_statement_union
*next
;
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
,
71 lang_afile_asection_pair_statement_enum
74 } lang_statement_header_type
;
79 lang_statement_header_type header
;
80 union etree_union
*exp
;
81 } lang_assignment_statement_type
;
84 typedef struct lang_target_statement_struct
{
85 lang_statement_header_type header
;
87 } lang_target_statement_type
;
90 typedef struct lang_output_statement_struct
{
91 lang_statement_header_type header
;
93 } lang_output_statement_type
;
96 typedef struct lang_output_section_statement_struct
98 lang_statement_header_type header
;
99 union etree_union
*addr_tree
;
100 lang_statement_list_type children
;
102 union lang_statement_union
*next
;
104 unsigned long subsection_alignment
;
107 asection
*bfd_section
;
108 lang_section_flags_type flags
;
109 struct memory_region_struct
*region
;
112 } lang_output_section_statement_type
;
116 lang_statement_header_type header
;
117 } lang_common_statement_type
;
120 lang_statement_header_type header
;
121 } lang_object_symbols_statement_type
;
124 lang_statement_header_type header
;
126 } lang_fill_statement_type
;
129 lang_statement_header_type header
;
131 union etree_union
*exp
;
133 asection
*output_section
;
135 } lang_data_statement_type
;
140 typedef struct lang_input_statement_struct
142 lang_statement_header_type header
;
143 /* Name of this file. */
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
;
150 /* Describe the layout of the contents of the file */
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. */
157 /* Describe data from the file loaded into core */
162 file_ptr passive_position
;
164 /* Symbol table of the file. */
166 unsigned int symbol_count
;
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'. */
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
;
177 /* For library members only */
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. */
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
;
197 /* 1 if file's header has been read into this structure. */
198 boolean header_read_flag
;
200 /* 1 means search a set of directories for this file. */
201 boolean search_dirs_flag
;
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
;
211 /* unsigned int globals_in_this_file;*/
215 asection
*common_section
;
216 asection
*common_output_section
;
217 } lang_input_statement_type
;
220 lang_statement_header_type header
;
222 lang_input_statement_type
*ifile
;
223 } lang_input_section_type
;
227 lang_statement_header_type header
;
229 union lang_statement_union
*file
;
230 } lang_afile_asection_pair_statement_type
;
232 typedef struct lang_wild_statement_struct
{
233 lang_statement_header_type header
;
236 lang_statement_list_type children
;
237 } lang_wild_statement_type
;
239 typedef struct lang_address_statement_struct
{
240 lang_statement_header_type header
;
242 union etree_union
*address
;
243 } lang_address_statement_type
;
246 lang_statement_header_type header
;
247 bfd_vma output_offset
;
249 asection
*output_section
;
251 } lang_padding_statement_type
;
253 typedef union lang_statement_union
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
;
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 *));
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 *));
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
*)));
301 #define LANG_FOR_EACH_ASYMBOL(asymbol) \
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)\
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)\
318 bfd *abfd = statement->the_bfd; \
319 for (section = abfd->sections; \
320 section != (asection *)NULL; \
321 section = section->next) { \
327 #define LANG_FOR_EACH_OUTPUT_SECTION(section, x) \
328 { extern bfd *output_bfd; \
330 for (section = output_bfd->sections; \
331 section != (asection *)NULL; \
332 section = section->next) \
337 PROTO(void, lang_process
,(void));
338 PROTO(void, ldlang_add_file
,(lang_input_statement_type
*));
340 PROTO(lang_output_section_statement_type
*,lang_output_section_find
,());
342 PROTO(lang_input_statement_type
*,
343 lang_add_input_file
,(char *name
,
344 lang_input_file_enum_type file_type
,
346 PROTO(lang_output_section_statement_type
*,
347 lang_output_section_statement_lookup
,(char *name
));