329ae8bef979dc4e4e08656574dd9c723a2cc4b4
[deliverable/binutils-gdb.git] / ld / ldmain.c
1 /* Copyright (C) 1991 Free Software Foundation, Inc.
2 Written by Steve Chamberlain steve@cygnus.com
3
4 This file is part of GLD, the Gnu Linker.
5
6 GLD is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
10
11 GLD is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with GLD; see the file COPYING. If not, write to
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
19
20
21 #include "bfd.h"
22 #include "sysdep.h"
23
24 #include "config.h"
25 #include "ld.h"
26 #include "ldmain.h"
27 #include "ldmisc.h"
28 #include "ldwrite.h"
29 #include "ldgram.h"
30 #include "ldsym.h"
31 #include "ldlang.h"
32 #include "ldemul.h"
33 #include "ldlex.h"
34 #include "ldfile.h"
35 #include "ldindr.h"
36 #include "ldwarn.h"
37 #include "ldctor.h"
38 #include "lderror.h"
39
40 /* IMPORTS */
41 extern boolean lang_has_input_file;
42 extern boolean trace_files;
43 /* EXPORTS */
44
45 char *default_target;
46 char *output_filename = "a.out";
47 /* Name this program was invoked by. */
48 char *program_name;
49
50 /* The file that we're creating */
51 bfd *output_bfd = 0;
52
53 extern boolean option_v;
54
55 /* The local symbol prefix */
56 char lprefix = 'L';
57
58 /* Count the number of global symbols multiply defined. */
59 int multiple_def_count;
60
61
62 /* Count the number of symbols defined through common declarations.
63 This count is referenced in symdef_library, linear_library, and
64 modified by enter_global_ref.
65
66 It is incremented when a symbol is created as a common, and
67 decremented when the common declaration is overridden
68
69 Another way of thinking of it is that this is a count of
70 all ldsym_types with a ->scoms field */
71
72 unsigned int commons_pending;
73
74 /* Count the number of global symbols referenced and not defined.
75 common symbols are not included in this count. */
76
77 unsigned int undefined_global_sym_count;
78
79
80
81 /* Count the number of warning symbols encountered. */
82 int warning_count;
83
84 /* have we had a load script ? */
85 extern boolean had_script;
86
87 /* Nonzero means print names of input files as processed. */
88 boolean trace_files;
89
90
91
92 /* 1 => write load map. */
93 boolean write_map;
94
95
96 int unix_relocate;
97 #ifdef GNU960
98 /* Indicates whether output file will be b.out (default) or coff */
99 enum target_flavour output_flavor = BFD_BOUT_FORMAT;
100 #endif
101
102 /* Force the make_executable to be output, even if there are non-fatal
103 errors */
104 boolean force_make_executable;
105
106 /* A count of the total number of local symbols ever seen - by adding
107 the symbol_count field of each newly read afile.*/
108
109 unsigned int total_symbols_seen;
110
111 /* A count of the number of read files - the same as the number of elements
112 in file_chain
113 */
114 unsigned int total_files_seen;
115
116
117 /* IMPORTS */
118 args_type command_line;
119 ld_config_type config;
120 void
121 main (argc, argv)
122 char **argv;
123 int argc;
124 {
125 char *emulation;
126 program_name = argv[0];
127 output_filename = "a.out";
128
129 bfd_init();
130
131 #ifdef GNU960
132 {
133 int i;
134
135 check_v960( argc, argv );
136 emulation = "gld960";
137 for ( i = 1; i < argc; i++ ){
138 if ( !strcmp(argv[i],"-Fcoff") ){
139 emulation = "lnk960";
140 output_flavor = BFD_COFF_FORMAT;
141 break;
142 }
143 }
144 }
145 #else
146 emulation = (char *) getenv(EMULATION_ENVIRON);
147 #endif
148
149 /* Initialize the data about options. */
150
151
152 trace_files = false;
153 write_map = false;
154 config.relocateable_output = false;
155 unix_relocate = 0;
156 command_line.force_common_definition = false;
157
158 init_bfd_error_vector();
159 ldsym_init();
160 ldfile_add_arch("");
161
162 config.make_executable = true;
163 force_make_executable = false;
164
165
166 /* Initialize the cumulative counts of symbols. */
167 undefined_global_sym_count = 0;
168 warning_count = 0;
169 multiple_def_count = 0;
170 commons_pending = 0;
171
172 config.magic_demand_paged = true;
173 config.text_read_only = true;
174 config.make_executable = true;
175 if (emulation == (char *)NULL) {
176 emulation= DEFAULT_EMULATION;
177 }
178
179 ldemul_choose_mode(emulation);
180 default_target = ldemul_choose_target();
181 lang_init();
182 ldemul_before_parse();
183 lang_has_input_file = false;
184 parse_args(argc, argv);
185 lang_final();
186
187 if (trace_files) {
188
189 info("%P: mode %s\n", emulation);
190
191 }
192 if (lang_has_input_file == false) {
193 einfo("%P%F: No input files\n");
194 }
195
196 ldemul_after_parse();
197
198
199 if (config.map_filename)
200 {
201 if (strcmp(config.map_filename, "-") == 0)
202 {
203 config.map_file = stdout;
204 }
205 else {
206 config.map_file = fopen(config.map_filename, FOPEN_WT);
207 if (config.map_file == (FILE *)NULL)
208 {
209 einfo("%P%F: can't open map file %s\n",
210 config.map_filename);
211 }
212 }
213 }
214
215
216 lang_process();
217
218 /* Print error messages for any missing symbols, for any warning
219 symbols, and possibly multiple definitions */
220
221
222 if (config.text_read_only)
223 {
224 /* Look for a text section and mark the readonly attribute in it */
225 asection *found = bfd_get_section_by_name(output_bfd, ".text");
226 if (found != (asection *)NULL) {
227 found->flags |= SEC_READONLY;
228 }
229 }
230
231 if (config.relocateable_output) {
232 output_bfd->flags &= ~EXEC_P;
233
234 ldwrite();
235 bfd_close(output_bfd);
236 }
237
238 else
239 {
240
241 output_bfd->flags |= EXEC_P;
242
243 ldwrite();
244
245
246 if (config.make_executable == false && force_make_executable ==false)
247 {
248
249 if (trace_files == true)
250 {
251 einfo("%P: Link errors found, deleting executable `%s'\n",
252 output_filename);
253 }
254
255 if (output_bfd->iostream)
256 fclose((FILE*)(output_bfd->iostream));
257
258 unlink(output_filename);
259 exit(1);
260 }
261 else {
262 bfd_close(output_bfd);
263 }
264 }
265
266
267
268 exit(0);
269 } /* main() */
270
271
272 void
273 Q_read_entry_symbols (desc, entry)
274 bfd *desc;
275 struct lang_input_statement_struct *entry;
276 {
277 if (entry->asymbols == (asymbol **)NULL) {
278 bfd_size_type table_size = get_symtab_upper_bound(desc);
279 entry->asymbols = (asymbol **)ldmalloc(table_size);
280 entry->symbol_count = bfd_canonicalize_symtab(desc, entry->asymbols) ;
281 }
282 }
283
284
285 /*
286 * turn this item into a reference
287 */
288 void
289 refize(sp, nlist_p)
290 ldsym_type *sp;
291 asymbol **nlist_p;
292 {
293 asymbol *sym = *nlist_p;
294 sym->value = 0;
295 sym->flags = 0;
296 sym->section = &bfd_und_section;
297 sym->udata =(PTR)( sp->srefs_chain);
298 sp->srefs_chain = nlist_p;
299 }
300 /*
301 This function is called for each name which is seen which has a global
302 scope. It enters the name into the global symbol table in the correct
303 symbol on the correct chain. Remember that each ldsym_type has three
304 chains attatched, one of all definitions of a symbol, one of all
305 references of a symbol and one of all common definitions of a symbol.
306
307 When the function is over, the supplied is left connected to the bfd
308 to which is was born, with its udata field pointing to the next member
309 on the chain in which it has been inserted.
310
311 A certain amount of jigery pokery is necessary since commons come
312 along and upset things, we only keep one item in the common chain; the
313 one with the biggest size seen sofar. When another common comes along
314 it either bumps the previous definition into the ref chain, since it
315 is bigger, or gets turned into a ref on the spot since the one on the
316 common chain is already bigger. If a real definition comes along then
317 the common gets bumped off anyway.
318
319 Whilst all this is going on we keep a count of the number of multiple
320 definitions seen, undefined global symbols and pending commons.
321 */
322
323 extern boolean relaxing;
324
325 void
326 DEFUN(Q_enter_global_ref,(nlist_p, name),
327 asymbol **nlist_p AND /* pointer into symbol table from incoming bfd */
328 CONST char *name /* name of symbol in linker table */ )
329 {
330 asymbol *sym = *nlist_p;
331 ldsym_type *sp ;
332
333 /* Lookup the name from the incoming bfd's symbol table in the
334 linker's global symbol table */
335
336
337 flagword this_symbol_flags = sym->flags;
338 sp = ldsym_get (name);
339
340 ASSERT(sym->udata == 0);
341
342
343 if (flag_is_constructor(this_symbol_flags)) {
344 /* Add this constructor to the list we keep */
345 ldlang_add_constructor(sp);
346 /* Turn any commons into refs */
347 if (sp->scoms_chain != (asymbol **)NULL) {
348 refize(sp, sp->scoms_chain);
349 sp->scoms_chain = 0;
350 }
351
352
353 }
354 else {
355 if (sym->section == &bfd_com_section) {
356 /* If we have a definition of this symbol already then
357 this common turns into a reference. Also we only
358 ever point to the largest common, so if we
359 have a common, but it's bigger that the new symbol
360 the turn this into a reference too. */
361 if (sp->sdefs_chain)
362 {
363 /* This is a common symbol, but we already have a definition
364 for it, so just link it into the ref chain as if
365 it were a reference */
366 refize(sp, nlist_p);
367 }
368 else if (sp->scoms_chain) {
369 /* If we have a previous common, keep only the biggest */
370 if ( (*(sp->scoms_chain))->value > sym->value) {
371 /* other common is bigger, throw this one away */
372 refize(sp, nlist_p);
373 }
374 else if (sp->scoms_chain != nlist_p) {
375 /* other common is smaller, throw that away */
376 refize(sp, sp->scoms_chain);
377 sp->scoms_chain = nlist_p;
378 }
379 }
380 else {
381 /* This is the first time we've seen a common, so remember it
382 - if it was undefined before, we know it's defined now. If
383 the symbol has been marked as really being a constructor,
384 then treat this as a ref
385 */
386 if (sp->flags & SYM_CONSTRUCTOR) {
387 /* Turn this into a ref */
388 refize(sp, nlist_p);
389 }
390 else {
391 /* treat like a common */
392 if (sp->srefs_chain)
393 undefined_global_sym_count--;
394
395 commons_pending++;
396 sp->scoms_chain = nlist_p;
397 }
398 }
399 }
400
401 else if (sym->section != &bfd_und_section) {
402 /* This is the definition of a symbol, add to def chain */
403 if (sp->sdefs_chain && (*(sp->sdefs_chain))->section != sym->section) {
404 /* Multiple definition */
405 asymbol *sy = *(sp->sdefs_chain);
406 lang_input_statement_type *stat = (lang_input_statement_type *) sy->the_bfd->usrdata;
407 lang_input_statement_type *stat1 = (lang_input_statement_type *) sym->the_bfd->usrdata;
408 asymbol ** stat1_symbols = stat1 ? stat1->asymbols: 0;
409 asymbol ** stat_symbols = stat ? stat->asymbols:0;
410
411 multiple_def_count++;
412 einfo("%X%C: multiple definition of `%T'\n",
413 sym->the_bfd, sym->section, stat1_symbols, sym->value, sym);
414
415 einfo("%X%C: first seen here\n",
416 sy->the_bfd, sy->section, stat_symbols, sy->value);
417 }
418 else {
419 sym->udata =(PTR)( sp->sdefs_chain);
420 sp->sdefs_chain = nlist_p;
421 }
422 /* A definition overrides a common symbol */
423 if (sp->scoms_chain) {
424 refize(sp, sp->scoms_chain);
425 sp->scoms_chain = 0;
426 commons_pending--;
427 }
428 else if (sp->srefs_chain && relaxing == false) {
429 /* If previously was undefined, then remember as defined */
430 undefined_global_sym_count--;
431 }
432 }
433 else {
434 if (sp->scoms_chain == (asymbol **)NULL
435 && sp->srefs_chain == (asymbol **)NULL
436 && sp->sdefs_chain == (asymbol **)NULL) {
437 /* And it's the first time we've seen it */
438 undefined_global_sym_count++;
439
440 }
441
442 refize(sp, nlist_p);
443 }
444 }
445
446 ASSERT(sp->sdefs_chain == 0 || sp->scoms_chain == 0);
447 ASSERT(sp->scoms_chain ==0 || (*(sp->scoms_chain))->udata == 0);
448
449
450 }
451
452 static void
453 Q_enter_file_symbols (entry)
454 lang_input_statement_type *entry;
455 {
456 asymbol **q ;
457
458 entry->common_section =
459 bfd_make_section_old_way(entry->the_bfd, "COMMON");
460
461 ldlang_add_file(entry);
462
463
464 if (trace_files || option_v) {
465 info("%I\n", entry);
466 }
467
468 total_symbols_seen += entry->symbol_count;
469 total_files_seen ++;
470 if (entry->symbol_count)
471 for (q = entry->asymbols; *q; q++)
472 {
473 asymbol *p = *q;
474
475 if (p->flags & BSF_INDIRECT)
476 {
477 add_indirect(q);
478 }
479 else if (p->flags & BSF_WARNING)
480 {
481 add_warning(p);
482 }
483 else if (p->section == &bfd_und_section
484 || (p->flags & BSF_GLOBAL)
485 || p->section == &bfd_com_section
486 || (p->flags & BSF_CONSTRUCTOR))
487 {
488 Q_enter_global_ref(q, p->name);
489 }
490
491
492 }
493 }
494
495
496
497 /* Searching libraries */
498
499 struct lang_input_statement_struct *decode_library_subfile ();
500 void linear_library (), symdef_library ();
501
502 /* Search the library ENTRY, already open on descriptor DESC.
503 This means deciding which library members to load,
504 making a chain of `struct lang_input_statement_struct' for those members,
505 and entering their global symbols in the hash table. */
506
507 void
508 search_library (entry)
509 struct lang_input_statement_struct *entry;
510 {
511
512 /* No need to load a library if no undefined symbols */
513 if (!undefined_global_sym_count) return;
514
515 if (bfd_has_map(entry->the_bfd))
516 symdef_library (entry);
517 else
518 linear_library (entry);
519
520 }
521
522
523 #ifdef GNU960
524 static
525 boolean
526 gnu960_check_format (abfd, format)
527 bfd *abfd;
528 bfd_format format;
529 {
530 boolean retval;
531
532 if ((bfd_check_format(abfd,format) == true)
533 && (abfd->xvec->flavour == output_flavor) ){
534 return true;
535 }
536
537
538 return false;
539 }
540 #endif
541
542 void
543 ldmain_open_file_read_symbol (entry)
544 struct lang_input_statement_struct *entry;
545 {
546 if (entry->asymbols == (asymbol **)NULL
547 &&entry->real == true
548 && entry->filename != (char *)NULL)
549 {
550 ldfile_open_file (entry);
551
552
553 #ifdef GNU960
554 if (gnu960_check_format(entry->the_bfd, bfd_object))
555 #else
556 if (bfd_check_format(entry->the_bfd, bfd_object))
557 #endif
558 {
559 entry->the_bfd->usrdata = (PTR)entry;
560
561
562 Q_read_entry_symbols (entry->the_bfd, entry);
563
564 /* look through the sections in the file and see if any of them
565 are constructors */
566 ldlang_check_for_constructors (entry);
567
568 Q_enter_file_symbols (entry);
569 }
570 #ifdef GNU960
571 else if (gnu960_check_format(entry->the_bfd, bfd_archive))
572 #else
573 else if (bfd_check_format(entry->the_bfd, bfd_archive))
574 #endif
575 {
576 entry->the_bfd->usrdata = (PTR)entry;
577
578 entry->subfiles = (lang_input_statement_type *)NULL;
579 search_library (entry);
580 }
581 else
582 {
583 einfo("%F%B: malformed input file (not rel or archive) \n",
584 entry->the_bfd);
585 }
586 }
587
588 }
589
590
591 /* Construct and return a lang_input_statement_struct for a library member.
592 The library's lang_input_statement_struct is library_entry,
593 and the library is open on DESC.
594 SUBFILE_OFFSET is the byte index in the library of this member's header.
595 We store the length of the member into *LENGTH_LOC. */
596
597 lang_input_statement_type *
598 decode_library_subfile (library_entry, subfile_offset)
599 struct lang_input_statement_struct *library_entry;
600 bfd *subfile_offset;
601 {
602 register struct lang_input_statement_struct *subentry;
603 subentry = (struct lang_input_statement_struct *) ldmalloc ((bfd_size_type)(sizeof (struct lang_input_statement_struct)));
604 subentry->filename = subfile_offset -> filename;
605 subentry->local_sym_name = subfile_offset->filename;
606 subentry->asymbols = 0;
607 subentry->the_bfd = subfile_offset;
608 subentry->subfiles = 0;
609 subentry->next = 0;
610 subentry->superfile = library_entry;
611 subentry->is_archive = false;
612
613 subentry->just_syms_flag = false;
614 subentry->loaded = false;
615 subentry->chain = 0;
616
617 return subentry;
618 }
619
620 boolean subfile_wanted_p ();
621 void
622 clear_syms(entry, offset)
623 struct lang_input_statement_struct *entry;
624 file_ptr offset;
625 {
626 carsym *car;
627 unsigned long indx = bfd_get_next_mapent(entry->the_bfd,
628 BFD_NO_MORE_SYMBOLS,
629 &car);
630 while (indx != BFD_NO_MORE_SYMBOLS) {
631 if (car->file_offset == offset) {
632 car->name = 0;
633 }
634 indx = bfd_get_next_mapent(entry->the_bfd, indx, &car);
635 }
636
637 }
638
639 /* Search a library that has a map
640 */
641 void
642 symdef_library (entry)
643 struct lang_input_statement_struct *entry;
644
645 {
646 register struct lang_input_statement_struct *prev = 0;
647
648 boolean not_finished = true;
649
650
651 while (not_finished == true)
652 {
653 carsym *exported_library_name;
654 bfd *prev_archive_member_bfd = 0;
655
656 int idx = bfd_get_next_mapent(entry->the_bfd,
657 BFD_NO_MORE_SYMBOLS,
658 &exported_library_name);
659
660 not_finished = false;
661
662 while (idx != BFD_NO_MORE_SYMBOLS && undefined_global_sym_count)
663 {
664
665 if (exported_library_name->name)
666 {
667
668 ldsym_type *sp = ldsym_get_soft (exported_library_name->name);
669
670 /* If we find a symbol that appears to be needed, think carefully
671 about the archive member that the symbol is in. */
672 /* So - if it exists, and is referenced somewhere and is
673 undefined or */
674 if (sp && sp->srefs_chain && !sp->sdefs_chain)
675 {
676 bfd *archive_member_bfd = bfd_get_elt_at_index(entry->the_bfd, idx);
677 struct lang_input_statement_struct *archive_member_lang_input_statement_struct;
678
679 #ifdef GNU960
680 if (archive_member_bfd && gnu960_check_format(archive_member_bfd, bfd_object))
681 #else
682 if (archive_member_bfd && bfd_check_format(archive_member_bfd, bfd_object))
683 #endif
684 {
685
686 /* Don't think carefully about any archive member
687 more than once in a given pass. */
688 if (prev_archive_member_bfd != archive_member_bfd)
689 {
690
691 prev_archive_member_bfd = archive_member_bfd;
692
693 /* Read the symbol table of the archive member. */
694
695 if (archive_member_bfd->usrdata != (PTR)NULL) {
696
697 archive_member_lang_input_statement_struct =(lang_input_statement_type *) archive_member_bfd->usrdata;
698 }
699 else {
700
701 archive_member_lang_input_statement_struct =
702 decode_library_subfile (entry, archive_member_bfd);
703 archive_member_bfd->usrdata = (PTR) archive_member_lang_input_statement_struct;
704
705 }
706
707 if (archive_member_lang_input_statement_struct == 0) {
708 einfo ("%F%I contains invalid archive member %s\n",
709 entry, sp->name);
710 }
711
712 if (archive_member_lang_input_statement_struct->loaded == false)
713 {
714
715 Q_read_entry_symbols (archive_member_bfd, archive_member_lang_input_statement_struct);
716 /* Now scan the symbol table and decide whether to load. */
717
718
719 if (subfile_wanted_p (archive_member_lang_input_statement_struct) == true)
720
721 {
722 /* This member is needed; load it.
723 Since we are loading something on this pass,
724 we must make another pass through the symdef data. */
725
726 not_finished = true;
727
728 Q_enter_file_symbols (archive_member_lang_input_statement_struct);
729
730 if (prev)
731 prev->chain = archive_member_lang_input_statement_struct;
732 else
733 entry->subfiles = archive_member_lang_input_statement_struct;
734
735
736 prev = archive_member_lang_input_statement_struct;
737
738
739 /* Clear out this member's symbols from the symdef data
740 so that following passes won't waste time on them. */
741 clear_syms(entry, exported_library_name->file_offset);
742 archive_member_lang_input_statement_struct->loaded = true;
743 }
744 }
745 }
746 }
747 }
748 }
749 idx = bfd_get_next_mapent(entry->the_bfd, idx, &exported_library_name);
750 }
751 }
752 }
753
754 void
755 linear_library (entry)
756 struct lang_input_statement_struct *entry;
757 {
758 boolean more_to_do = true;
759 register struct lang_input_statement_struct *prev = 0;
760
761 if (entry->complained == false) {
762 einfo("%P: library %s has bad table of contents, rerun ranlib\n",
763 entry->the_bfd->filename);
764 entry->complained = true;
765 }
766 while (more_to_do) {
767
768 bfd * archive = bfd_openr_next_archived_file(entry->the_bfd,0);
769
770 more_to_do = false;
771 while (archive) {
772 #ifdef GNU960
773 if (gnu960_check_format(archive, bfd_object))
774 #else
775 if (bfd_check_format(archive, bfd_object))
776 #endif
777 {
778 register struct lang_input_statement_struct *subentry;
779
780 subentry = decode_library_subfile (entry,
781 archive);
782
783 archive->usrdata = (PTR) subentry;
784 if (!subentry) return;
785 if (subentry->loaded == false) {
786 Q_read_entry_symbols (archive, subentry);
787
788 if (subfile_wanted_p (subentry) == true)
789 {
790 Q_enter_file_symbols (subentry);
791
792 if (prev)
793 prev->chain = subentry;
794 else
795 entry->subfiles = subentry;
796 prev = subentry;
797
798 more_to_do = true;
799 subentry->loaded = true;
800 }
801 }
802 }
803 archive = bfd_openr_next_archived_file(entry->the_bfd,archive);
804
805 }
806
807 }
808 }
809
810 /* ENTRY is an entry for a file inside an archive
811 Its symbols have been read into core, but not entered into the
812 linker ymbol table
813 Return nonzero if we ought to load this file */
814
815 boolean
816 subfile_wanted_p (entry)
817 struct lang_input_statement_struct *entry;
818 {
819 asymbol **q;
820
821 for (q = entry->asymbols; *q; q++)
822 {
823 asymbol *p = *q;
824
825 /* If the symbol has an interesting definition, we could
826 potentially want it. */
827
828 if (p->flags & BSF_INDIRECT)
829 {
830 /** add_indirect(q);*/
831 }
832
833 if (p->section == &bfd_com_section
834 || (p->flags & BSF_GLOBAL)
835 || (p->flags & BSF_INDIRECT))
836 {
837 register ldsym_type *sp = ldsym_get_soft (p->name);
838
839
840 /* If this symbol has not been hashed,
841 we can't be looking for it. */
842 if (sp != (ldsym_type *)NULL
843 && sp->sdefs_chain == (asymbol **)NULL) {
844 if (sp->srefs_chain != (asymbol **)NULL
845 || sp->scoms_chain != (asymbol **)NULL)
846 {
847 /* This is a symbol we are looking for. It is either
848 not yet defined or common. */
849
850 if (p->section == &bfd_com_section)
851 {
852
853 /* If the symbol in the table is a constructor, we won't to
854 anything fancy with it */
855 if ((sp->flags & SYM_CONSTRUCTOR) == 0) {
856 /* This libary member has something to
857 say about this element. We should
858 remember if its a new size */
859 /* Move something from the ref list to the com list */
860 if(sp->scoms_chain) {
861 /* Already a common symbol, maybe update it */
862 if (p->value > (*(sp->scoms_chain))->value) {
863 (*(sp->scoms_chain))->value = p->value;
864 }
865 }
866 else {
867 /* Take a value from the ref chain
868 Here we are moving a symbol from the owning bfd
869 to another bfd. We must set up the
870 common_section portion of the bfd thing */
871
872
873
874 sp->scoms_chain = sp->srefs_chain;
875 sp->srefs_chain =
876 (asymbol **)((*(sp->srefs_chain))->udata);
877 (*(sp->scoms_chain))->udata = (PTR)NULL;
878
879 (*( sp->scoms_chain))->section =
880 &bfd_com_section;
881 (*( sp->scoms_chain))->flags = 0;
882 /* Remember the size of this item */
883 sp->scoms_chain[0]->value = p->value;
884 commons_pending++;
885 undefined_global_sym_count--;
886 } {
887 asymbol *com = *(sp->scoms_chain);
888 if (((lang_input_statement_type *)
889 (com->the_bfd->usrdata))->common_section ==
890 (asection *)NULL) {
891 ((lang_input_statement_type *)
892 (com->the_bfd->usrdata))->common_section =
893 bfd_make_section_old_way(com->the_bfd, "COMMON");
894 }
895 }
896 }
897 ASSERT(p->udata == 0);
898 }
899
900 else {
901 if (write_map)
902 {
903 info("%I needed due to %s\n",entry, sp->name);
904 }
905 return true;
906 }
907 }
908 }
909 }
910 }
911
912 return false;
913 }
914
915
This page took 0.049941 seconds and 4 git commands to generate.