1 /* Copyright (C) 1991 Free Software Foundation, Inc.
3 This file is part of GLD, the Gnu Linker.
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)
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.
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. */
22 * Revision 1.2 1991/03/22 23:02:34 steve
23 * Brought up to sync with Intel again.
25 * Revision 1.3 1991/03/16 22:19:21 rich
28 * Revision 1.2 1991/03/15 18:52:42 rich
31 * Revision 1.1 1991/03/13 00:48:23 chrisb
34 * Revision 1.8 1991/03/10 09:31:28 rich
36 * Makefile config.h ld-emul.c ld-emul.h ld-gld.c ld-gld960.c
37 * ld-lnk960.c ld.h lddigest.c ldexp.c ldexp.h ldfile.c ldfile.h
38 * ldgram.y ldinfo.h ldlang.c ldlang.h ldlex.h ldlex.l ldmain.c
39 * ldmain.h ldmisc.c ldmisc.h ldsym.c ldsym.h ldversion.c
40 * ldversion.h ldwarn.h ldwrite.c ldwrite.h y.tab.h
42 * As of this round of changes, ld now builds on all hosts of (Intel960)
43 * interest and copy passes my copy test on big endian hosts again.
45 * Revision 1.7 1991/03/09 03:31:03 sac
46 * After a fatal info message, the output file is deleted.
48 * Revision 1.6 1991/03/09 03:25:06 sac
49 * Added support for LONG, SHORT and BYTE keywords in scripts
51 * Revision 1.5 1991/03/06 21:59:31 sac
52 * Completed G++ support
54 * Revision 1.4 1991/03/06 02:26:02 sac
55 * Added support for constructor sections.
56 * Remove parsing ambiguity.
59 * Revision 1.3 1991/02/22 17:15:01 sac
60 * Added RCS keywords and copyrights
72 #include "ldgram.tab.h"
83 extern unsigned int undefined_global_sym_count
;
85 static char *startup_file
;
86 static lang_input_statement_type
*first_file
;
87 lang_statement_list_type statement_list
;
88 lang_statement_list_type
*stat_ptr
= &statement_list
;
89 lang_statement_list_type lang_output_section_statement
;
90 lang_statement_list_type input_file_chain
;
91 lang_statement_list_type file_chain
;
92 extern char *current_file
;
93 static boolean placed_commons
= false;
95 boolean lang_float_flag
;
97 static lang_output_section_statement_type
*default_common_section
;
101 PROTO(static void, print_statements
,(void));
102 PROTO(static void, print_statement
,(lang_statement_union_type
*,
103 lang_output_section_statement_type
*));
108 boolean lang_has_input_file
= false;
111 extern bfd
*output_bfd
;
112 size_t largest_section
;
115 extern enum bfd_architecture ldfile_output_architecture
;
116 extern unsigned long ldfile_output_machine
;
117 extern char *ldfile_output_machine_name
;
120 extern ldsym_type
*symbol_head
;
123 unsigned int commons_pending
;
128 extern args_type command_line
;
129 extern ld_config_type config
;
135 lang_output_section_statement_type
*create_object_symbols
;
137 extern boolean had_script
;
138 static boolean map_option_f
;
141 boolean had_output_filename
= false;
142 extern boolean write_map
;
149 size_t longest_section_name
= 8;
152 lang_input_statement_type
*script_file
;
154 section_userdata_type common_section_userdata
;
155 asection common_section
;
158 #define cat(a,b) a##b
160 #define cat(a,b) a/**/b
163 #define new_stat(x,y) (cat(x,_type)*) new_statement(cat(x,_enum), sizeof(cat(x,_type)),y)
165 #define outside_section_address(q) ( (q)->output_offset + (q)->output_section->vma)
167 #define outside_symbol_address(q) ((q)->value + outside_section_address(q->section))
169 boolean option_longmap
= false;
171 static void lang_list_init(list
)
172 lang_statement_list_type
*list
;
174 list
->head
= (lang_statement_union_type
*)NULL
;
175 list
->tail
= &list
->head
;
182 printf("%*s", -longest_section_name
, name
);
198 printf("%8lx", value
);
204 printf("%5x", (unsigned)value
);
207 print_alignment(value
)
210 printf("2**%2u",value
);
216 printf("%04x",(unsigned)value
);
221 lang_statement_union_type
*new_statement(type
, size
, list
)
222 enum statement_enum type
;
224 lang_statement_list_type
*list
;
226 lang_statement_union_type
*new = (lang_statement_union_type
*)
228 new->header
.type
= type
;
229 new->header
.next
= (lang_statement_union_type
*)NULL
;
230 lang_statement_append(list
, new, &new->header
.next
);
234 static lang_input_statement_type
*
235 new_afile(name
, file_type
, target
)
237 lang_input_file_enum_type file_type
;
240 lang_input_statement_type
*p
= new_stat(lang_input_statement
,
242 lang_has_input_file
= true;
245 case lang_input_file_is_symbols_only_enum
:
247 p
->is_archive
=false;
249 p
->local_sym_name
= name
;
250 p
->just_syms_flag
= true;
251 p
->search_dirs_flag
= false;
253 case lang_input_file_is_fake_enum
:
255 p
->is_archive
=false;
257 p
->local_sym_name
= name
;
258 p
->just_syms_flag
= false;
259 p
->search_dirs_flag
=false;
262 case lang_input_file_is_l_enum
:
263 p
->is_archive
= true;
266 p
->local_sym_name
= concat("-l",name
,"");
267 p
->just_syms_flag
= false;
268 p
->search_dirs_flag
= true;
271 case lang_input_file_is_search_file_enum
:
272 case lang_input_file_is_marker_enum
:
274 p
->is_archive
=false;
276 p
->local_sym_name
= name
;
277 p
->just_syms_flag
= false;
278 p
->search_dirs_flag
=true;
283 case lang_input_file_is_file_enum
:
285 p
->is_archive
=false;
287 p
->local_sym_name
= name
;
288 p
->just_syms_flag
= false;
289 p
->search_dirs_flag
=false;
296 p
->asymbols
= (asymbol
**)NULL
;
297 p
->superfile
= (lang_input_statement_type
*)NULL
;
299 p
->next_real_file
= (lang_statement_union_type
*)NULL
;
300 p
->next
= (lang_statement_union_type
*)NULL
;
302 p
->common_output_section
= (asection
*)NULL
;
304 lang_statement_append(&input_file_chain
,
305 (lang_statement_union_type
*)p
,
310 lang_input_statement_type
*
311 lang_add_input_file(name
,
315 lang_input_file_enum_type file_type
;
318 /* Look it up or build a new one */
320 lang_input_statement_type
*p
;
322 for (p
= (lang_input_statement_type
*)input_file_chain
.head
;
323 p
!= (lang_input_statement_type
*)NULL
;
324 p
= (lang_input_statement_type
*)(p
->next_real_file
))
326 /* Sometimes we have incomplete entries in here */
327 if (p
->filename
!= (char *)NULL
) {
328 if(strcmp(name
,p
->filename
) == 0) return p
;
332 return new_afile(name
, file_type
, target
);
341 stat_ptr
= &statement_list
;
342 lang_list_init(stat_ptr
);
344 lang_list_init(&input_file_chain
);
345 lang_list_init(&lang_output_section_statement
);
346 lang_list_init(&file_chain
);
347 first_file
= lang_add_input_file((char *)NULL
,
348 lang_input_file_is_marker_enum
,
356 script_file
= lang_add_input_file("script file",
357 lang_input_file_is_fake_enum
,
359 script_file
->the_bfd
= bfd_create("script file", output_bfd
);
360 script_file
->symbol_count
= 0;
362 common_section
.userdata
= &common_section_userdata
;
368 /* this function mainains a dictionary of regions. If the *default*
369 region is asked for then a pointer to the first region is
370 returned. If there is no first pointer then one is created
373 static lang_memory_region_type
*lang_memory_region_list
;
374 static lang_memory_region_type
**lang_memory_region_list_tail
= &lang_memory_region_list
;
376 lang_memory_region_type
*
377 lang_memory_region_lookup(name
)
381 lang_memory_region_type
*p
= lang_memory_region_list
;
382 for (p
= lang_memory_region_list
;
383 p
!= ( lang_memory_region_type
*)NULL
;
385 if (strcmp(p
->name
, name
) == 0) {
389 if (strcmp(name
,"*default*")==0) {
390 /* This is the default region, dig out first one on the list */
391 if (lang_memory_region_list
!= (lang_memory_region_type
*)NULL
){
392 return lang_memory_region_list
;
396 lang_memory_region_type
*new =
397 (lang_memory_region_type
*)ldmalloc(sizeof(lang_memory_region_type
));
399 new->next
= (lang_memory_region_type
*)NULL
;
401 *lang_memory_region_list_tail
= new;
402 lang_memory_region_list_tail
= &new->next
;
412 lang_output_section_statement_type
*
413 lang_output_section_find(name
)
416 lang_statement_union_type
*u
;
417 lang_output_section_statement_type
*lookup
;
419 for (u
= lang_output_section_statement
.head
;
420 u
!= (lang_statement_union_type
*)NULL
;
423 lookup
= &u
->output_section_statement
;
424 if (strcmp(name
, lookup
->name
)==0) {
428 return (lang_output_section_statement_type
*)NULL
;
431 lang_output_section_statement_type
*
432 lang_output_section_statement_lookup(name
)
436 lang_output_section_statement_type
*lookup
;
437 lookup
=lang_output_section_find(name
);
438 if (lookup
== (lang_output_section_statement_type
*)NULL
) {
440 lookup
=(lang_output_section_statement_type
*)
441 new_stat(lang_output_section_statement
, stat_ptr
);
442 lookup
->region
= (lang_memory_region_type
*)NULL
;
444 lookup
->block_value
= 1;
447 lookup
->next
= (lang_statement_union_type
*)NULL
;
448 lookup
->bfd_section
= (asection
*)NULL
;
449 lookup
->processed
= false;
450 lookup
->addr_tree
= (etree_type
*)NULL
;
451 lang_list_init(&lookup
->children
);
453 lang_statement_append(&lang_output_section_statement
,
454 (lang_statement_union_type
*)lookup
,
465 print_flags(outfile
, ignore_flags
)
467 lang_section_flags_type
*ignore_flags
;
469 fprintf(outfile
,"(");
471 if (flags
->flag_read
) fprintf(outfile
,"R");
472 if (flags
->flag_write
) fprintf(outfile
,"W");
473 if (flags
->flag_executable
) fprintf(outfile
,"X");
474 if (flags
->flag_loadable
) fprintf(outfile
,"L");
476 fprintf(outfile
,")");
483 lang_memory_region_type
*m
;
484 fprintf(outfile
,"**MEMORY CONFIGURATION**\n\n");
486 fprintf(outfile
,"name\t\torigin\t\tlength\t\tattributes\n");
487 for (m
= lang_memory_region_list
;
488 m
!= (lang_memory_region_type
*)NULL
;
491 fprintf(outfile
,"%-16s", m
->name
);
493 fprintf(outfile
,"%08lx\t%08lx\t", m
->origin
, m
->length
);
494 print_flags(outfile
, &m
->flags
);
495 fprintf(outfile
,"\n");
497 fprintf(outfile
,"\n\n**LINK EDITOR MEMORY MAP**\n\n");
498 fprintf(outfile
,"output\t\tinput\t\tvirtual\n");
499 fprintf(outfile
,"section\t\tsection\t\taddress\tsize\n\n");
508 static void init_os(s
)
509 lang_output_section_statement_type
*s
;
511 section_userdata_type
*new =
512 (section_userdata_type
*)
513 ldmalloc(sizeof(section_userdata_type
));
515 s
->bfd_section
= bfd_make_section(output_bfd
, s
->name
);
516 s
->bfd_section
->output_section
= s
->bfd_section
;
517 s
->bfd_section
->flags
= SEC_NO_FLAGS
;
518 /* We initialize an output sections output offset to minus its own */
519 /* vma to allow us to output a section through itself */
520 s
->bfd_section
->output_offset
= 0;
521 get_userdata( s
->bfd_section
) = new;
525 wild_doit(ptr
, section
,output
, file
)
526 lang_statement_list_type
*ptr
;
528 lang_output_section_statement_type
*output
;
529 lang_input_statement_type
*file
;
531 if(output
->bfd_section
== (asection
*)NULL
)
536 if (section
!= (asection
*)NULL
537 && section
->output_section
== (asection
*)NULL
) {
538 /* Add a section reference to the list */
539 lang_input_section_type
*new = new_stat(lang_input_section
, ptr
);
541 new->section
= section
;
543 section
->output_section
= output
->bfd_section
;
544 section
->output_section
->flags
|= section
->flags
;
545 if (section
->alignment_power
> output
->bfd_section
->alignment_power
) {
546 output
->bfd_section
->alignment_power
= section
->alignment_power
;
553 our_bfd_get_section_by_name(abfd
, section
)
557 return bfd_get_section_by_name(abfd
, section
);
561 wild_section(ptr
, section
, file
, output
)
562 lang_wild_statement_type
*ptr
;
564 lang_input_statement_type
*file
;
565 lang_output_section_statement_type
*output
;
568 if (section
== (char *)NULL
) {
569 /* Do the creation to all sections in the file */
570 for (s
= file
->the_bfd
->sections
; s
!= (asection
*)NULL
; s
=s
->next
) {
571 wild_doit(&ptr
->children
, s
, output
, file
);
575 /* Do the creation to the named section only */
576 wild_doit(&ptr
->children
,
577 our_bfd_get_section_by_name(file
->the_bfd
, section
),
588 lang_input_statement_type
*lookup_name(name
, target
)
592 lang_input_statement_type
*search
;
593 for(search
= (lang_input_statement_type
*)input_file_chain
.head
;
594 search
!= (lang_input_statement_type
*)NULL
;
595 search
= (lang_input_statement_type
*)search
->next_real_file
)
597 if (search
->filename
== (char *)NULL
&& name
== (char *)NULL
) {
600 if (search
->filename
!= (char *)NULL
&& name
!= (char *)NULL
) {
601 if (strcmp(search
->filename
, name
) == 0) {
602 Q_read_file_symbols(search
);
608 /* There isn't an afile entry for this file yet, this must be */
609 /* because the name has only appeared inside a load script and not */
610 /* on the command line */
611 search
= new_afile(name
, lang_input_file_is_file_enum
, target
);
612 Q_read_file_symbols(search
);
618 wild(s
, section
, file
, target
, output
)
619 lang_wild_statement_type
*s
;
623 lang_output_section_statement_type
*output
;
625 lang_input_statement_type
*f
;
626 if (file
== (char *)NULL
) {
627 /* Perform the iteration over all files in the list */
628 for (f
= (lang_input_statement_type
*)file_chain
.head
;
629 f
!= (lang_input_statement_type
*)NULL
;
630 f
= (lang_input_statement_type
*)f
->next
) {
631 wild_section(s
, section
, f
, output
);
635 /* Perform the iteration over a single file */
636 wild_section( s
, section
, lookup_name(file
, target
), output
);
641 read in all the files
644 open_output(name
, target
)
648 extern char *output_filename
;
649 bfd
* output
= bfd_openw(name
, target
);
650 output_filename
= name
;
651 if (output
== (bfd
*)NULL
)
653 if (bfd_error
== invalid_target
) {
654 info("%P%F target %s not found\n", target
);
656 info("%P%F problem opening output file %s, %E", name
);
659 output
->flags
|= D_PAGED
;
660 bfd_set_format(output
, bfd_object
);
663 extern char *default_target
;
665 lang_phase_0(sh
,target
)
666 lang_statement_union_type
*sh
;
669 lang_statement_union_type
*s
= (lang_statement_union_type
*)sh
;
670 for (; s
!= (lang_statement_union_type
*)NULL
; s
= s
->next
)
672 switch (s
->header
.type
) {
673 case lang_output_section_statement_enum
:
674 lang_phase_0(s
->output_section_statement
.children
.head
,
677 case lang_output_statement_enum
:
679 output_bfd
= open_output(s
->output_statement
.name
,
680 target
== (char *)NULL
?
681 default_target
: target
);
682 ldemul_set_output_arch();
685 case lang_target_statement_enum
:
686 target
= s
->target_statement
.target
;
688 case lang_wild_statement_enum
:
689 /* Maybe we should load the file's symbols */
690 if (s
->wild_statement
.filename
) {
691 (void) lookup_name(s
->wild_statement
.filename
, target
);
694 /* Attatch this to the current output section */
695 case lang_common_statement_enum
:
696 case lang_fill_statement_enum
:
697 case lang_input_section_enum
:
698 case lang_object_symbols_statement_enum
:
699 case lang_address_statement_enum
:
700 case lang_data_statement_enum
:
702 case lang_afile_asection_pair_statement_enum
:
707 case lang_input_statement_enum
:
708 if (s
->input_statement
.real
== true) {
709 s
->input_statement
.target
= target
;
710 lookup_name(s
->input_statement
.filename
, target
);
713 case lang_assignment_statement_enum
:
715 (void) exp_fold_tree(s
->assignment_statement
.exp
,
721 case lang_padding_statement_enum
:
729 /* If there are [COMMONS] statements, put a wild one into the bss section */
732 lang_reasonable_defaults()
735 lang_output_section_statement_lookup(".text");
736 lang_output_section_statement_lookup(".data");
738 default_common_section
=
739 lang_output_section_statement_lookup(".bss");
741 if (placed_commons
== false) {
742 lang_wild_statement_type
*new =
743 new_stat(lang_wild_statement
,
744 &default_common_section
->children
);
745 new->section_name
= "COMMON";
746 new->filename
= (char *)NULL
;
747 lang_list_init(&new->children
);
754 if (had_script
== false) {
755 parse_line(ldemul_get_script());
758 lang_reasonable_defaults();
759 lang_phase_0(statement_list
.head
,default_target
);
763 /* Open input files and attatch to output sections */
765 lang_open_input(s
, target
, output_section_statement
)
766 lang_statement_union_type
*s
;
768 lang_output_section_statement_type
*output_section_statement
;
770 for (; s
!= (lang_statement_union_type
*)NULL
; s
= s
->next
)
772 switch (s
->header
.type
) {
773 case lang_wild_statement_enum
:
774 wild(&s
->wild_statement
, s
->wild_statement
.section_name
,
775 s
->wild_statement
.filename
, target
,
776 output_section_statement
);
780 case lang_output_section_statement_enum
:
781 lang_open_input(s
->output_section_statement
.children
.head
,
783 &s
->output_section_statement
);
785 case lang_output_statement_enum
:
787 case lang_target_statement_enum
:
788 target
= s
->target_statement
.target
;
790 case lang_common_statement_enum
:
791 case lang_fill_statement_enum
:
792 case lang_input_section_enum
:
793 case lang_object_symbols_statement_enum
:
794 case lang_data_statement_enum
:
796 case lang_afile_asection_pair_statement_enum
:
800 case lang_assignment_statement_enum
:
801 case lang_padding_statement_enum
:
804 case lang_address_statement_enum
:
805 /* Mark the specified section with the supplied address */
807 lang_output_section_statement_type
*os
=
808 lang_output_section_statement_lookup
809 (s
->address_statement
.section_name
);
810 os
->addr_tree
= s
->address_statement
.address
;
813 case lang_input_statement_enum
:
814 /* A standard input statement, has no wildcards */
815 /* Q_read_file_symbols(&s->input_statement);*/
826 print_output_section_statement(output_section_statement
)
827 lang_output_section_statement_type
*output_section_statement
;
829 asection
*section
= output_section_statement
->bfd_section
;
831 print_section(output_section_statement
->name
);
834 print_dot
= section
->vma
;
838 print_address(section
->vma
);
840 print_size(section
->size
);
842 print_alignment(section
->alignment_power
);
845 printf("%s flags", output_section_statement
->region
->name
);
846 print_flags(stdout
, &output_section_statement
->flags
);
851 printf("No attached output section");
854 print_statement(output_section_statement
->children
.head
,
855 output_section_statement
);
860 print_assignment(assignment
, output_section
)
861 lang_assignment_statement_type
*assignment
;
862 lang_output_section_statement_type
*output_section
;
864 etree_value_type result
;
869 print_address(print_dot
);
871 result
= exp_fold_tree(assignment
->exp
->assign
.src
,
873 lang_final_phase_enum
,
878 print_address(result
.value
);
882 printf("*undefined*");
885 exp_print_tree(stdout
, assignment
->exp
);
890 print_input_statement(statm
)
891 lang_input_statement_type
*statm
;
893 printf("LOAD %s\n",statm
->filename
);
896 static void print_symbol(q
)
903 print_address(outside_symbol_address(q
));
904 printf(" %s", q
->name
? q
->name
: " ");
908 print_input_section(in
)
909 lang_input_section_type
*in
;
911 asection
*i
= in
->section
;
916 print_section(i
->name
);
918 if (i
->output_section
) {
919 print_address(i
->output_section
->vma
+ i
->output_offset
);
923 print_alignment(i
->alignment_power
);
926 bfd
*abfd
= in
->ifile
->the_bfd
;
927 printf(" %s ",abfd
->xvec
->name
);
928 if(abfd
->my_archive
!= (bfd
*)NULL
) {
929 printf("[%s]%s", abfd
->my_archive
->filename
,
933 printf("%s", abfd
->filename
);
937 /* Find all the symbols in this file defined in this section */
940 for (p
= in
->ifile
->asymbols
; *p
; p
++) {
943 if (bfd_get_section(q
) == i
&& q
->flags
& BSF_GLOBAL
) {
954 print_dot
= outside_section_address(i
) + i
->size
;
957 printf("No output section allocated\n");
962 print_common_statement()
967 print_section(common_section
.output_section
->name
);
969 print_address(common_section
.output_offset
+
970 common_section
.output_section
->vma
);
972 print_size(common_section
.size
);
976 /* Print out all the global symbols */
979 for (lgs
= symbol_head
; lgs
!= (ldsym_type
*)NULL
; lgs
=
981 if (lgs
->sdefs_chain
) {
982 asymbol
*def
= *(lgs
->sdefs_chain
);
983 if (def
->section
== &common_section
) {
989 print_dot
= common_section
.output_offset
+
990 common_section
.output_section
->vma
+ common_section
.size
;
995 print_fill_statement(fill
)
996 lang_fill_statement_type
*fill
;
998 printf("FILL mask ");
999 print_fill( fill
->fill
);
1003 print_data_statement(data
)
1004 lang_data_statement_type
*data
;
1006 /* bfd_vma value; */
1011 ASSERT(print_dot
== data
->output_vma
);
1013 print_address(data
->output_vma
);
1015 print_address(data
->value
);
1017 switch (data
->type
) {
1020 print_dot
+= BYTE_SIZE
;
1024 print_dot
+= SHORT_SIZE
;
1028 print_dot
+= LONG_SIZE
;
1032 exp_print_tree(stdout
, data
->exp
);
1039 print_padding_statement(s
)
1040 lang_padding_statement_type
*s
;
1044 print_section("*fill*");
1046 print_address(s
->output_offset
+ s
->output_section
->vma
);
1048 print_size(s
->size
);
1050 print_fill(s
->fill
);
1054 static void print_wild_statement(w
,os
)
1055 lang_wild_statement_type
*w
;
1056 lang_output_section_statement_type
*os
;
1058 if (w
->filename
!= (char *)NULL
) {
1059 printf("%s",w
->filename
);
1064 if (w
->section_name
!= (char *)NULL
) {
1065 printf("(%s)",w
->section_name
);
1071 print_statement(w
->children
.head
, os
);
1075 print_statement(s
, os
)
1076 lang_statement_union_type
*s
;
1077 lang_output_section_statement_type
*os
;
1080 switch (s
->header
.type
) {
1081 case lang_wild_statement_enum
:
1082 print_wild_statement(&s
->wild_statement
, os
);
1085 printf("Fail with %d\n",s
->header
.type
);
1088 case lang_address_statement_enum
:
1089 printf("address\n");
1091 case lang_common_statement_enum
:
1092 print_common_statement();
1094 case lang_object_symbols_statement_enum
:
1095 printf("object symbols\n");
1097 case lang_fill_statement_enum
:
1098 print_fill_statement(&s
->fill_statement
);
1100 case lang_data_statement_enum
:
1101 print_data_statement(&s
->data_statement
);
1105 case lang_input_section_enum
:
1106 print_input_section(&s
->input_section
);
1108 case lang_padding_statement_enum
:
1109 print_padding_statement(&s
->padding_statement
);
1111 case lang_output_section_statement_enum
:
1112 print_output_section_statement(&s
->output_section_statement
);
1114 case lang_assignment_statement_enum
:
1115 print_assignment(&s
->assignment_statement
,
1120 case lang_target_statement_enum
:
1121 printf("TARGET(%s)\n", s
->target_statement
.target
);
1123 case lang_output_statement_enum
:
1124 printf("OUTPUT(%s)\n", s
->output_statement
.name
);
1126 case lang_input_statement_enum
:
1127 print_input_statement(&s
->input_statement
);
1129 case lang_afile_asection_pair_statement_enum
:
1141 print_statement(statement_list
.head
,
1142 (lang_output_section_statement_type
*)NULL
);
1146 insert_pad(this_ptr
, fill
, power
, output_section_statement
, dot
)
1147 lang_statement_union_type
**this_ptr
;
1150 asection
* output_section_statement
;
1153 /* Align this section first to the
1154 input sections requirement, then
1155 to the output section's requirement.
1156 If this alignment is > than any seen before,
1157 then record it too. Perform the alignment by
1158 inserting a magic 'padding' statement.
1161 unsigned int alignment_needed
= align_power(dot
, power
) - dot
;
1163 if (alignment_needed
!= 0)
1165 lang_statement_union_type
*new =
1166 (lang_statement_union_type
*)
1167 ldmalloc(sizeof(lang_padding_statement_type
));
1168 /* Link into existing chain */
1169 new->header
.next
= *this_ptr
;
1171 new->header
.type
= lang_padding_statement_enum
;
1172 new->padding_statement
.output_section
= output_section_statement
;
1173 new->padding_statement
.output_offset
=
1174 dot
- output_section_statement
->vma
;
1175 new->padding_statement
.fill
= fill
;
1176 new->padding_statement
.size
= alignment_needed
;
1180 /* Remember the most restrictive alignment */
1181 if (power
> output_section_statement
->alignment_power
) {
1182 output_section_statement
->alignment_power
= power
;
1184 output_section_statement
->size
+= alignment_needed
;
1185 return alignment_needed
+ dot
;
1190 size_common runs run though each global symboxl, and works
1191 out how big the common section will be.
1195 size_common(output_section_statement
, this_ptr
, dot
)
1196 lang_output_section_statement_type
*output_section_statement
;
1197 lang_statement_union_type
**this_ptr
;
1200 extern ldsym_type
*symbol_head
;
1202 /* Make sure that each symbol is only defined once.
1203 Allocate common symbols
1204 Make the ref chain point to the defining asymbol.
1206 /* Now, for each symbol, verify that it is defined globally at most once.
1207 Put the global value into the symbol entry.
1208 Common symbols are allocated here, in the BSS section.
1209 Each defined symbol is given a '->defined' field
1210 which is the correct N_ code for its definition,
1211 except in the case of common symbols with -r.
1212 Then make all the references point at the symbol entry
1213 instead of being chained together. */
1216 common_section
.name
= output_section_statement
->bfd_section
->name
;
1217 common_section
.output_section
= output_section_statement
->bfd_section
;
1218 common_section
.output_offset
=
1219 dot
- output_section_statement
->bfd_section
->vma
;
1220 if (config
.relocateable_output
== false ||
1221 command_line
.force_common_definition
== true) {
1222 dot
= insert_pad(this_ptr
,
1223 0x0, 4, output_section_statement
->bfd_section
, dot
);
1225 for (sp
= symbol_head
; sp
!= (ldsym_type
*)NULL
; sp
= sp
->next
)
1227 /* Attatch this symbol to the correct output section*/
1229 /* Allocate as common if wanted */
1231 if (sp
->scoms_chain
)
1234 unsigned long com
= (*(sp
->scoms_chain
))->value
;
1235 /* Work out what alignment this common item s
1236 hould be put on. Anything < int is int aligned,
1237 anything bigger is self aligned,
1238 up to the restriction of the machine */
1240 unsigned int align
= sizeof(int);
1242 /* Round up size of object to nearest int */
1243 com
= ALIGN(com
, sizeof(int));
1244 /* See what alignment is necessary -*/
1246 while ((com
& align
)==0) align
<<=1;
1252 dot
= ALIGN(dot
, align
);
1255 /* Transmogrify this from a common symbol
1256 into a definition of a symbol in common
1258 sp
->sdefs_chain
= sp
->scoms_chain
;
1261 asymbol
*com_ptr
= *(sp
->sdefs_chain
);
1263 sp
->scoms_chain
= (asymbol
**)NULL
;
1265 /* Assign address, but keep section relative */
1267 /* Force the symbol to belong in the bss section */
1268 com_ptr
->flags
= BSF_EXPORT
| BSF_GLOBAL
;
1269 com_ptr
->section
= &common_section
;
1270 common_section
.size
+= com
;
1273 printf ("Allocating common %s: %lx at %lx\n",
1278 com_ptr
->value
= common_section
.size
;
1284 (common_section
.output_section
->vma
+
1285 common_section
.output_section
->size
)) {
1286 common_section
.output_section
->size
=
1287 dot
- common_section
.output_section
->vma
;
1289 return dot
+ common_section
.size
;
1293 size_input_section( this_ptr
, output_section_statement
, fill
, dot
)
1294 lang_statement_union_type
**this_ptr
;
1295 lang_output_section_statement_type
*output_section_statement
;
1296 unsigned short fill
;
1299 lang_input_section_type
*is
= &((*this_ptr
)->input_section
);
1300 asection
*i
= is
->section
;
1302 dot
= insert_pad(this_ptr
, fill
, i
->alignment_power
,
1303 output_section_statement
->bfd_section
, dot
);
1305 /* remember the largest size so we can malloc the largest area */
1306 /* needed for the output stage */
1307 if (i
->size
> largest_section
) {
1308 largest_section
= i
->size
;
1311 /* Remember where in the output section this input section goes */
1312 i
->output_offset
= dot
- output_section_statement
->bfd_section
->vma
;
1314 /* Mark how big the output section must be to contain this now */
1316 output_section_statement
->bfd_section
->size
=
1317 dot
- output_section_statement
->bfd_section
->vma
;
1324 /* Work out the size of the output sections
1325 from the sizes of the input sections */
1327 lang_size_sections(s
, output_section_statement
, prev
, fill
, dot
)
1328 lang_statement_union_type
*s
;
1329 lang_output_section_statement_type
* output_section_statement
;
1330 lang_statement_union_type
**prev
;
1331 unsigned short fill
;
1334 /* Size up the sections from their constituent parts */
1335 for (; s
!= (lang_statement_union_type
*)NULL
; s
= s
->next
)
1337 switch (s
->header
.type
) {
1338 case lang_output_section_statement_enum
:
1341 lang_output_section_statement_type
*os
=
1342 &(s
->output_section_statement
);
1343 /* The start of a section */
1345 if (os
->addr_tree
== (etree_type
*)NULL
) {
1346 /* No address specified for this section, get one
1347 from the region specification
1349 if (os
->region
== (lang_memory_region_type
*)NULL
) {
1350 os
->region
= lang_memory_region_lookup("*default*");
1352 dot
= os
->region
->current
;
1355 etree_value_type r
;
1356 r
= exp_fold_tree(os
->addr_tree
,
1357 (lang_output_section_statement_type
*)NULL
,
1358 lang_allocating_phase_enum
,
1360 if (r
.valid
== false) {
1361 info("%F%S: non constant address expression for section %s\n",
1366 /* The section starts here */
1367 /* First, align to what the section needs */
1369 dot
= align_power(dot
, os
->bfd_section
->alignment_power
);
1370 os
->bfd_section
->vma
= dot
;
1371 os
->bfd_section
->output_offset
= 0;
1373 (void) lang_size_sections(os
->children
.head
, os
, &os
->children
.head
,
1375 /* Ignore the size of the input sections, use the vma and size to */
1379 after
= ALIGN(os
->bfd_section
->vma
+
1380 os
->bfd_section
->size
,
1384 os
->bfd_section
->size
= after
- os
->bfd_section
->vma
;
1385 dot
= os
->bfd_section
->vma
+ os
->bfd_section
->size
;
1386 os
->processed
= true;
1388 /* Replace into region ? */
1389 if (os
->addr_tree
== (etree_type
*)NULL
1390 && os
->region
!=(lang_memory_region_type
*)NULL
) {
1391 os
->region
->current
= dot
;
1397 case lang_data_statement_enum
:
1400 s
->data_statement
.output_vma
= dot
;
1401 s
->data_statement
.output_section
=
1402 output_section_statement
->bfd_section
;
1404 switch (s
->data_statement
.type
) {
1417 output_section_statement
->bfd_section
->size
+= size
;
1421 case lang_wild_statement_enum
:
1423 dot
= lang_size_sections(s
->wild_statement
.children
.head
,
1424 output_section_statement
,
1425 &s
->wild_statement
.children
.head
,
1431 case lang_object_symbols_statement_enum
:
1432 create_object_symbols
= output_section_statement
;
1434 case lang_output_statement_enum
:
1436 case lang_target_statement_enum
:
1438 case lang_common_statement_enum
:
1439 dot
= size_common(output_section_statement
, prev
, dot
);
1443 case lang_input_section_enum
:
1444 dot
= size_input_section(prev
,
1445 output_section_statement
,
1446 output_section_statement
->fill
, dot
);
1448 case lang_input_statement_enum
:
1450 case lang_fill_statement_enum
:
1451 fill
= s
->fill_statement
.fill
;
1453 case lang_assignment_statement_enum
:
1455 bfd_vma newdot
= dot
;
1456 exp_fold_tree(s
->assignment_statement
.exp
,
1457 output_section_statement
,
1458 lang_allocating_phase_enum
,
1463 /* We've been moved ! so insert a pad */
1465 lang_statement_union_type
*new =
1466 (lang_statement_union_type
*)
1467 ldmalloc(sizeof(lang_padding_statement_type
));
1468 /* Link into existing chain */
1469 new->header
.next
= *prev
;
1471 new->header
.type
= lang_padding_statement_enum
;
1472 new->padding_statement
.output_section
=
1473 output_section_statement
->bfd_section
;
1474 new->padding_statement
.output_offset
=
1475 dot
- output_section_statement
->bfd_section
->vma
;
1476 new->padding_statement
.fill
= fill
;
1477 new->padding_statement
.size
= newdot
- dot
;
1478 output_section_statement
->bfd_section
->size
+=
1479 new->padding_statement
.size
;
1485 case lang_padding_statement_enum
:
1491 case lang_address_statement_enum
:
1494 prev
= &s
->header
.next
;
1501 lang_do_assignments(s
, output_section_statement
, fill
, dot
)
1502 lang_statement_union_type
*s
;
1503 lang_output_section_statement_type
* output_section_statement
;
1504 unsigned short fill
;
1508 for (; s
!= (lang_statement_union_type
*)NULL
; s
= s
->next
)
1510 switch (s
->header
.type
) {
1511 case lang_output_section_statement_enum
:
1513 lang_output_section_statement_type
*os
=
1514 &(s
->output_section_statement
);
1515 dot
= os
->bfd_section
->vma
;
1516 (void) lang_do_assignments(os
->children
.head
, os
, os
->fill
, dot
);
1517 dot
= os
->bfd_section
->vma
+ os
->bfd_section
->size
;
1520 case lang_wild_statement_enum
:
1522 dot
= lang_do_assignments(s
->wild_statement
.children
.head
,
1523 output_section_statement
,
1528 case lang_object_symbols_statement_enum
:
1529 case lang_output_statement_enum
:
1530 case lang_target_statement_enum
:
1531 case lang_common_statement_enum
:
1533 case lang_data_statement_enum
:
1535 etree_value_type value
;
1536 value
= exp_fold_tree(s
->data_statement
.exp
,
1537 0, lang_final_phase_enum
, dot
, &dot
);
1538 s
->data_statement
.value
= value
.value
;
1539 if (value
.valid
== false) info("%F%P: Invalid data statement\n");
1541 switch (s
->data_statement
.type
) {
1553 case lang_input_section_enum
:
1555 asection
*in
= s
->input_section
.section
;
1560 case lang_input_statement_enum
:
1562 case lang_fill_statement_enum
:
1563 fill
= s
->fill_statement
.fill
;
1565 case lang_assignment_statement_enum
:
1567 exp_fold_tree(s
->assignment_statement
.exp
,
1568 output_section_statement
,
1569 lang_final_phase_enum
,
1575 case lang_padding_statement_enum
:
1576 dot
+= s
->padding_statement
.size
;
1581 case lang_address_statement_enum
:
1591 static void lang_relocate_globals()
1595 Each ldsym_type maintains a chain of pointers to asymbols which
1596 references the definition. Replace each pointer to the referenence
1597 with a pointer to only one place, preferably the definition. If
1598 the defintion isn't available then the common symbol, and if
1599 there isn't one of them then choose one reference.
1602 FOR_EACH_LDSYM(lgs
) {
1604 if (lgs
->sdefs_chain
) {
1605 it
= *(lgs
->sdefs_chain
);
1607 else if (lgs
->scoms_chain
!= (asymbol
**)NULL
) {
1608 it
= *(lgs
->scoms_chain
);
1610 else if (lgs
->srefs_chain
!= (asymbol
**)NULL
) {
1611 it
= *(lgs
->srefs_chain
);
1616 if (it
!= (asymbol
*)NULL
)
1618 asymbol
**ptr
= lgs
->srefs_chain
;
1620 while (ptr
!= (asymbol
**)NULL
) {
1621 asymbol
*ref
= *ptr
;
1623 ptr
= (asymbol
**)(ref
->udata
);
1631 /* now that all the jiggery pokery is finished, copy important data from
1632 * out internal form to the bfd way. Also create a section
1633 * for each dummy file
1637 lang_create_output_section_statements()
1639 lang_statement_union_type
*os
;
1640 for (os
= lang_output_section_statement
.head
;
1641 os
!= (lang_statement_union_type
*)NULL
;
1642 os
= os
->output_section_statement
.next
) {
1643 lang_output_section_statement_type
*s
=
1644 &os
->output_section_statement
;
1647 script_file
->the_bfd
->sections
= output_bfd
->sections
;
1655 if (entry_symbol
== (char *)NULL
) {
1656 /* No entry has been specified, look for start */
1657 entry_symbol
= "start";
1659 lgs
= ldsym_get_soft(entry_symbol
);
1660 if (lgs
&& lgs
->sdefs_chain
) {
1661 asymbol
*sy
= *(lgs
->sdefs_chain
);
1662 /* We can set the entry address*/
1663 bfd_set_start_address(output_bfd
,
1664 outside_symbol_address(sy
));
1668 /* Can't find anything reasonable,
1669 use the first address in the text section
1671 asection
*ts
= bfd_get_section_by_name(output_bfd
, ".text");
1673 bfd_set_start_address(output_bfd
, ts
->vma
);
1678 /* By now we know the target architecture, and we may have an */
1679 /* ldfile_output_machine_name */
1683 lang_statement_union_type
*file
;
1686 for (file
= file_chain
.head
;
1687 file
!= (lang_statement_union_type
*)NULL
;
1688 file
=file
->input_statement
.next
)
1690 /* Inspect the architecture and ensure we're linking like
1694 if (bfd_arch_compatible( file
->input_statement
.the_bfd
,
1696 &ldfile_output_architecture
,
1697 &ldfile_output_machine
)) {
1698 bfd_set_arch_mach(output_bfd
,
1699 ldfile_output_architecture
, ldfile_output_machine
);
1702 enum bfd_architecture this_architecture
=
1703 bfd_get_architecture(file
->input_statement
.the_bfd
);
1704 unsigned long this_machine
=
1705 bfd_get_machine(file
->input_statement
.the_bfd
);
1707 info("%I: architecture %s",
1709 bfd_printable_arch_mach(this_architecture
, this_machine
));
1710 info(" incompatible with output %s\n",
1711 bfd_printable_arch_mach(ldfile_output_architecture
,
1712 ldfile_output_machine
));
1713 ldfile_output_architecture
= this_architecture
;
1714 ldfile_output_machine
= this_machine
;
1715 bfd_set_arch_mach(output_bfd
,
1716 ldfile_output_architecture
,
1717 ldfile_output_machine
);
1726 * run through all the global common symbols and tie them
1727 * to the output section requested.
1734 if (config
.relocateable_output
== false ||
1735 command_line
.force_common_definition
== true) {
1736 for (lgs
= symbol_head
;
1737 lgs
!= (ldsym_type
*)NULL
;
1743 if (lgs
->scoms_chain
!= (asymbol
**)NULL
) {
1745 com
= *(lgs
->scoms_chain
);
1747 align
= sizeof(int);
1748 /* Round up size of object to nearest int */
1749 size
= ALIGN(size
, sizeof(int));
1750 /* Force alignment */
1752 while ((size
& align
)==0) align
<<=1;
1757 /* Change from a common symbol into a definition of
1759 lgs
->sdefs_chain
= lgs
->scoms_chain
;
1760 lgs
->scoms_chain
= (asymbol
**)NULL
;
1762 /* Point to the correct common section */
1764 ((lang_input_statement_type
*)
1765 (com
->the_bfd
->usrdata
))->common_section
;
1766 /* Fix the size of the common section */
1769 com
->flags
= BSF_EXPORT
| BSF_GLOBAL
;
1773 printf ("Allocating common %s: %x at %x\n",
1776 (unsigned) com
->section
->size
);
1778 com
->value
= com
->section
->size
;
1779 com
->section
->size
+= size
;
1786 run through the input files and ensure that every input
1787 section has somewhere to go. If one is found without
1788 a destination then create an input request and place it
1789 into the statement tree.
1792 static void lang_place_orphans()
1794 lang_input_statement_type
*file
;
1795 for (file
= (lang_input_statement_type
*)file_chain
.head
;
1796 file
!= (lang_input_statement_type
*)NULL
;
1797 file
= (lang_input_statement_type
*)file
->next
) {
1799 for (s
= file
->the_bfd
->sections
;
1800 s
!= (asection
*)NULL
;
1802 if ( s
->output_section
== (asection
*)NULL
) {
1803 /* This section of the file is not attatched, root
1804 around for a sensible place for it to go */
1806 if (file
->common_section
== s
) {
1807 /* This is a lonely common section which must
1808 have come from an archive. We attatch to the
1809 section with the wildcard */
1810 wild_doit(&default_common_section
->children
, s
,
1811 default_common_section
, file
);
1814 lang_output_section_statement_type
*os
=
1815 lang_output_section_statement_lookup(s
->name
);
1817 wild_doit(&os
->children
, s
, os
, file
);
1829 * peformed after every file has been opened and symbols read
1836 lang_create_output_section_statements();
1837 lang_open_input(statement_list
.head
, (char *)NULL
,
1838 ( lang_output_section_statement_type
*)NULL
);
1839 lang_place_orphans();
1842 ldemul_before_allocation();
1844 lang_size_sections(statement_list
.head
,
1845 (lang_output_section_statement_type
*)NULL
,
1846 &(statement_list
.head
), 0, (bfd_vma
)0);
1847 ldemul_after_allocation();
1848 /* Do it once again now that we know the sizes of everything */
1850 lang_do_assignments(statement_list
.head
,
1851 (lang_output_section_statement_type
*)NULL
,
1858 lang_relocate_globals();
1868 lang_set_flags(ptr
, flags
)
1869 lang_section_flags_type
*ptr
;
1872 boolean state
= true;
1873 ptr
->flag_read
= false;
1874 ptr
->flag_write
= false;
1875 ptr
->flag_executable
= false;
1876 ptr
->flag_loadable
= false;
1879 if (*flags
== '!') {
1886 ptr
->flag_read
= state
;
1889 ptr
->flag_write
= state
;
1892 ptr
->flag_executable
= state
;
1895 ptr
->flag_loadable
= state
;
1898 info("%P%F illegal syntax in flags\n");
1908 lang_for_each_file(func
)
1911 lang_input_statement_type
*f
;
1912 for (f
= (lang_input_statement_type
*)file_chain
.head
;
1913 f
!= (lang_input_statement_type
*)NULL
;
1914 f
= (lang_input_statement_type
*)f
->next
)
1922 lang_for_each_input_section(func
)
1925 lang_input_statement_type
*f
;
1926 for (f
= (lang_input_statement_type
*)file_chain
.head
;
1927 f
!= (lang_input_statement_type
*)NULL
;
1928 f
= (lang_input_statement_type
*)f
->next
)
1931 for (s
= f
->the_bfd
->sections
;
1932 s
!= (asection
*)NULL
;
1934 func(f
->the_bfd
, s
);
1942 ldlang_add_file(entry
)
1943 lang_input_statement_type
*entry
;
1945 lang_has_input_file
= true;
1946 lang_statement_append(&file_chain
,
1947 (lang_statement_union_type
*)entry
,
1954 lang_add_output(name
)
1957 lang_output_statement_type
*new = new_stat(lang_output_statement
,
1960 had_output_filename
= true;
1964 static lang_output_section_statement_type
*current_section
;
1967 lang_enter_output_section_statement(output_section_statement_name
,
1970 char *output_section_statement_name
;
1971 etree_type
*address_exp
;
1972 bfd_vma block_value
;
1974 lang_output_section_statement_type
*os
;
1977 lang_output_section_statement_lookup(output_section_statement_name
);
1980 /* Add this statement to tree */
1981 /* add_statement(lang_output_section_statement_enum,
1982 output_section_statement);*/
1983 /* Make next things chain into subchain of this */
1985 if (os
->addr_tree
==
1986 (etree_type
*)NULL
) {
1990 os
->block_value
= block_value
;
1991 stat_ptr
= & os
->children
;
1999 if (had_output_filename
== false) {
2000 lang_add_output("a.out");
2010 asymbol
*create_symbol(name
, flags
, section
)
2015 extern lang_input_statement_type
*script_file
;
2016 asymbol
**def_ptr
= (asymbol
**)ldmalloc(sizeof(asymbol
**));
2017 /* Add this definition to script file */
2018 asymbol
*def
= (asymbol
*)bfd_make_empty_symbol(script_file
->the_bfd
);
2022 def
->section
= section
;
2025 Q_enter_global_ref(def_ptr
);
2038 /* EXPORTED TO YACC */
2040 lang_section_start(name
, address
)
2042 etree_type
*address
;
2044 lang_address_statement_type
*ad
=new_stat(lang_address_statement
, stat_ptr
);
2045 ad
->section_name
= name
;
2046 ad
->address
= address
;
2048 void lang_add_entry(name
)
2051 entry_symbol
= name
;
2055 lang_add_target(name
)
2058 lang_target_statement_type
*new = new_stat(lang_target_statement
,
2064 lang_add_wild(section_name
, filename
)
2068 lang_wild_statement_type
*new = new_stat(lang_wild_statement
,
2071 if (section_name
!= (char *)NULL
&& strcmp(section_name
,"COMMON") == 0)
2073 placed_commons
= true;
2075 new->section_name
= section_name
;
2076 new->filename
= filename
;
2077 lang_list_init(&new->children
);
2087 map_option_f
= true;
2094 void lang_add_fill(exp
)
2097 lang_fill_statement_type
*new = new_stat(lang_fill_statement
,
2102 void lang_add_data(type
, exp
)
2104 union etree_union
*exp
;
2107 lang_data_statement_type
*new = new_stat(lang_data_statement
,
2114 lang_add_assignment(exp
)
2117 lang_assignment_statement_type
*new = new_stat(lang_assignment_statement
,
2123 lang_add_attribute(attribute
)
2124 enum statement_enum attribute
;
2126 new_statement(attribute
, sizeof(lang_statement_union_type
),stat_ptr
);
2135 if (startup_file
!= (char *)NULL
) {
2136 info("%P%FMultiple STARTUP files\n");
2138 first_file
->filename
= name
;
2139 first_file
->local_sym_name
= name
;
2147 lang_float_flag
= maybe
;
2151 lang_leave_output_section_statement(fill
, memspec
)
2155 current_section
->fill
= fill
;
2156 current_section
->region
= lang_memory_region_lookup(memspec
);
2157 stat_ptr
= &statement_list
;
2161 lang_abs_symbol_at_beginning_of(section
, name
)
2165 extern bfd
*output_bfd
;
2166 extern asymbol
*create_symbol();
2167 asection
*s
= bfd_get_section_by_name(output_bfd
, section
);
2168 asymbol
*def
= create_symbol(name
,
2169 BSF_GLOBAL
| BSF_EXPORT
|
2172 if (s
!= (asection
*)NULL
) {
2173 def
->value
= s
->vma
;
2181 lang_abs_symbol_at_end_of(section
, name
)
2185 extern bfd
*output_bfd
;
2186 extern asymbol
*create_symbol();
2187 asection
*s
= bfd_get_section_by_name(output_bfd
, section
);
2188 /* Add a symbol called _end */
2189 asymbol
*def
= create_symbol(name
,
2190 BSF_GLOBAL
| BSF_EXPORT
|
2193 if (s
!= (asection
*)NULL
) {
2194 def
->value
= s
->vma
+ s
->size
;
2202 lang_statement_append(list
, element
, field
)
2203 lang_statement_list_type
*list
;
2204 lang_statement_union_type
*element
;
2205 lang_statement_union_type
**field
;
2207 *(list
->tail
) = element
;
2213 lang_for_each_statement_worker(func
, s
)
2215 lang_statement_union_type
*s
;
2217 for (; s
!= (lang_statement_union_type
*)NULL
; s
= s
->next
)
2221 switch (s
->header
.type
) {
2222 case lang_output_section_statement_enum
:
2223 lang_for_each_statement_worker
2225 s
->output_section_statement
.children
.head
);
2227 case lang_wild_statement_enum
:
2228 lang_for_each_statement_worker
2230 s
->wild_statement
.children
.head
);
2232 case lang_data_statement_enum
:
2233 case lang_object_symbols_statement_enum
:
2234 case lang_output_statement_enum
:
2235 case lang_target_statement_enum
:
2236 case lang_common_statement_enum
:
2237 case lang_input_section_enum
:
2238 case lang_input_statement_enum
:
2239 case lang_fill_statement_enum
:
2240 case lang_assignment_statement_enum
:
2241 case lang_padding_statement_enum
:
2242 case lang_address_statement_enum
:
2251 void lang_for_each_statement(func
)
2254 lang_for_each_statement_worker(func
,
2255 statement_list
.head
);