lint
[deliverable/binutils-gdb.git] / ld / ldlang.c
1 /* Copyright (C) 1991 Free Software Foundation, Inc.
2
3 This file is part of GLD, the Gnu Linker.
4
5 GLD is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 1, or (at your option)
8 any later version.
9
10 GLD is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GLD; see the file COPYING. If not, write to
17 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
18
19 /* $Id$
20 *
21 */
22
23 #include "bfd.h"
24 #include "sysdep.h"
25
26 #include "ld.h"
27 #include "ldmain.h"
28 #include "ldsym.h"
29 #include "ldgram.h"
30 #include "ldwarn.h"
31 #include "ldlang.h"
32 #include "ldexp.h"
33 #include "ldemul.h"
34 #include "ldlex.h"
35 #include "ldmisc.h"
36 #include "ldindr.h"
37 #include "ldctor.h"
38 /* FORWARDS */
39 PROTO (static void, print_statements, (void));
40 PROTO (static void, print_statement, (lang_statement_union_type *,
41 lang_output_section_statement_type *));
42
43 /* LOCALS */
44 static struct obstack stat_obstack;
45
46 #define obstack_chunk_alloc ldmalloc
47 #define obstack_chunk_free free
48 static CONST char *startup_file;
49 static lang_statement_list_type input_file_chain;
50
51 /* Points to the last statement in the .data section, so we can add
52 stuff to the data section without pain */
53 static lang_statement_list_type end_of_data_section_statement_list;
54
55 /* List of statements needed to handle constructors */
56 extern lang_statement_list_type constructor_list;
57
58 static boolean placed_commons = false;
59 static lang_output_section_statement_type *default_common_section;
60 static boolean map_option_f;
61 static bfd_vma print_dot;
62 static lang_input_statement_type *first_file;
63 static lang_statement_list_type lang_output_section_statement;
64 static CONST char *current_target;
65 static CONST char *output_target;
66 static size_t longest_section_name = 8;
67 static asection common_section;
68 static section_userdata_type common_section_userdata;
69 static lang_statement_list_type statement_list;
70
71 /* EXPORTS */
72 boolean relaxing;
73 lang_output_section_statement_type *abs_output_section;
74 lang_statement_list_type *stat_ptr = &statement_list;
75 lang_input_statement_type *script_file = 0;
76 boolean option_longmap = false;
77 lang_statement_list_type file_chain =
78 {0};
79 CONST char *entry_symbol = 0;
80 bfd_size_type largest_section = 0;
81 boolean lang_has_input_file = false;
82 lang_output_section_statement_type *create_object_symbols = 0;
83 boolean had_output_filename = false;
84 boolean lang_float_flag = false;
85
86 /* IMPORTS */
87 extern char *default_target;
88
89 extern unsigned int undefined_global_sym_count;
90 extern char *current_file;
91 extern bfd *output_bfd;
92 extern enum bfd_architecture ldfile_output_architecture;
93 extern unsigned long ldfile_output_machine;
94 extern char *ldfile_output_machine_name;
95 extern ldsym_type *symbol_head;
96 extern unsigned int commons_pending;
97 extern args_type command_line;
98 extern ld_config_type config;
99 extern boolean had_script;
100 extern boolean write_map;
101
102 #ifdef __STDC__
103 #define cat(a,b) a##b
104 #else
105 #define cat(a,b) a/**/b
106 #endif
107
108 #define new_stat(x,y) (cat(x,_type)*) new_statement(cat(x,_enum), sizeof(cat(x,_type)),y)
109
110 #define outside_section_address(q) ( (q)->output_offset + (q)->output_section->vma)
111
112 #define outside_symbol_address(q) ((q)->value + outside_section_address(q->section))
113
114 void EXFUN (lang_add_data, (int type, union etree_union * exp));
115
116 PTR
117 DEFUN (stat_alloc, (size),
118 size_t size)
119 {
120 return obstack_alloc (&stat_obstack, size);
121 }
122 static void
123 DEFUN (print_size, (value),
124 size_t value)
125 {
126 fprintf (config.map_file, "%5x", (unsigned) value);
127 }
128 static void
129 DEFUN (print_alignment, (value),
130 unsigned int value)
131 {
132 fprintf (config.map_file, "2**%1u", value);
133 }
134 static void
135 DEFUN (print_fill, (value),
136 fill_type value)
137 {
138 fprintf (config.map_file, "%04x", (unsigned) value);
139 }
140
141
142 static void
143 DEFUN (print_section, (name),
144 CONST char *CONST name)
145 {
146 fprintf (config.map_file, "%*s", -longest_section_name, name);
147 }
148
149 /*----------------------------------------------------------------------
150 lang_for_each_statement walks the parse tree and calls the provided
151 function for each node
152 */
153
154 static void
155 DEFUN (lang_for_each_statement_worker, (func, s),
156 void (*func) ()AND
157 lang_statement_union_type * s)
158 {
159 for (; s != (lang_statement_union_type *) NULL; s = s->next)
160 {
161 func (s);
162
163 switch (s->header.type)
164 {
165 case lang_constructors_statement_enum:
166 lang_for_each_statement_worker (func, constructor_list.head);
167 break;
168 case lang_output_section_statement_enum:
169 lang_for_each_statement_worker
170 (func,
171 s->output_section_statement.children.head);
172 break;
173 case lang_wild_statement_enum:
174 lang_for_each_statement_worker
175 (func,
176 s->wild_statement.children.head);
177 break;
178 case lang_data_statement_enum:
179 case lang_object_symbols_statement_enum:
180 case lang_output_statement_enum:
181 case lang_target_statement_enum:
182 case lang_input_section_enum:
183 case lang_input_statement_enum:
184 case lang_assignment_statement_enum:
185 case lang_padding_statement_enum:
186 case lang_address_statement_enum:
187 break;
188 default:
189 FAIL ();
190 break;
191 }
192 }
193 }
194
195 void
196 DEFUN (lang_for_each_statement, (func),
197 void (*func) ())
198 {
199 lang_for_each_statement_worker (func,
200 statement_list.head);
201 }
202
203 /*----------------------------------------------------------------------*/
204 void
205 DEFUN (lang_list_init, (list),
206 lang_statement_list_type * list)
207 {
208 list->head = (lang_statement_union_type *) NULL;
209 list->tail = &list->head;
210 }
211
212 /*----------------------------------------------------------------------
213
214 build a new statement node for the parse tree
215
216 */
217
218 static
219 lang_statement_union_type *
220 DEFUN (new_statement, (type, size, list),
221 enum statement_enum type AND
222 bfd_size_type size AND
223 lang_statement_list_type * list)
224 {
225 lang_statement_union_type *new = (lang_statement_union_type *)
226 stat_alloc (size);
227
228 new->header.type = type;
229 new->header.next = (lang_statement_union_type *) NULL;
230 lang_statement_append (list, new, &new->header.next);
231 return new;
232 }
233
234 /*
235 Build a new input file node for the language. There are several ways
236 in which we treat an input file, eg, we only look at symbols, or
237 prefix it with a -l etc.
238
239 We can be supplied with requests for input files more than once;
240 they may, for example be split over serveral lines like foo.o(.text)
241 foo.o(.data) etc, so when asked for a file we check that we havn't
242 got it already so we don't duplicate the bfd.
243
244 */
245 static lang_input_statement_type *
246 DEFUN (new_afile, (name, file_type, target),
247 CONST char *CONST name AND
248 CONST lang_input_file_enum_type file_type AND
249 CONST char *CONST target)
250 {
251
252 lang_input_statement_type *p = new_stat (lang_input_statement,
253 stat_ptr);
254
255 lang_has_input_file = true;
256 p->target = target;
257 p->complained = false;
258 switch (file_type)
259 {
260 case lang_input_file_is_symbols_only_enum:
261 p->filename = name;
262 p->is_archive = false;
263 p->real = true;
264 p->local_sym_name = name;
265 p->just_syms_flag = true;
266 p->search_dirs_flag = false;
267 break;
268 case lang_input_file_is_fake_enum:
269 p->filename = name;
270 p->is_archive = false;
271 p->real = false;
272 p->local_sym_name = name;
273 p->just_syms_flag = false;
274 p->search_dirs_flag = false;
275 break;
276 case lang_input_file_is_l_enum:
277 p->is_archive = true;
278 p->filename = name;
279 p->real = true;
280 p->local_sym_name = concat ("-l", name, "");
281 p->just_syms_flag = false;
282 p->search_dirs_flag = true;
283 break;
284 case lang_input_file_is_search_file_enum:
285 case lang_input_file_is_marker_enum:
286 p->filename = name;
287 p->is_archive = false;
288 p->real = true;
289 p->local_sym_name = name;
290 p->just_syms_flag = false;
291 p->search_dirs_flag = true;
292 break;
293 case lang_input_file_is_file_enum:
294 p->filename = name;
295 p->is_archive = false;
296 p->real = true;
297 p->local_sym_name = name;
298 p->just_syms_flag = false;
299 p->search_dirs_flag = false;
300 break;
301 default:
302 FAIL ();
303 }
304 p->asymbols = (asymbol **) NULL;
305 p->superfile = (lang_input_statement_type *) NULL;
306 p->next_real_file = (lang_statement_union_type *) NULL;
307 p->next = (lang_statement_union_type *) NULL;
308 p->symbol_count = 0;
309 p->common_output_section = (asection *) NULL;
310 lang_statement_append (&input_file_chain,
311 (lang_statement_union_type *) p,
312 &p->next_real_file);
313 return p;
314 }
315
316 lang_input_statement_type *
317 DEFUN (lang_add_input_file, (name, file_type, target),
318 CONST char *name AND
319 lang_input_file_enum_type file_type AND
320 CONST char *target)
321 {
322 /* Look it up or build a new one */
323 lang_has_input_file = true;
324 #if 0
325 lang_input_statement_type *p;
326
327 for (p = (lang_input_statement_type *) input_file_chain.head;
328 p != (lang_input_statement_type *) NULL;
329 p = (lang_input_statement_type *) (p->next_real_file))
330 {
331 /* Sometimes we have incomplete entries in here */
332 if (p->filename != (char *) NULL)
333 {
334 if (strcmp (name, p->filename) == 0)
335 return p;
336 }
337
338 }
339 #endif
340 return new_afile (name, file_type, target);
341 }
342
343 /* Build enough state so that the parser can build its tree */
344 void
345 DEFUN_VOID (lang_init)
346 {
347 obstack_begin (&stat_obstack, 1000);
348
349 stat_ptr = &statement_list;
350
351 lang_list_init (stat_ptr);
352
353 lang_list_init (&input_file_chain);
354 lang_list_init (&lang_output_section_statement);
355 lang_list_init (&file_chain);
356 first_file = lang_add_input_file ((char *) NULL,
357 lang_input_file_is_marker_enum,
358 (char *) NULL);
359 abs_output_section = lang_output_section_statement_lookup (BFD_ABS_SECTION_NAME);
360
361 abs_output_section->bfd_section = &bfd_abs_section;
362
363 }
364
365 /*----------------------------------------------------------------------
366 A region is an area of memory declared with the
367 MEMORY { name:org=exp, len=exp ... }
368 syntax.
369
370 We maintain a list of all the regions here
371
372 If no regions are specified in the script, then the default is used
373 which is created when looked up to be the entire data space
374 */
375
376 static lang_memory_region_type *lang_memory_region_list;
377 static lang_memory_region_type **lang_memory_region_list_tail = &lang_memory_region_list;
378
379 lang_memory_region_type *
380 DEFUN (lang_memory_region_lookup, (name),
381 CONST char *CONST name)
382 {
383
384 lang_memory_region_type *p = lang_memory_region_list;
385
386 for (p = lang_memory_region_list;
387 p != (lang_memory_region_type *) NULL;
388 p = p->next)
389 {
390 if (strcmp (p->name, name) == 0)
391 {
392 return p;
393 }
394 }
395 if (strcmp (name, "*default*") == 0)
396 {
397 /* This is the default region, dig out first one on the list */
398 if (lang_memory_region_list != (lang_memory_region_type *) NULL)
399 {
400 return lang_memory_region_list;
401 }
402 }
403 {
404 lang_memory_region_type *new =
405 (lang_memory_region_type *) stat_alloc ((bfd_size_type) (sizeof (lang_memory_region_type)));
406
407 new->name = buystring (name);
408 new->next = (lang_memory_region_type *) NULL;
409
410 *lang_memory_region_list_tail = new;
411 lang_memory_region_list_tail = &new->next;
412 new->origin = 0;
413 new->length = ~0;
414 new->current = 0;
415 new->had_full_message = false;
416
417 return new;
418 }
419 }
420
421
422 lang_output_section_statement_type *
423 DEFUN (lang_output_section_find, (name),
424 CONST char *CONST name)
425 {
426 lang_statement_union_type *u;
427 lang_output_section_statement_type *lookup;
428
429 for (u = lang_output_section_statement.head;
430 u != (lang_statement_union_type *) NULL;
431 u = lookup->next)
432 {
433 lookup = &u->output_section_statement;
434 if (strcmp (name, lookup->name) == 0)
435 {
436 return lookup;
437 }
438 }
439 return (lang_output_section_statement_type *) NULL;
440 }
441
442 lang_output_section_statement_type *
443 DEFUN (lang_output_section_statement_lookup, (name),
444 CONST char *CONST name)
445 {
446 lang_output_section_statement_type *lookup;
447
448 lookup = lang_output_section_find (name);
449 if (lookup == (lang_output_section_statement_type *) NULL)
450 {
451
452 lookup = (lang_output_section_statement_type *)
453 new_stat (lang_output_section_statement, stat_ptr);
454 lookup->region = (lang_memory_region_type *) NULL;
455 lookup->fill = 0;
456 lookup->block_value = 1;
457 lookup->name = name;
458
459 lookup->next = (lang_statement_union_type *) NULL;
460 lookup->bfd_section = (asection *) NULL;
461 lookup->processed = false;
462 lookup->addr_tree = (etree_type *) NULL;
463 lang_list_init (&lookup->children);
464
465 lang_statement_append (&lang_output_section_statement,
466 (lang_statement_union_type *) lookup,
467 &lookup->next);
468 }
469 return lookup;
470 }
471
472 /*ARGSUSED*/
473 static void
474 DEFUN (print_flags, (ignore_flags),
475 int *ignore_flags)
476 {
477 fprintf (config.map_file, "(");
478 #if 0
479 if (flags->flag_read)
480 fprintf (outfile, "R");
481 if (flags->flag_write)
482 fprintf (outfile, "W");
483 if (flags->flag_executable)
484 fprintf (outfile, "X");
485 if (flags->flag_loadable)
486 fprintf (outfile, "L");
487 #endif
488 fprintf (config.map_file, ")");
489 }
490
491 void
492 DEFUN_VOID (lang_map)
493 {
494 lang_memory_region_type *m;
495
496 fprintf (config.map_file, "**MEMORY CONFIGURATION**\n\n");
497 #ifdef HOST_64_BIT
498 fprintf (config.map_file, "name\t\torigin\t\tlength\t\tattributes\n");
499 #else
500 fprintf (config.map_file, "name\t\torigin length\t\tattributes\n");
501 #endif
502 for (m = lang_memory_region_list;
503 m != (lang_memory_region_type *) NULL;
504 m = m->next)
505 {
506 fprintf (config.map_file, "%-16s", m->name);
507 print_address (m->origin);
508 print_space ();
509 print_address (m->length);
510 print_space ();
511 print_flags (&m->flags);
512 fprintf (config.map_file, "\n");
513 }
514 fprintf (config.map_file, "\n\n**LINK EDITOR MEMORY MAP**\n\n");
515 fprintf (config.map_file, "output input virtual\n");
516 fprintf (config.map_file, "section section address tsize\n\n");
517
518 print_statements ();
519
520 }
521
522 /*
523 *
524 */
525 static void
526 DEFUN (init_os, (s),
527 lang_output_section_statement_type * s)
528 {
529 /* asection *section = bfd_get_section_by_name(output_bfd, s->name);*/
530 section_userdata_type *new =
531 (section_userdata_type *)
532 stat_alloc ((bfd_size_type) (sizeof (section_userdata_type)));
533
534 s->bfd_section = bfd_get_section_by_name (output_bfd, s->name);
535 if (s->bfd_section == (asection *) NULL)
536 s->bfd_section = bfd_make_section (output_bfd, s->name);
537 if (s->bfd_section == (asection *) NULL)
538 {
539 einfo ("%P%F output format %s cannot represent section called %s\n",
540 output_bfd->xvec->name, s->name);
541 }
542 s->bfd_section->output_section = s->bfd_section;
543 /* s->bfd_section->flags = s->flags;*/
544
545 /* We initialize an output sections output offset to minus its own */
546 /* vma to allow us to output a section through itself */
547 s->bfd_section->output_offset = 0;
548 get_userdata (s->bfd_section) = (PTR) new;
549
550 }
551
552 /***********************************************************************
553 The wild routines.
554
555 These expand statements like *(.text) and foo.o to a list of
556 explicit actions, like foo.o(.text), bar.o(.text) and
557 foo.o(.text,.data) .
558
559 The toplevel routine, wild, takes a statement, section, file and
560 target. If either the section or file is null it is taken to be the
561 wildcard. Seperate lang_input_section statements are created for
562 each part of the expanstion, and placed after the statement provided.
563
564 */
565
566 static void
567 DEFUN (wild_doit, (ptr, section, output, file),
568 lang_statement_list_type * ptr AND
569 asection * section AND
570 lang_output_section_statement_type * output AND
571 lang_input_statement_type * file)
572 {
573 if (output->bfd_section == (asection *) NULL)
574 {
575 init_os (output);
576 }
577
578 if (section != (asection *) NULL
579 && section->output_section == (asection *) NULL)
580 {
581 /* Add a section reference to the list */
582 lang_input_section_type *new = new_stat (lang_input_section, ptr);
583
584 new->section = section;
585 new->ifile = file;
586 section->output_section = output->bfd_section;
587 section->output_section->flags |= section->flags;
588 if (section->alignment_power > output->bfd_section->alignment_power)
589 {
590 output->bfd_section->alignment_power = section->alignment_power;
591 }
592 }
593 }
594
595 static asection *
596 DEFUN (our_bfd_get_section_by_name, (abfd, section),
597 bfd * abfd AND
598 CONST char *section)
599 {
600 return bfd_get_section_by_name (abfd, section);
601 }
602
603 static void
604 DEFUN (wild_section, (ptr, section, file, output),
605 lang_wild_statement_type * ptr AND
606 CONST char *section AND
607 lang_input_statement_type * file AND
608 lang_output_section_statement_type * output)
609 {
610 asection *s;
611
612 if (file->just_syms_flag == false)
613 {
614 if (section == (char *) NULL)
615 {
616 /* Do the creation to all sections in the file */
617 for (s = file->the_bfd->sections; s != (asection *) NULL; s = s->next)
618 {
619 wild_doit (&ptr->children, s, output, file);
620 }
621 }
622 else
623 {
624 /* Do the creation to the named section only */
625 wild_doit (&ptr->children,
626 our_bfd_get_section_by_name (file->the_bfd, section),
627 output, file);
628 }
629 }
630 }
631
632 /* passed a file name (which must have been seen already and added to
633 the statement tree. We will see if it has been opened already and
634 had its symbols read. If not then we'll read it.
635
636 Archives are pecuilar here. We may open them once, but if they do
637 not define anything we need at the time, they won't have all their
638 symbols read. If we need them later, we'll have to redo it.
639 */
640 static
641 lang_input_statement_type *
642 DEFUN (lookup_name, (name),
643 CONST char *CONST name)
644 {
645 lang_input_statement_type *search;
646
647 for (search = (lang_input_statement_type *) input_file_chain.head;
648 search != (lang_input_statement_type *) NULL;
649 search = (lang_input_statement_type *) search->next_real_file)
650 {
651 if (search->filename == (char *) NULL && name == (char *) NULL)
652 {
653 return search;
654 }
655 if (search->filename != (char *) NULL && name != (char *) NULL)
656 {
657 if (strcmp (search->filename, name) == 0)
658 {
659 ldmain_open_file_read_symbol (search);
660 return search;
661 }
662 }
663 }
664
665 /* There isn't an afile entry for this file yet, this must be
666 because the name has only appeared inside a load script and not
667 on the command line */
668 search = new_afile (name, lang_input_file_is_file_enum, default_target);
669 ldmain_open_file_read_symbol (search);
670 return search;
671
672
673 }
674
675 static void
676 DEFUN (wild, (s, section, file, target, output),
677 lang_wild_statement_type * s AND
678 CONST char *CONST section AND
679 CONST char *CONST file AND
680 CONST char *CONST target AND
681 lang_output_section_statement_type * output)
682 {
683 lang_input_statement_type *f;
684
685 if (file == (char *) NULL)
686 {
687 /* Perform the iteration over all files in the list */
688 for (f = (lang_input_statement_type *) file_chain.head;
689 f != (lang_input_statement_type *) NULL;
690 f = (lang_input_statement_type *) f->next)
691 {
692 wild_section (s, section, f, output);
693 }
694 }
695 else
696 {
697 /* Perform the iteration over a single file */
698 wild_section (s, section, lookup_name (file), output);
699 }
700 if (section != (char *) NULL
701 && strcmp (section, "COMMON") == 0
702 && default_common_section == (lang_output_section_statement_type *) NULL)
703 {
704 /* Remember the section that common is going to incase we later
705 get something which doesn't know where to put it */
706 default_common_section = output;
707 }
708 }
709
710 /*
711 read in all the files
712 */
713 static bfd *
714 DEFUN (open_output, (name),
715 CONST char *CONST name)
716 {
717 extern CONST char *output_filename;
718 bfd *output;
719
720 if (output_target == (char *) NULL)
721 {
722 if (current_target != (char *) NULL)
723 output_target = current_target;
724 else
725 output_target = default_target;
726 }
727 output = bfd_openw (name, output_target);
728 output_filename = name;
729
730 if (output == (bfd *) NULL)
731 {
732 if (bfd_error == invalid_target)
733 {
734 einfo ("%P%F target %s not found\n", output_target);
735 }
736 einfo ("%P%F problem opening output file %s, %E", name);
737 }
738
739 /* output->flags |= D_PAGED;*/
740 bfd_set_format (output, bfd_object);
741 return output;
742 }
743
744
745
746
747 static void
748 DEFUN (ldlang_open_output, (statement),
749 lang_statement_union_type * statement)
750 {
751 switch (statement->header.type)
752 {
753 case lang_output_statement_enum:
754 output_bfd = open_output (statement->output_statement.name);
755 ldemul_set_output_arch ();
756 if (config.magic_demand_paged && !config.relocateable_output)
757 output_bfd->flags |= D_PAGED;
758 else
759 output_bfd->flags &= ~D_PAGED;
760 if (config.text_read_only)
761 output_bfd->flags |= WP_TEXT;
762 else
763 output_bfd->flags &= ~WP_TEXT;
764 break;
765
766 case lang_target_statement_enum:
767 current_target = statement->target_statement.target;
768 break;
769 default:
770 break;
771 }
772 }
773
774 static void
775 DEFUN (open_input_bfds, (statement),
776 lang_statement_union_type * statement)
777 {
778 switch (statement->header.type)
779 {
780 case lang_target_statement_enum:
781 current_target = statement->target_statement.target;
782 break;
783 case lang_wild_statement_enum:
784 /* Maybe we should load the file's symbols */
785 if (statement->wild_statement.filename)
786 {
787 (void) lookup_name (statement->wild_statement.filename);
788 }
789 break;
790 case lang_input_statement_enum:
791 if (statement->input_statement.real == true)
792 {
793 statement->input_statement.target = current_target;
794 lookup_name (statement->input_statement.filename);
795 }
796 break;
797 default:
798 break;
799 }
800 }
801
802 /* If there are [COMMONS] statements, put a wild one into the bss section */
803
804 static void
805 lang_reasonable_defaults ()
806 {
807
808
809
810 #if 0
811 lang_output_section_statement_lookup (".text");
812 lang_output_section_statement_lookup (".data");
813
814 default_common_section =
815 lang_output_section_statement_lookup (".bss");
816
817
818 if (placed_commons == false)
819 {
820 lang_wild_statement_type *new =
821 new_stat (lang_wild_statement,
822 &default_common_section->children);
823
824 new->section_name = "COMMON";
825 new->filename = (char *) NULL;
826 lang_list_init (&new->children);
827 }
828 #endif
829
830 }
831
832 /*
833 Add the supplied name to the symbol table as an undefined reference.
834 Remove items from the chain as we open input bfds
835 */
836 typedef struct ldlang_undef_chain_list
837 {
838 struct ldlang_undef_chain_list *next;
839 char *name;
840 } ldlang_undef_chain_list_type;
841
842 static ldlang_undef_chain_list_type *ldlang_undef_chain_list_head;
843
844 void
845 DEFUN (ldlang_add_undef, (name),
846 CONST char *CONST name)
847 {
848 ldlang_undef_chain_list_type *new =
849 (ldlang_undef_chain_list_type
850 *) stat_alloc ((bfd_size_type) (sizeof (ldlang_undef_chain_list_type)));
851
852 new->next = ldlang_undef_chain_list_head;
853 ldlang_undef_chain_list_head = new;
854
855 new->name = buystring (name);
856 }
857
858 /* Run through the list of undefineds created above and place them
859 into the linker hash table as undefined symbols belonging to the
860 script file.
861 */
862 static void
863 DEFUN_VOID (lang_place_undefineds)
864 {
865 ldlang_undef_chain_list_type *ptr = ldlang_undef_chain_list_head;
866
867 while (ptr != (ldlang_undef_chain_list_type *) NULL)
868 {
869 asymbol *def;
870 asymbol **def_ptr = (asymbol **) stat_alloc ((bfd_size_type) (sizeof (asymbol **)));
871
872 def = (asymbol *) bfd_make_empty_symbol (script_file->the_bfd);
873 *def_ptr = def;
874 def->name = ptr->name;
875 def->section = &bfd_und_section;
876 Q_enter_global_ref (def_ptr, ptr->name);
877 ptr = ptr->next;
878 }
879 }
880
881 /* Copy important data from out internal form to the bfd way. Also
882 create a section for the dummy file
883 */
884
885 static void
886 DEFUN_VOID (lang_create_output_section_statements)
887 {
888 lang_statement_union_type *os;
889
890 for (os = lang_output_section_statement.head;
891 os != (lang_statement_union_type *) NULL;
892 os = os->output_section_statement.next)
893 {
894 lang_output_section_statement_type *s =
895 &os->output_section_statement;
896
897 init_os (s);
898 }
899
900 }
901
902 static void
903 DEFUN_VOID (lang_init_script_file)
904 {
905 script_file = lang_add_input_file ("script file",
906 lang_input_file_is_fake_enum,
907 (char *) NULL);
908 script_file->the_bfd = bfd_create ("script file", output_bfd);
909 script_file->symbol_count = 0;
910 script_file->the_bfd->sections = output_bfd->sections;
911 abs_output_section = lang_output_section_statement_lookup (BFD_ABS_SECTION_NAME);
912
913 abs_output_section->bfd_section = &bfd_abs_section;
914
915 }
916
917 /* Open input files and attatch to output sections */
918 static void
919 DEFUN (map_input_to_output_sections, (s, target, output_section_statement),
920 lang_statement_union_type * s AND
921 CONST char *target AND
922 lang_output_section_statement_type * output_section_statement)
923 {
924 for (; s != (lang_statement_union_type *) NULL; s = s->next)
925 {
926 switch (s->header.type)
927 {
928
929
930 case lang_wild_statement_enum:
931 wild (&s->wild_statement, s->wild_statement.section_name,
932 s->wild_statement.filename, target,
933 output_section_statement);
934
935 break;
936 case lang_constructors_statement_enum:
937 map_input_to_output_sections (constructor_list.head,
938 target,
939 output_section_statement);
940 break;
941 case lang_output_section_statement_enum:
942 map_input_to_output_sections (s->output_section_statement.children.head,
943 target,
944 &s->output_section_statement);
945 break;
946 case lang_output_statement_enum:
947 break;
948 case lang_target_statement_enum:
949 target = s->target_statement.target;
950 break;
951 case lang_fill_statement_enum:
952 case lang_input_section_enum:
953 case lang_object_symbols_statement_enum:
954 case lang_data_statement_enum:
955 case lang_assignment_statement_enum:
956 case lang_padding_statement_enum:
957 break;
958 case lang_afile_asection_pair_statement_enum:
959 FAIL ();
960 break;
961 case lang_address_statement_enum:
962 /* Mark the specified section with the supplied address */
963 {
964 lang_output_section_statement_type *os =
965 lang_output_section_statement_lookup
966 (s->address_statement.section_name);
967
968 os->addr_tree = s->address_statement.address;
969 if (os->bfd_section == (asection *) NULL)
970 {
971 einfo ("%P%F can't set the address of undefined section %s\n",
972 s->address_statement.section_name);
973 }
974 }
975 break;
976 case lang_input_statement_enum:
977 /* A standard input statement, has no wildcards */
978 /* ldmain_open_file_read_symbol(&s->input_statement);*/
979 break;
980 }
981 }
982 }
983
984
985
986
987
988 static void
989 DEFUN (print_output_section_statement, (output_section_statement),
990 lang_output_section_statement_type * output_section_statement)
991 {
992 asection *section = output_section_statement->bfd_section;
993
994 print_nl ();
995 print_section (output_section_statement->name);
996
997 if (section)
998 {
999 print_dot = section->vma;
1000 print_space ();
1001 print_section ("");
1002 print_space ();
1003 print_address (section->vma);
1004 print_space ();
1005 print_size (bfd_get_section_size_before_reloc (section));
1006 print_space ();
1007 print_alignment (section->alignment_power);
1008 print_space ();
1009 #if 0
1010 fprintf (config.map_file, "%s flags", output_section_statement->region->name);
1011 print_flags (stdout, &output_section_statement->flags);
1012 #endif
1013 if (section->flags & SEC_LOAD)
1014 fprintf (config.map_file, "load ");
1015 if (section->flags & SEC_ALLOC)
1016 fprintf (config.map_file, "alloc ");
1017 if (section->flags & SEC_RELOC)
1018 fprintf (config.map_file, "reloc ");
1019 if (section->flags & SEC_HAS_CONTENTS)
1020 fprintf (config.map_file, "contents ");
1021
1022 }
1023 else
1024 {
1025 fprintf (config.map_file, "No attached output section");
1026 }
1027 print_nl ();
1028 print_statement (output_section_statement->children.head,
1029 output_section_statement);
1030
1031 }
1032
1033 static void
1034 DEFUN (print_assignment, (assignment, output_section),
1035 lang_assignment_statement_type * assignment AND
1036 lang_output_section_statement_type * output_section)
1037 {
1038 etree_value_type result;
1039
1040 print_section ("");
1041 print_space ();
1042 print_section ("");
1043 print_space ();
1044 print_address (print_dot);
1045 print_space ();
1046 result = exp_fold_tree (assignment->exp->assign.src,
1047 output_section,
1048 lang_final_phase_enum,
1049 print_dot,
1050 &print_dot);
1051
1052 if (result.valid)
1053 {
1054 print_address (result.value);
1055 }
1056 else
1057 {
1058 fprintf (config.map_file, "*undefined*");
1059 }
1060 print_space ();
1061 exp_print_tree (assignment->exp);
1062
1063 fprintf (config.map_file, "\n");
1064 }
1065
1066 static void
1067 DEFUN (print_input_statement, (statm),
1068 lang_input_statement_type * statm)
1069 {
1070 if (statm->filename != (char *) NULL)
1071 {
1072 fprintf (config.map_file, "LOAD %s\n", statm->filename);
1073 }
1074 }
1075
1076 static void
1077 DEFUN (print_symbol, (q),
1078 asymbol * q)
1079 {
1080 print_section ("");
1081 fprintf (config.map_file, " ");
1082 print_section ("");
1083 fprintf (config.map_file, " ");
1084 print_address (outside_symbol_address (q));
1085 fprintf (config.map_file, " %s", q->name ? q->name : " ");
1086 print_nl ();
1087 }
1088
1089 static void
1090 DEFUN (print_input_section, (in),
1091 lang_input_section_type * in)
1092 {
1093 asection *i = in->section;
1094 int size = i->reloc_done ?
1095 bfd_get_section_size_after_reloc (i) :
1096 bfd_get_section_size_before_reloc (i);
1097
1098 if (size != 0)
1099 {
1100 print_section ("");
1101 fprintf (config.map_file, " ");
1102 print_section (i->name);
1103 fprintf (config.map_file, " ");
1104 if (i->output_section)
1105 {
1106 print_address (i->output_section->vma + i->output_offset);
1107 fprintf (config.map_file, " ");
1108 print_size (size);
1109 fprintf (config.map_file, " ");
1110 print_alignment (i->alignment_power);
1111 fprintf (config.map_file, " ");
1112 if (in->ifile)
1113 {
1114
1115 bfd *abfd = in->ifile->the_bfd;
1116
1117 if (in->ifile->just_syms_flag == true)
1118 {
1119 fprintf (config.map_file, "symbols only ");
1120 }
1121
1122 fprintf (config.map_file, " %s ", abfd->xvec->name);
1123 if (abfd->my_archive != (bfd *) NULL)
1124 {
1125 fprintf (config.map_file, "[%s]%s", abfd->my_archive->filename,
1126 abfd->filename);
1127 }
1128 else
1129 {
1130 fprintf (config.map_file, "%s", abfd->filename);
1131 }
1132 fprintf (config.map_file, "(overhead %d bytes)", (int) bfd_alloc_size (abfd));
1133 print_nl ();
1134
1135 /* Find all the symbols in this file defined in this section */
1136
1137 if (in->ifile->symbol_count)
1138 {
1139 asymbol **p;
1140
1141 for (p = in->ifile->asymbols; *p; p++)
1142 {
1143 asymbol *q = *p;
1144
1145 if (bfd_get_section (q) == i && q->flags & BSF_GLOBAL)
1146 {
1147 print_symbol (q);
1148 }
1149 }
1150 }
1151 }
1152 else
1153 {
1154 print_nl ();
1155 }
1156
1157
1158 print_dot = outside_section_address (i) + size;
1159 }
1160 else
1161 {
1162 fprintf (config.map_file, "No output section allocated\n");
1163 }
1164 }
1165 }
1166
1167 static void
1168 DEFUN (print_fill_statement, (fill),
1169 lang_fill_statement_type * fill)
1170 {
1171 fprintf (config.map_file, "FILL mask ");
1172 print_fill (fill->fill);
1173 }
1174
1175 static void
1176 DEFUN (print_data_statement, (data),
1177 lang_data_statement_type * data)
1178 {
1179 /* bfd_vma value; */
1180 print_section ("");
1181 print_space ();
1182 print_section ("");
1183 print_space ();
1184 /* ASSERT(print_dot == data->output_vma);*/
1185
1186 print_address (data->output_vma + data->output_section->vma);
1187 print_space ();
1188 print_address (data->value);
1189 print_space ();
1190 switch (data->type)
1191 {
1192 case BYTE:
1193 fprintf (config.map_file, "BYTE ");
1194 print_dot += BYTE_SIZE;
1195 break;
1196 case SHORT:
1197 fprintf (config.map_file, "SHORT ");
1198 print_dot += SHORT_SIZE;
1199 break;
1200 case LONG:
1201 fprintf (config.map_file, "LONG ");
1202 print_dot += LONG_SIZE;
1203 break;
1204 }
1205
1206 exp_print_tree (data->exp);
1207
1208 fprintf (config.map_file, "\n");
1209 }
1210
1211
1212 static void
1213 DEFUN (print_padding_statement, (s),
1214 lang_padding_statement_type * s)
1215 {
1216 print_section ("");
1217 print_space ();
1218 print_section ("*fill*");
1219 print_space ();
1220 print_address (s->output_offset + s->output_section->vma);
1221 print_space ();
1222 print_size (s->size);
1223 print_space ();
1224 print_fill (s->fill);
1225 print_nl ();
1226
1227 print_dot = s->output_offset + s->output_section->vma + s->size;
1228
1229 }
1230
1231 static void
1232 DEFUN (print_wild_statement, (w, os),
1233 lang_wild_statement_type * w AND
1234 lang_output_section_statement_type * os)
1235 {
1236 fprintf (config.map_file, " from ");
1237 if (w->filename != (char *) NULL)
1238 {
1239 fprintf (config.map_file, "%s", w->filename);
1240 }
1241 else
1242 {
1243 fprintf (config.map_file, "*");
1244 }
1245 if (w->section_name != (char *) NULL)
1246 {
1247 fprintf (config.map_file, "(%s)", w->section_name);
1248 }
1249 else
1250 {
1251 fprintf (config.map_file, "(*)");
1252 }
1253 print_nl ();
1254 print_statement (w->children.head, os);
1255
1256 }
1257 static void
1258 DEFUN (print_statement, (s, os),
1259 lang_statement_union_type * s AND
1260 lang_output_section_statement_type * os)
1261 {
1262 while (s)
1263 {
1264 switch (s->header.type)
1265 {
1266 case lang_constructors_statement_enum:
1267 fprintf (config.map_file, "constructors:\n");
1268 print_statement (constructor_list.head, os);
1269 break;
1270 case lang_wild_statement_enum:
1271 print_wild_statement (&s->wild_statement, os);
1272 break;
1273 default:
1274 fprintf (config.map_file, "Fail with %d\n", s->header.type);
1275 FAIL ();
1276 break;
1277 case lang_address_statement_enum:
1278 fprintf (config.map_file, "address\n");
1279 break;
1280 case lang_object_symbols_statement_enum:
1281 fprintf (config.map_file, "object symbols\n");
1282 break;
1283 case lang_fill_statement_enum:
1284 print_fill_statement (&s->fill_statement);
1285 break;
1286 case lang_data_statement_enum:
1287 print_data_statement (&s->data_statement);
1288 break;
1289 case lang_input_section_enum:
1290 print_input_section (&s->input_section);
1291 break;
1292 case lang_padding_statement_enum:
1293 print_padding_statement (&s->padding_statement);
1294 break;
1295 case lang_output_section_statement_enum:
1296 print_output_section_statement (&s->output_section_statement);
1297 break;
1298 case lang_assignment_statement_enum:
1299 print_assignment (&s->assignment_statement,
1300 os);
1301 break;
1302 case lang_target_statement_enum:
1303 fprintf (config.map_file, "TARGET(%s)\n", s->target_statement.target);
1304 break;
1305 case lang_output_statement_enum:
1306 fprintf (config.map_file, "OUTPUT(%s %s)\n",
1307 s->output_statement.name,
1308 output_target);
1309 break;
1310 case lang_input_statement_enum:
1311 print_input_statement (&s->input_statement);
1312 break;
1313 case lang_afile_asection_pair_statement_enum:
1314 FAIL ();
1315 break;
1316 }
1317 s = s->next;
1318 }
1319 }
1320
1321
1322 static void
1323 DEFUN_VOID (print_statements)
1324 {
1325 print_statement (statement_list.head,
1326 abs_output_section);
1327
1328 }
1329
1330 static bfd_vma
1331 DEFUN (insert_pad, (this_ptr, fill, power, output_section_statement, dot),
1332 lang_statement_union_type ** this_ptr AND
1333 fill_type fill AND
1334 unsigned int power AND
1335 asection * output_section_statement AND
1336 bfd_vma dot)
1337 {
1338 /* Align this section first to the
1339 input sections requirement, then
1340 to the output section's requirement.
1341 If this alignment is > than any seen before,
1342 then record it too. Perform the alignment by
1343 inserting a magic 'padding' statement.
1344 */
1345
1346 unsigned int alignment_needed = align_power (dot, power) - dot;
1347
1348 if (alignment_needed != 0)
1349 {
1350 lang_statement_union_type *new =
1351 (lang_statement_union_type *)
1352 stat_alloc ((bfd_size_type) (sizeof (lang_padding_statement_type)));
1353
1354 /* Link into existing chain */
1355 new->header.next = *this_ptr;
1356 *this_ptr = new;
1357 new->header.type = lang_padding_statement_enum;
1358 new->padding_statement.output_section = output_section_statement;
1359 new->padding_statement.output_offset =
1360 dot - output_section_statement->vma;
1361 new->padding_statement.fill = fill;
1362 new->padding_statement.size = alignment_needed;
1363 }
1364
1365
1366 /* Remember the most restrictive alignment */
1367 if (power > output_section_statement->alignment_power)
1368 {
1369 output_section_statement->alignment_power = power;
1370 }
1371 output_section_statement->_raw_size += alignment_needed;
1372 return alignment_needed + dot;
1373
1374 }
1375
1376 /* Work out how much this section will move the dot point */
1377 static bfd_vma
1378 DEFUN (size_input_section, (this_ptr, output_section_statement, fill, dot),
1379 lang_statement_union_type ** this_ptr AND
1380 lang_output_section_statement_type * output_section_statement AND
1381 unsigned short fill AND
1382 bfd_vma dot)
1383 {
1384 lang_input_section_type *is = &((*this_ptr)->input_section);
1385 asection *i = is->section;
1386
1387 if (is->ifile->just_syms_flag == false)
1388 {
1389 dot = insert_pad (this_ptr, fill, i->alignment_power,
1390 output_section_statement->bfd_section, dot);
1391
1392 /* remember the largest size so we can malloc the largest area
1393 needed for the output stage. Only remember the size of sections
1394 which we will actually allocate */
1395 if (((i->flags &
1396 (SEC_HAS_CONTENTS | SEC_LOAD)) == (SEC_HAS_CONTENTS | SEC_LOAD))
1397 && (bfd_get_section_size_before_reloc (i) > largest_section))
1398 {
1399 largest_section = bfd_get_section_size_before_reloc (i);
1400 }
1401
1402 /* Remember where in the output section this input section goes */
1403
1404 i->output_offset = dot - output_section_statement->bfd_section->vma;
1405
1406 /* Mark how big the output section must be to contain this now */
1407 dot += bfd_get_section_size_before_reloc (i);
1408 output_section_statement->bfd_section->_raw_size =
1409 dot - output_section_statement->bfd_section->vma;
1410 }
1411 else
1412 {
1413 i->output_offset = i->vma - output_section_statement->bfd_section->vma;
1414 }
1415
1416 return dot;
1417 }
1418
1419 /* Sizing happens in two passes, first pass we allocate worst case
1420 stuff. The second pass (if relaxing), we use what we learnt to
1421 change the size of some relocs from worst case to better
1422 */
1423 static boolean had_relax;
1424
1425 static bfd_vma
1426 DEFUN (lang_size_sections, (s, output_section_statement, prev, fill,
1427 dot, relax),
1428 lang_statement_union_type * s AND
1429 lang_output_section_statement_type * output_section_statement AND
1430 lang_statement_union_type ** prev AND
1431 unsigned short fill AND
1432 bfd_vma dot AND
1433 boolean relax)
1434 {
1435 /* Size up the sections from their constituent parts */
1436 for (; s != (lang_statement_union_type *) NULL; s = s->next)
1437 {
1438 switch (s->header.type)
1439 {
1440
1441 case lang_output_section_statement_enum:
1442 {
1443 bfd_vma after;
1444 lang_output_section_statement_type *os = &s->output_section_statement;
1445
1446 if (os->bfd_section == &bfd_abs_section)
1447 {
1448 /* No matter what happens, an abs section starts at zero */
1449 os->bfd_section->vma = 0;
1450 }
1451 else
1452 {
1453 if (os->addr_tree == (etree_type *) NULL)
1454 {
1455 /* No address specified for this section, get one
1456 from the region specification
1457 */
1458 if (os->region == (lang_memory_region_type *) NULL)
1459 {
1460 os->region = lang_memory_region_lookup ("*default*");
1461 }
1462 dot = os->region->current;
1463 }
1464 else
1465 {
1466 etree_value_type r;
1467
1468 r = exp_fold_tree (os->addr_tree,
1469 abs_output_section,
1470 lang_allocating_phase_enum,
1471 dot, &dot);
1472 if (r.valid == false)
1473 {
1474 einfo ("%F%S: non constant address expression for section %s\n",
1475 os->name);
1476 }
1477 dot = r.value;
1478 }
1479 /* The section starts here */
1480 /* First, align to what the section needs */
1481
1482
1483 dot = align_power (dot, os->bfd_section->alignment_power);
1484 os->bfd_section->vma = dot;
1485 }
1486
1487
1488 os->bfd_section->output_offset = 0;
1489
1490 (void) lang_size_sections (os->children.head, os, &os->children.head,
1491 os->fill, dot, relax);
1492 /* Ignore the size of the input sections, use the vma and size to */
1493 /* align against */
1494
1495
1496 after = ALIGN (os->bfd_section->vma +
1497 os->bfd_section->_raw_size,
1498 os->block_value);
1499
1500
1501 os->bfd_section->_raw_size = after - os->bfd_section->vma;
1502 dot = os->bfd_section->vma + os->bfd_section->_raw_size;
1503 os->processed = true;
1504
1505 /* Replace into region ? */
1506 if (os->addr_tree == (etree_type *) NULL
1507 && os->region != (lang_memory_region_type *) NULL)
1508 {
1509 os->region->current = dot;
1510 /* Make sure this isn't silly */
1511 if (os->region->current >
1512 os->region->origin +
1513 os->region->length)
1514 {
1515 einfo ("%X%P: Region %s is full (%B section %s)\n",
1516 os->region->name,
1517 os->bfd_section->owner,
1518 os->bfd_section->name);
1519 /* Reset the region pointer */
1520 os->region->current = 0;
1521
1522 }
1523
1524 }
1525 }
1526
1527 break;
1528 case lang_constructors_statement_enum:
1529 dot = lang_size_sections (constructor_list.head,
1530 output_section_statement,
1531 &s->wild_statement.children.head,
1532 fill,
1533 dot, relax);
1534 break;
1535
1536 case lang_data_statement_enum:
1537 {
1538 unsigned int size = 0;
1539
1540 s->data_statement.output_vma = dot - output_section_statement->bfd_section->vma;
1541 s->data_statement.output_section =
1542 output_section_statement->bfd_section;
1543
1544 switch (s->data_statement.type)
1545 {
1546 case LONG:
1547 size = LONG_SIZE;
1548 break;
1549 case SHORT:
1550 size = SHORT_SIZE;
1551 break;
1552 case BYTE:
1553 size = BYTE_SIZE;
1554 break;
1555
1556 }
1557 dot += size;
1558 output_section_statement->bfd_section->_raw_size += size;
1559 }
1560 break;
1561
1562 case lang_wild_statement_enum:
1563
1564 dot = lang_size_sections (s->wild_statement.children.head,
1565 output_section_statement,
1566 &s->wild_statement.children.head,
1567
1568 fill, dot, relax);
1569
1570 break;
1571
1572 case lang_object_symbols_statement_enum:
1573 create_object_symbols = output_section_statement;
1574 break;
1575 case lang_output_statement_enum:
1576 case lang_target_statement_enum:
1577 break;
1578 case lang_input_section_enum:
1579 if (relax)
1580 {
1581 relaxing = true;
1582
1583 had_relax = had_relax || relax_section (prev);
1584 relaxing = false;
1585
1586 }
1587
1588 dot = size_input_section (prev,
1589 output_section_statement,
1590 output_section_statement->fill, dot);
1591 break;
1592 case lang_input_statement_enum:
1593 break;
1594 case lang_fill_statement_enum:
1595 s->fill_statement.output_section = output_section_statement->bfd_section;
1596
1597 fill = s->fill_statement.fill;
1598 break;
1599 case lang_assignment_statement_enum:
1600 {
1601 bfd_vma newdot = dot;
1602
1603 exp_fold_tree (s->assignment_statement.exp,
1604 output_section_statement,
1605 lang_allocating_phase_enum,
1606 dot,
1607 &newdot);
1608
1609 if (newdot != dot && !relax)
1610 /* We've been moved ! so insert a pad */
1611 {
1612 lang_statement_union_type *new =
1613 (lang_statement_union_type *)
1614 stat_alloc ((bfd_size_type) (sizeof (lang_padding_statement_type)));
1615
1616 /* Link into existing chain */
1617 new->header.next = *prev;
1618 *prev = new;
1619 new->header.type = lang_padding_statement_enum;
1620 new->padding_statement.output_section =
1621 output_section_statement->bfd_section;
1622 new->padding_statement.output_offset =
1623 dot - output_section_statement->bfd_section->vma;
1624 new->padding_statement.fill = fill;
1625 new->padding_statement.size = newdot - dot;
1626 output_section_statement->bfd_section->_raw_size +=
1627 new->padding_statement.size;
1628 dot = newdot;
1629 }
1630 }
1631
1632 break;
1633 default:
1634 FAIL ();
1635 break;
1636 /* This can only get here when relaxing is turned on */
1637 case lang_padding_statement_enum:
1638
1639 case lang_address_statement_enum:
1640 break;
1641 }
1642 prev = &s->header.next;
1643 }
1644 return dot;
1645 }
1646
1647 static bfd_vma
1648 DEFUN (lang_do_assignments, (s, output_section_statement, fill, dot),
1649 lang_statement_union_type * s AND
1650 lang_output_section_statement_type * output_section_statement AND
1651 unsigned short fill AND
1652 bfd_vma dot)
1653 {
1654
1655 for (; s != (lang_statement_union_type *) NULL; s = s->next)
1656 {
1657 switch (s->header.type)
1658 {
1659 case lang_constructors_statement_enum:
1660 dot = lang_do_assignments (constructor_list.head,
1661 output_section_statement,
1662 fill,
1663 dot);
1664 break;
1665
1666 case lang_output_section_statement_enum:
1667 {
1668 lang_output_section_statement_type *os =
1669 &(s->output_section_statement);
1670
1671 dot = os->bfd_section->vma;
1672 (void) lang_do_assignments (os->children.head, os, os->fill, dot);
1673 dot = os->bfd_section->vma + os->bfd_section->_raw_size;
1674 }
1675 break;
1676 case lang_wild_statement_enum:
1677
1678 dot = lang_do_assignments (s->wild_statement.children.head,
1679 output_section_statement,
1680 fill, dot);
1681
1682 break;
1683
1684 case lang_object_symbols_statement_enum:
1685 case lang_output_statement_enum:
1686 case lang_target_statement_enum:
1687 #if 0
1688 case lang_common_statement_enum:
1689 #endif
1690 break;
1691 case lang_data_statement_enum:
1692 {
1693 etree_value_type value;
1694
1695 value = exp_fold_tree (s->data_statement.exp,
1696 abs_output_section,
1697 lang_final_phase_enum, dot, &dot);
1698 s->data_statement.value = value.value;
1699 if (value.valid == false)
1700 einfo ("%F%P: Invalid data statement\n");
1701 }
1702 switch (s->data_statement.type)
1703 {
1704 case LONG:
1705 dot += LONG_SIZE;
1706 break;
1707 case SHORT:
1708 dot += SHORT_SIZE;
1709 break;
1710 case BYTE:
1711 dot += BYTE_SIZE;
1712 break;
1713 }
1714 break;
1715 case lang_input_section_enum:
1716 {
1717 asection *in = s->input_section.section;
1718
1719 dot += bfd_get_section_size_before_reloc (in);
1720 }
1721 break;
1722
1723 case lang_input_statement_enum:
1724 break;
1725 case lang_fill_statement_enum:
1726 fill = s->fill_statement.fill;
1727 break;
1728 case lang_assignment_statement_enum:
1729 {
1730 exp_fold_tree (s->assignment_statement.exp,
1731 output_section_statement,
1732 lang_final_phase_enum,
1733 dot,
1734 &dot);
1735 }
1736
1737 break;
1738 case lang_padding_statement_enum:
1739 dot += s->padding_statement.size;
1740 break;
1741 default:
1742 FAIL ();
1743 break;
1744 case lang_address_statement_enum:
1745 break;
1746 }
1747
1748 }
1749 return dot;
1750 }
1751
1752
1753
1754 static void
1755 DEFUN_VOID (lang_relocate_globals)
1756 {
1757
1758 /*
1759 Each ldsym_type maintains a chain of pointers to asymbols which
1760 references the definition. Replace each pointer to the referenence
1761 with a pointer to only one place, preferably the definition. If
1762 the defintion isn't available then the common symbol, and if
1763 there isn't one of them then choose one reference.
1764 */
1765
1766 FOR_EACH_LDSYM (lgs)
1767 {
1768 asymbol *it;
1769
1770 if (lgs->sdefs_chain)
1771 {
1772 it = *(lgs->sdefs_chain);
1773 }
1774 else if (lgs->scoms_chain != (asymbol **) NULL)
1775 {
1776 it = *(lgs->scoms_chain);
1777 }
1778 else if (lgs->srefs_chain != (asymbol **) NULL)
1779 {
1780 it = *(lgs->srefs_chain);
1781 }
1782 else
1783 {
1784 /* This can happen when the command line asked for a symbol to
1785 be -u */
1786 it = (asymbol *) NULL;
1787 }
1788 if (it != (asymbol *) NULL)
1789 {
1790 asymbol **ptr = lgs->srefs_chain;;
1791 if (lgs->flags & SYM_WARNING)
1792 {
1793 produce_warnings (lgs, it);
1794 }
1795
1796 while (ptr != (asymbol **) NULL)
1797 {
1798 asymbol *ref = *ptr;
1799
1800 *ptr = it;
1801 ptr = (asymbol **) (ref->udata);
1802 }
1803 }
1804 }
1805 }
1806
1807
1808
1809 static void
1810 DEFUN_VOID (lang_finish)
1811 {
1812 ldsym_type *lgs;
1813
1814 if (entry_symbol == (char *) NULL)
1815 {
1816 /* No entry has been specified, look for start */
1817 entry_symbol = "start";
1818 }
1819 lgs = ldsym_get_soft (entry_symbol);
1820 if (lgs && lgs->sdefs_chain)
1821 {
1822 asymbol *sy = *(lgs->sdefs_chain);
1823
1824 /* We can set the entry address*/
1825 bfd_set_start_address (output_bfd,
1826 outside_symbol_address (sy));
1827
1828 }
1829 else
1830 {
1831 /* Can't find anything reasonable,
1832 use the first address in the text section
1833 */
1834 asection *ts = bfd_get_section_by_name (output_bfd, ".text");
1835
1836 if (ts)
1837 {
1838 bfd_set_start_address (output_bfd, ts->vma);
1839 }
1840 }
1841 }
1842
1843 /* By now we know the target architecture, and we may have an */
1844 /* ldfile_output_machine_name */
1845 static void
1846 DEFUN_VOID (lang_check)
1847 {
1848 lang_statement_union_type *file;
1849 bfd *input_bfd;
1850 unsigned long input_machine;
1851 enum bfd_architecture input_architecture;
1852 CONST bfd_arch_info_type *compatible;
1853
1854 for (file = file_chain.head;
1855 file != (lang_statement_union_type *) NULL;
1856 file = file->input_statement.next)
1857 {
1858 unsigned long ldfile_new_output_machine = 0;
1859 enum bfd_architecture ldfile_new_output_architecture = bfd_arch_unknown;
1860
1861 input_bfd = file->input_statement.the_bfd;
1862
1863 input_machine = bfd_get_mach (input_bfd);
1864 input_architecture = bfd_get_arch (input_bfd);
1865
1866
1867 /* Inspect the architecture and ensure we're linking like with
1868 like */
1869
1870 compatible = bfd_arch_get_compatible (input_bfd,
1871 output_bfd);
1872
1873 if (compatible)
1874 {
1875 ldfile_output_machine = compatible->mach;
1876 ldfile_output_architecture = compatible->arch;
1877 }
1878 else
1879 {
1880
1881 info ("%P: warning, %s architecture of input file `%B' incompatible with %s output\n",
1882 bfd_printable_name (input_bfd), input_bfd,
1883 bfd_printable_name (output_bfd));
1884
1885 bfd_set_arch_mach (output_bfd,
1886 ldfile_new_output_architecture,
1887 ldfile_new_output_machine);
1888 }
1889
1890 }
1891 }
1892
1893 /*
1894 * run through all the global common symbols and tie them
1895 * to the output section requested.
1896 *
1897 As an experiment we do this 4 times, once for all the byte sizes,
1898 then all the two bytes, all the four bytes and then everything else
1899 */
1900
1901 static void
1902 DEFUN_VOID (lang_common)
1903 {
1904 ldsym_type *lgs;
1905 size_t power;
1906
1907 if (config.relocateable_output == false ||
1908 command_line.force_common_definition == true)
1909 {
1910 for (power = 1; (config.sort_common == true && power == 1) || (power <= 16); power <<= 1)
1911 {
1912 for (lgs = symbol_head;
1913 lgs != (ldsym_type *) NULL;
1914 lgs = lgs->next)
1915 {
1916 asymbol *com;
1917 unsigned int power_of_two;
1918 size_t size;
1919 size_t align;
1920
1921 if (lgs->scoms_chain != (asymbol **) NULL)
1922 {
1923 com = *(lgs->scoms_chain);
1924 size = com->value;
1925 switch (size)
1926 {
1927 case 0:
1928 case 1:
1929 align = 1;
1930 power_of_two = 0;
1931 break;
1932 case 2:
1933 power_of_two = 1;
1934 align = 2;
1935 break;
1936 case 3:
1937 case 4:
1938 power_of_two = 2;
1939 align = 4;
1940 break;
1941 case 5:
1942 case 6:
1943 case 7:
1944 case 8:
1945 power_of_two = 3;
1946 align = 8;
1947 break;
1948 default:
1949 power_of_two = 4;
1950 align = 16;
1951 break;
1952 }
1953 if (config.sort_common == false || align == power)
1954 {
1955 /* Change from a common symbol into a definition of
1956 a symbol */
1957 lgs->sdefs_chain = lgs->scoms_chain;
1958 lgs->scoms_chain = (asymbol **) NULL;
1959 commons_pending--;
1960 /* Point to the correct common section */
1961 com->section =
1962 ((lang_input_statement_type *)
1963 (com->the_bfd->usrdata))->common_section;
1964 /* Fix the size of the common section */
1965
1966 com->section->_raw_size =
1967 ALIGN (com->section->_raw_size, align);
1968
1969 /* Remember if this is the biggest alignment ever seen */
1970 if (power_of_two > com->section->alignment_power)
1971 {
1972 com->section->alignment_power = power_of_two;
1973 }
1974
1975 /* Symbol stops being common and starts being global, but
1976 we remember that it was common once. */
1977
1978 com->flags = BSF_EXPORT | BSF_GLOBAL | BSF_OLD_COMMON;
1979 com->value = com->section->_raw_size;
1980
1981 if (write_map)
1982 {
1983 fprintf (config.map_file, "Allocating common %s: %x at %x %s\n",
1984 lgs->name,
1985 (unsigned) size,
1986 (unsigned) com->value,
1987 com->the_bfd->filename);
1988 }
1989
1990 com->section->_raw_size += size;
1991
1992 }
1993 }
1994
1995 }
1996 }
1997 }
1998
1999
2000 }
2001
2002 /*
2003 run through the input files and ensure that every input
2004 section has somewhere to go. If one is found without
2005 a destination then create an input request and place it
2006 into the statement tree.
2007 */
2008
2009 static void
2010 DEFUN_VOID (lang_place_orphans)
2011 {
2012 lang_input_statement_type *file;
2013
2014 for (file = (lang_input_statement_type *) file_chain.head;
2015 file != (lang_input_statement_type *) NULL;
2016 file = (lang_input_statement_type *) file->next)
2017 {
2018 asection *s;
2019
2020 for (s = file->the_bfd->sections;
2021 s != (asection *) NULL;
2022 s = s->next)
2023 {
2024 if (s->output_section == (asection *) NULL)
2025 {
2026 /* This section of the file is not attatched, root
2027 around for a sensible place for it to go */
2028
2029 if (file->common_section == s)
2030 {
2031 /* This is a lonely common section which must
2032 have come from an archive. We attatch to the
2033 section with the wildcard */
2034 if (config.relocateable_output != true
2035 && command_line.force_common_definition == false)
2036 {
2037 if (default_common_section ==
2038 (lang_output_section_statement_type *) NULL)
2039 {
2040 info ("%P: No [COMMON] command, defaulting to .bss\n");
2041
2042 default_common_section =
2043 lang_output_section_statement_lookup (".bss");
2044
2045 }
2046 wild_doit (&default_common_section->children, s,
2047 default_common_section, file);
2048 }
2049 }
2050 else
2051 {
2052 lang_output_section_statement_type *os =
2053 lang_output_section_statement_lookup (s->name);
2054
2055 wild_doit (&os->children, s, os, file);
2056 }
2057 }
2058 }
2059 }
2060 }
2061
2062
2063 void
2064 DEFUN (lang_set_flags, (ptr, flags),
2065 int *ptr AND
2066 CONST char *flags)
2067 {
2068 boolean state = false;
2069
2070 *ptr = 0;
2071 while (*flags)
2072 {
2073 if (*flags == '!')
2074 {
2075 state = false;
2076 flags++;
2077 }
2078 else
2079 state = true;
2080 switch (*flags)
2081 {
2082 case 'R':
2083 /* ptr->flag_read = state; */
2084 break;
2085 case 'W':
2086 /* ptr->flag_write = state; */
2087 break;
2088 case 'X':
2089 /* ptr->flag_executable= state;*/
2090 break;
2091 case 'L':
2092 case 'I':
2093 /* ptr->flag_loadable= state;*/
2094 break;
2095 default:
2096 einfo ("%P%F illegal syntax in flags\n");
2097 break;
2098 }
2099 flags++;
2100 }
2101 }
2102
2103
2104
2105 void
2106 DEFUN (lang_for_each_file, (func),
2107 PROTO (void, (*func), (lang_input_statement_type *)))
2108 {
2109 lang_input_statement_type *f;
2110
2111 for (f = (lang_input_statement_type *) file_chain.head;
2112 f != (lang_input_statement_type *) NULL;
2113 f = (lang_input_statement_type *) f->next)
2114 {
2115 func (f);
2116 }
2117 }
2118
2119
2120 void
2121 DEFUN (lang_for_each_input_section, (func),
2122 PROTO (void, (*func), (bfd * ab, asection * as)))
2123 {
2124 lang_input_statement_type *f;
2125
2126 for (f = (lang_input_statement_type *) file_chain.head;
2127 f != (lang_input_statement_type *) NULL;
2128 f = (lang_input_statement_type *) f->next)
2129 {
2130 asection *s;
2131
2132 for (s = f->the_bfd->sections;
2133 s != (asection *) NULL;
2134 s = s->next)
2135 {
2136 func (f->the_bfd, s);
2137 }
2138 }
2139 }
2140
2141
2142
2143 void
2144 DEFUN (ldlang_add_file, (entry),
2145 lang_input_statement_type * entry)
2146 {
2147
2148 lang_statement_append (&file_chain,
2149 (lang_statement_union_type *) entry,
2150 &entry->next);
2151 }
2152
2153 void
2154 DEFUN (lang_add_output, (name),
2155 CONST char *name)
2156 {
2157 lang_output_statement_type *new = new_stat (lang_output_statement,
2158 stat_ptr);
2159
2160 new->name = name;
2161 had_output_filename = true;
2162 }
2163
2164
2165 static lang_output_section_statement_type *current_section;
2166
2167 void
2168 DEFUN (lang_enter_output_section_statement,
2169 (output_section_statement_name,
2170 address_exp,
2171 flags,
2172 block_value),
2173 char *output_section_statement_name AND
2174 etree_type * address_exp AND
2175 int flags AND
2176 bfd_vma block_value)
2177 {
2178 lang_output_section_statement_type *os;
2179
2180 current_section =
2181 os =
2182 lang_output_section_statement_lookup (output_section_statement_name);
2183
2184
2185
2186 /* Add this statement to tree */
2187 /* add_statement(lang_output_section_statement_enum,
2188 output_section_statement);*/
2189 /* Make next things chain into subchain of this */
2190
2191 if (os->addr_tree ==
2192 (etree_type *) NULL)
2193 {
2194 os->addr_tree =
2195 address_exp;
2196 }
2197 os->flags = flags;
2198 os->block_value = block_value;
2199 stat_ptr = &os->children;
2200
2201 }
2202
2203 void
2204 DEFUN_VOID (lang_final)
2205 {
2206 if (had_output_filename == false)
2207 {
2208 extern CONST char *output_filename;
2209
2210 lang_add_output (output_filename);
2211 }
2212 }
2213
2214 /* Reset the current counters in the regions */
2215 static void
2216 DEFUN_VOID (reset_memory_regions)
2217 {
2218 lang_memory_region_type *p = lang_memory_region_list;
2219
2220 for (p = lang_memory_region_list;
2221 p != (lang_memory_region_type *) NULL;
2222 p = p->next)
2223 {
2224 p->current = p->origin;
2225 }
2226 }
2227
2228
2229 asymbol *
2230 DEFUN (create_symbol, (name, flags, section),
2231 CONST char *name AND
2232 flagword flags AND
2233 asection * section)
2234 {
2235 extern lang_input_statement_type *script_file;
2236 asymbol **def_ptr = (asymbol **) stat_alloc ((bfd_size_type) (sizeof (asymbol **)));
2237
2238 /* Add this definition to script file */
2239 asymbol *def = (asymbol *) bfd_make_empty_symbol (script_file->the_bfd);
2240
2241 def->name = buystring (name);
2242 def->udata = 0;
2243 def->flags = flags;
2244 def->section = section;
2245
2246 *def_ptr = def;
2247 Q_enter_global_ref (def_ptr, name);
2248 return def;
2249 }
2250
2251 void
2252 DEFUN_VOID (lang_process)
2253 {
2254
2255 if (had_script == false)
2256 {
2257 parse_line (ldemul_get_script (), 1);
2258 }
2259 lang_reasonable_defaults ();
2260 current_target = default_target;
2261
2262 lang_for_each_statement (ldlang_open_output); /* Open the output file */
2263 /* For each output section statement, create a section in the output
2264 file */
2265 lang_create_output_section_statements ();
2266
2267 /* Create a dummy bfd for the script */
2268 lang_init_script_file ();
2269
2270 /* Add to the hash table all undefineds on the command line */
2271 lang_place_undefineds ();
2272
2273 /* Create a bfd for each input file */
2274 current_target = default_target;
2275 lang_for_each_statement (open_input_bfds);
2276
2277 common_section.userdata = (PTR) & common_section_userdata;
2278
2279
2280 /* Run through the contours of the script and attatch input sections
2281 to the correct output sections
2282 */
2283 find_constructors ();
2284 map_input_to_output_sections (statement_list.head, (char *) NULL,
2285 (lang_output_section_statement_type *) NULL);
2286
2287
2288 /* Find any sections not attatched explicitly and handle them */
2289 lang_place_orphans ();
2290
2291 /* Size up the common data */
2292 lang_common ();
2293
2294 ldemul_before_allocation ();
2295
2296
2297 /* Size up the sections */
2298 lang_size_sections (statement_list.head,
2299 abs_output_section,
2300 &(statement_list.head), 0, (bfd_vma) 0, false);
2301
2302
2303 /* Now run around and relax if we can */
2304 if (command_line.relax)
2305 {
2306 reset_memory_regions ();
2307
2308 /* Move the global symbols around */
2309 lang_relocate_globals ();
2310
2311 had_relax = true;
2312 while (had_relax)
2313 {
2314
2315 had_relax = false;
2316
2317 lang_size_sections (statement_list.head,
2318 (lang_output_section_statement_type *) NULL,
2319 &(statement_list.head), 0, (bfd_vma) 0, true);
2320 /* FIXME. Until the code in relax is fixed so that it only reads in
2321 stuff once, we cant iterate since there is no way for the linker to
2322 know what has been patched and what hasn't */
2323 break;
2324
2325 }
2326
2327
2328
2329
2330 }
2331
2332
2333 /* See if anything special should be done now we know how big
2334 everything is */
2335 ldemul_after_allocation ();
2336
2337 /* Do all the assignments, now that we know the final restingplaces
2338 of all the symbols */
2339
2340 lang_do_assignments (statement_list.head,
2341 abs_output_section,
2342 0, (bfd_vma) 0);
2343
2344
2345 /* Move the global symbols around */
2346 lang_relocate_globals ();
2347
2348 /* Make sure that we're not mixing architectures */
2349
2350 lang_check ();
2351
2352 /* Final stuffs */
2353 lang_finish ();
2354 }
2355
2356 /* EXPORTED TO YACC */
2357
2358 void
2359 DEFUN (lang_add_wild, (section_name, filename),
2360 CONST char *CONST section_name AND
2361 CONST char *CONST filename)
2362 {
2363 lang_wild_statement_type *new = new_stat (lang_wild_statement,
2364 stat_ptr);
2365
2366 if (section_name != (char *) NULL && strcmp (section_name, "COMMON") == 0)
2367 {
2368 placed_commons = true;
2369 }
2370 if (filename != (char *) NULL)
2371 {
2372 lang_has_input_file = true;
2373 }
2374 new->section_name = section_name;
2375 new->filename = filename;
2376 lang_list_init (&new->children);
2377 }
2378
2379 void
2380 DEFUN (lang_section_start, (name, address),
2381 CONST char *name AND
2382 etree_type * address)
2383 {
2384 lang_address_statement_type *ad = new_stat (lang_address_statement, stat_ptr);
2385
2386 ad->section_name = name;
2387 ad->address = address;
2388 }
2389
2390 void
2391 DEFUN (lang_add_entry, (name),
2392 CONST char *name)
2393 {
2394 entry_symbol = name;
2395 }
2396
2397 void
2398 DEFUN (lang_add_target, (name),
2399 CONST char *name)
2400 {
2401 lang_target_statement_type *new = new_stat (lang_target_statement,
2402 stat_ptr);
2403
2404 new->target = name;
2405
2406 }
2407
2408 void
2409 DEFUN (lang_add_map, (name),
2410 CONST char *name)
2411 {
2412 while (*name)
2413 {
2414 switch (*name)
2415 {
2416 case 'F':
2417 map_option_f = true;
2418 break;
2419 }
2420 name++;
2421 }
2422 }
2423
2424 void
2425 DEFUN (lang_add_fill, (exp),
2426 int exp)
2427 {
2428 lang_fill_statement_type *new = new_stat (lang_fill_statement,
2429 stat_ptr);
2430
2431 new->fill = exp;
2432 }
2433
2434 void
2435 DEFUN (lang_add_data, (type, exp),
2436 int type AND
2437 union etree_union *exp)
2438 {
2439
2440 lang_data_statement_type *new = new_stat (lang_data_statement,
2441 stat_ptr);
2442
2443 new->exp = exp;
2444 new->type = type;
2445
2446 }
2447
2448 void
2449 DEFUN (lang_add_assignment, (exp),
2450 etree_type * exp)
2451 {
2452 lang_assignment_statement_type *new = new_stat (lang_assignment_statement,
2453 stat_ptr);
2454
2455 new->exp = exp;
2456 }
2457
2458 void
2459 DEFUN (lang_add_attribute, (attribute),
2460 enum statement_enum attribute)
2461 {
2462 new_statement (attribute, sizeof (lang_statement_union_type), stat_ptr);
2463 }
2464
2465 void
2466 DEFUN (lang_startup, (name),
2467 CONST char *name)
2468 {
2469 if (startup_file != (char *) NULL)
2470 {
2471 einfo ("%P%FMultiple STARTUP files\n");
2472 }
2473 first_file->filename = name;
2474 first_file->local_sym_name = name;
2475
2476 startup_file = name;
2477 }
2478
2479 void
2480 DEFUN (lang_float, (maybe),
2481 boolean maybe)
2482 {
2483 lang_float_flag = maybe;
2484 }
2485
2486 void
2487 DEFUN (lang_leave_output_section_statement, (fill, memspec),
2488 bfd_vma fill AND
2489 CONST char *memspec)
2490 {
2491 current_section->fill = fill;
2492 current_section->region = lang_memory_region_lookup (memspec);
2493 stat_ptr = &statement_list;
2494
2495 /* We remember if we are closing a .data section, since we use it to
2496 store constructors in */
2497 if (strcmp (current_section->name, ".data") == 0)
2498 {
2499 end_of_data_section_statement_list = statement_list;
2500
2501 }
2502 }
2503
2504 /*
2505 Create an absolute symbol with the given name with the value of the
2506 address of first byte of the section named.
2507
2508 If the symbol already exists, then do nothing.
2509 */
2510 void
2511 DEFUN (lang_abs_symbol_at_beginning_of, (section, name),
2512 CONST char *section AND
2513 CONST char *name)
2514 {
2515 if (ldsym_undefined (name))
2516 {
2517 asection *s = bfd_get_section_by_name (output_bfd, section);
2518 asymbol *def = create_symbol (name,
2519 BSF_GLOBAL | BSF_EXPORT,
2520 &bfd_abs_section);
2521
2522 if (s != (asection *) NULL)
2523 {
2524 def->value = s->vma;
2525 }
2526 else
2527 {
2528 def->value = 0;
2529 }
2530 }
2531 }
2532
2533 /*
2534 Create an absolute symbol with the given name with the value of the
2535 address of the first byte after the end of the section named.
2536
2537 If the symbol already exists, then do nothing.
2538 */
2539 void
2540 DEFUN (lang_abs_symbol_at_end_of, (section, name),
2541 CONST char *section AND
2542 CONST char *name)
2543 {
2544 if (ldsym_undefined (name))
2545 {
2546 asection *s = bfd_get_section_by_name (output_bfd, section);
2547
2548 /* Add a symbol called _end */
2549 asymbol *def = create_symbol (name,
2550 BSF_GLOBAL | BSF_EXPORT,
2551 &bfd_abs_section);
2552
2553 if (s != (asection *) NULL)
2554 {
2555 def->value = s->vma + s->_raw_size;
2556 }
2557 else
2558 {
2559 def->value = 0;
2560 }
2561 }
2562 }
2563
2564 void
2565 DEFUN (lang_statement_append, (list, element, field),
2566 lang_statement_list_type * list AND
2567 lang_statement_union_type * element AND
2568 lang_statement_union_type ** field)
2569 {
2570 *(list->tail) = element;
2571 list->tail = field;
2572 }
2573
2574 /* Set the output format type */
2575 void
2576 DEFUN (lang_add_output_format, (format),
2577 CONST char *format)
2578 {
2579 output_target = format;
2580 }
This page took 0.083199 seconds and 4 git commands to generate.