Lint found by Rich and gcc
[platform/upstream/binutils.git] / ld / ldlang.h
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
38
39 typedef struct memory_region_struct {
40   char *name;
41   struct memory_region_struct *next;
42   bfd_vma origin;
43   bfd_offset length;
44   bfd_vma current;
45   int flags;
46   boolean had_full_message;
47
48 } lang_memory_region_type ;
49
50 typedef struct lang_statement_header_struct 
51   {
52     union  lang_statement_union  *next;
53     enum statement_enum {
54       lang_output_section_statement_enum,
55       lang_assignment_statement_enum,
56       lang_input_statement_enum,
57       lang_address_statement_enum,
58       lang_wild_statement_enum,
59       lang_input_section_enum,
60       lang_object_symbols_statement_enum,
61       lang_fill_statement_enum,
62       lang_data_statement_enum,
63       lang_target_statement_enum,
64       lang_output_statement_enum,
65       lang_padding_statement_enum,
66       
67       lang_afile_asection_pair_statement_enum,
68         lang_constructors_statement_enum
69       } type;
70     
71   } lang_statement_header_type;
72
73
74 typedef struct 
75   {
76     lang_statement_header_type header;
77     union etree_union *exp;
78   }  lang_assignment_statement_type;
79
80
81 typedef struct lang_target_statement_struct {
82   lang_statement_header_type header;
83   CONST char *target;
84 } lang_target_statement_type;
85
86
87 typedef struct lang_output_statement_struct {
88   lang_statement_header_type header;
89   CONST char *name;
90 } lang_output_statement_type;
91
92
93 typedef struct lang_output_section_statement_struct 
94   {
95     lang_statement_header_type header;
96     union etree_union *addr_tree;
97     lang_statement_list_type children;
98     CONST char *memspec;
99     union lang_statement_union *next;
100     CONST char *name;
101     unsigned long subsection_alignment;
102     boolean processed;
103     
104     asection *bfd_section;
105    int flags;
106     struct memory_region_struct *region;
107     size_t block_value;
108     fill_type fill;
109   } lang_output_section_statement_type;
110
111
112 typedef struct {
113   lang_statement_header_type header;
114 } lang_common_statement_type;
115
116 typedef struct {
117   lang_statement_header_type header;
118 } lang_object_symbols_statement_type;
119
120 typedef struct {
121   lang_statement_header_type header;
122   fill_type fill;
123 } lang_fill_statement_type;
124
125 typedef struct {
126   lang_statement_header_type header;
127   unsigned int type;
128   union  etree_union *exp;
129   bfd_vma value;
130   asection *output_section;
131   bfd_vma output_vma;
132 } lang_data_statement_type;
133
134
135
136
137 typedef struct lang_input_statement_struct
138   {
139     lang_statement_header_type header;
140     /* Name of this file.  */
141     CONST char *filename;
142     /* Name to use for the symbol giving address of text start */
143     /* Usually the same as filename, but for a file spec'd with -l
144        this is the -l switch itself rather than the filename.  */
145     CONST char *local_sym_name;
146     
147     bfd *the_bfd;
148     
149     boolean closed;
150     file_ptr passive_position;
151     
152     /* Symbol table of the file.  */
153     asymbol **asymbols;
154     unsigned int symbol_count;
155     
156     /* For library members only */
157     
158     /* For a library, points to chain of entries for the library members.  */
159     struct lang_input_statement_struct *subfiles;
160     /* For a library member, offset of the member within the archive.
161        Zero for files that are not library members.  */
162     /*  int starting_offset;*/
163     /* Size of contents of this file, if library member.  */
164     bfd_size_type total_size;
165     /* For library member, points to the library's own entry.  */
166     struct lang_input_statement_struct *superfile;
167     /* For library member, points to next entry for next member.  */
168     struct lang_input_statement_struct *chain;
169     /* Point to the next file - whatever it is, wanders up and down
170        archives */
171     
172     union lang_statement_union  *next;
173     /* Point to the next file, but skips archive contents */
174     union  lang_statement_union  *next_real_file;
175     
176     boolean is_archive;
177     
178     /* 1 means search a set of directories for this file.  */
179     boolean search_dirs_flag;
180     
181     /* 1 means this is base file of incremental load.
182        Do not load this file's text or data.
183        Also default text_start to after this file's bss. */
184     
185     boolean just_syms_flag;
186     
187     boolean loaded;
188     
189     
190     /*    unsigned int globals_in_this_file;*/
191     CONST char *target;
192     boolean real;
193     
194     asection *common_section;
195     asection *common_output_section;
196   } lang_input_statement_type;
197
198 typedef struct {
199   lang_statement_header_type header;
200   asection *section;
201   lang_input_statement_type *ifile;
202   
203 } lang_input_section_type;
204
205
206 typedef struct {
207   lang_statement_header_type header;
208   asection *section;
209   union lang_statement_union *file;
210 } lang_afile_asection_pair_statement_type;
211
212 typedef struct lang_wild_statement_struct {
213   lang_statement_header_type header;
214   CONST char *section_name;
215   CONST char *filename;
216   lang_statement_list_type children;
217 } lang_wild_statement_type;
218
219 typedef struct lang_address_statement_struct {
220   lang_statement_header_type header;
221   CONST  char *section_name;
222   union  etree_union *address;
223 } lang_address_statement_type;
224
225 typedef struct {
226   lang_statement_header_type header;
227   bfd_vma output_offset;
228   size_t size;
229   asection *output_section;
230   fill_type fill;
231 } lang_padding_statement_type;
232
233 typedef union lang_statement_union 
234   {
235     lang_statement_header_type header;
236     union lang_statement_union *next;
237     lang_wild_statement_type wild_statement;
238     lang_data_statement_type data_statement;
239     lang_address_statement_type address_statement;
240     lang_output_section_statement_type output_section_statement;
241     lang_afile_asection_pair_statement_type afile_asection_pair_statement;
242     lang_assignment_statement_type assignment_statement;
243     lang_input_statement_type input_statement;
244     lang_target_statement_type target_statement;
245     lang_output_statement_type output_statement;
246     lang_input_section_type input_section;
247     lang_common_statement_type common_statement;
248     lang_object_symbols_statement_type object_symbols_statement;
249     lang_fill_statement_type fill_statement;
250     lang_padding_statement_type padding_statement;
251   } lang_statement_union_type;
252
253
254
255 PROTO(void,lang_init,(void));
256 PROTO(struct memory_region_struct ,
257       *lang_memory_region_lookup,(CONST
258                                   char *CONST));
259
260
261 PROTO(void ,lang_map,(void));
262 PROTO(void,lang_set_flags,(int  *, CONST char *));
263 PROTO(void,lang_add_output,(CONST char *));
264
265 PROTO(void,lang_final,(void));
266 PROTO(struct symbol_cache_entry *,create_symbol,(CONST char *, unsigned int, struct sec *));
267 PROTO(void ,lang_process,(void));
268 PROTO(void ,lang_section_start,(CONST char *, union etree_union *));
269 PROTO(void,lang_add_entry,(CONST char *));
270 PROTO(void,lang_add_target,(CONST char *));
271 PROTO(void,lang_add_wild,(CONST char *CONST , CONST char *CONST));
272 PROTO(void,lang_add_map,(CONST char *));
273 PROTO(void,lang_add_fill,(int));
274 PROTO(void,lang_add_assignment,(union etree_union *));
275 PROTO(void,lang_add_attribute,(enum statement_enum));
276 PROTO(void,lang_startup,(CONST char *));
277 PROTO(void,lang_float,(enum bfd_boolean));
278 PROTO(void,lang_leave_output_section_statement,(bfd_vma, CONST char *));
279 PROTO(void,lang_abs_symbol_at_end_of,(CONST char *, CONST char *));
280 PROTO(void,lang_abs_symbol_at_beginning_of,(CONST char *, CONST char *));
281 PROTO(void,lang_statement_append,(struct statement_list *, union lang_statement_union *, union lang_statement_union **));
282 PROTO(void, lang_for_each_file,(void (*dothis)(lang_input_statement_type *)));
283
284
285 #define LANG_FOR_EACH_INPUT_STATEMENT(statement)               \
286   extern lang_statement_list_type file_chain;                   \
287   lang_input_statement_type *statement;                         \
288   for (statement = (lang_input_statement_type *)file_chain.head;\
289        statement != (lang_input_statement_type *)NULL;          \
290        statement = (lang_input_statement_type *)statement->next)\
291   
292 #define LANG_FOR_EACH_INPUT_SECTION(statement, abfd, section, x) \
293   { extern lang_statement_list_type file_chain;                 \
294       lang_input_statement_type *statement;                             \
295         for (statement = (lang_input_statement_type *)file_chain.head;\
296              statement != (lang_input_statement_type *)NULL;            \
297              statement = (lang_input_statement_type *)statement->next)\
298                  {                                                              \
299           asection *section;                                    \
300     bfd *abfd = statement->the_bfd;                             \
301       for (section = abfd->sections;                            \
302            section != (asection *)NULL;                         \
303            section = section->next) {                           \
304           x;                                                    \
305   }                                                             \
306   }                                                             \
307  }              
308
309 #define LANG_FOR_EACH_OUTPUT_SECTION(section, x)                \
310   { extern bfd *output_bfd;                                     \
311       asection *section;                                        \
312         for (section = output_bfd->sections;                            \
313              section != (asection *)NULL;                               \
314              section = section->next)                           \
315                  { x; }                                                 \
316                  }
317
318
319 PROTO(void, lang_process,(void));
320 PROTO(void, ldlang_add_file,(lang_input_statement_type *));
321
322 PROTO(lang_output_section_statement_type
323       *,lang_output_section_find,(CONST char * CONST));
324
325 PROTO(lang_input_statement_type *,
326       lang_add_input_file,(CONST char *name,
327                            lang_input_file_enum_type file_type,
328                           CONST char *target));
329 PROTO(lang_output_section_statement_type *,
330       lang_output_section_statement_lookup,(CONST char * CONST name));
331
332 PROTO(void, ldlang_add_undef,(CONST char *CONST name));
333 PROTO(void, lang_add_output_format,(CONST char *));
334
335
336 void EXFUN(lang_list_init,( lang_statement_list_type*));
337
338 void EXFUN(lang_add_data,(int type, union etree_union *));
339
340 void EXFUN(lang_for_each_statement,(void (*func)()));
341