X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=bfd%2Flinker.c;h=1b48f199fe3c10445487383ce603bc74fb7009ca;hb=1e490350fff9619fd30dbea910412308eb7c8661;hp=c359c923191e4a5a284ee4d8035c42899b68106e;hpb=39f27966436499da318f99c3ad922a2ba2d9208b;p=deliverable%2Fbinutils-gdb.git diff --git a/bfd/linker.c b/bfd/linker.c index c359c92319..1b48f199fe 100644 --- a/bfd/linker.c +++ b/bfd/linker.c @@ -631,7 +631,7 @@ bfd_link_add_undef (table, h) /* Routine to create an entry in an generic link hash table. */ struct bfd_hash_entry * -generic_link_hash_newfunc (entry, table, string) +_bfd_generic_link_hash_newfunc (entry, table, string) struct bfd_hash_entry *entry; struct bfd_hash_table *table; const char *string; @@ -675,7 +675,7 @@ _bfd_generic_link_hash_table_create (abfd) if (ret == NULL) return (struct bfd_link_hash_table *) NULL; if (! _bfd_link_hash_table_init (&ret->root, abfd, - generic_link_hash_newfunc)) + _bfd_generic_link_hash_newfunc)) { free (ret); return (struct bfd_link_hash_table *) NULL; @@ -1397,7 +1397,7 @@ static const enum link_action link_action[8][8] = /* DEFW_ROW */ {DEFW, DEFW, DEFW, NOACT, NOACT, NOACT, NOACT, CYCLE }, /* COMMON_ROW */ {COM, COM, COM, CREF, CREF, BIG, CREF, WARNC }, /* INDR_ROW */ {IND, IND, IND, MDEF, IND, CIND, MIND, CYCLE }, - /* WARN_ROW */ {MWARN, WARN, WARN, CWARN, CWARN, WARN, CWARN, CYCLE }, + /* WARN_ROW */ {MWARN, WARN, WARN, CWARN, CWARN, WARN, CWARN, MWARN }, /* SET_ROW */ {SET, SET, SET, SET, SET, SET, CYCLE, CYCLE } }; @@ -1521,11 +1521,13 @@ _bfd_generic_link_add_one_symbol (info, abfd, name, flags, section, value, } } - if (info->notice_hash != (struct bfd_hash_table *) NULL - && (bfd_hash_lookup (info->notice_hash, name, false, false) - != (struct bfd_hash_entry *) NULL)) + if (info->notice_all + || (info->notice_hash != (struct bfd_hash_table *) NULL + && (bfd_hash_lookup (info->notice_hash, name, false, false) + != (struct bfd_hash_entry *) NULL))) { - if (! (*info->callbacks->notice) (info, name, abfd, section, value)) + if (! (*info->callbacks->notice) (info, h->root.string, abfd, section, + value)) return false; } @@ -1565,7 +1567,7 @@ _bfd_generic_link_add_one_symbol (info, abfd, name, flags, section, value, previously common. */ BFD_ASSERT (h->type == bfd_link_hash_common); if (! ((*info->callbacks->multiple_common) - (info, name, + (info, h->root.string, h->u.c.p->section->owner, bfd_link_hash_common, h->u.c.size, abfd, bfd_link_hash_defined, (bfd_vma) 0))) return false; @@ -1628,7 +1630,7 @@ _bfd_generic_link_add_one_symbol (info, abfd, name, flags, section, value, if (! ((*info->callbacks->constructor) (info, c == 'I' ? true : false, - name, abfd, section, value))) + h->root.string, abfd, section, value))) return false; } } @@ -1699,7 +1701,7 @@ _bfd_generic_link_add_one_symbol (info, abfd, name, flags, section, value, two sizes. */ BFD_ASSERT (h->type == bfd_link_hash_common); if (! ((*info->callbacks->multiple_common) - (info, name, + (info, h->root.string, h->u.c.p->section->owner, bfd_link_hash_common, h->u.c.size, abfd, bfd_link_hash_common, value))) return false; @@ -1732,7 +1734,7 @@ _bfd_generic_link_add_one_symbol (info, abfd, name, flags, section, value, else obfd = NULL; if (! ((*info->callbacks->multiple_common) - (info, name, obfd, h->type, (bfd_vma) 0, + (info, h->root.string, obfd, h->type, (bfd_vma) 0, abfd, bfd_link_hash_common, value))) return false; } @@ -1773,8 +1775,8 @@ _bfd_generic_link_add_one_symbol (info, abfd, name, flags, section, value, break; if (! ((*info->callbacks->multiple_definition) - (info, name, msec->owner, msec, mval, abfd, section, - value))) + (info, h->root.string, msec->owner, msec, mval, abfd, + section, value))) return false; } break; @@ -1783,7 +1785,7 @@ _bfd_generic_link_add_one_symbol (info, abfd, name, flags, section, value, /* Create an indirect symbol from an existing common symbol. */ BFD_ASSERT (h->type == bfd_link_hash_common); if (! ((*info->callbacks->multiple_common) - (info, name, + (info, h->root.string, h->u.c.p->section->owner, bfd_link_hash_common, h->u.c.size, abfd, bfd_link_hash_indirect, (bfd_vma) 0))) return false; @@ -1831,8 +1833,9 @@ _bfd_generic_link_add_one_symbol (info, abfd, name, flags, section, value, /* Issue a warning and cycle. */ if (h->u.i.warning != NULL) { - if (! (*info->callbacks->warning) (info, h->u.i.warning, name, - abfd, (asection *) NULL, + if (! (*info->callbacks->warning) (info, h->u.i.warning, + h->root.string, abfd, + (asection *) NULL, (bfd_vma) 0)) return false; /* Only issue a warning once. */ @@ -1855,7 +1858,7 @@ _bfd_generic_link_add_one_symbol (info, abfd, name, flags, section, value, case WARN: /* Issue a warning. */ - if (! (*info->callbacks->warning) (info, string, name, + if (! (*info->callbacks->warning) (info, string, h->root.string, hash_entry_bfd (h), (asection *) NULL, (bfd_vma) 0)) return false; @@ -1869,7 +1872,7 @@ _bfd_generic_link_add_one_symbol (info, abfd, name, flags, section, value, ensure this. */ if (h->next != NULL || info->hash->undefs_tail == h) { - if (! (*info->callbacks->warning) (info, string, name, + if (! (*info->callbacks->warning) (info, string, h->root.string, hash_entry_bfd (h), (asection *) NULL, (bfd_vma) 0)) @@ -1937,6 +1940,12 @@ _bfd_generic_final_link (abfd, info) abfd->symcount = 0; outsymalloc = 0; + /* Mark all sections which will be included in the output file. */ + for (o = abfd->sections; o != NULL; o = o->next) + for (p = o->link_order_head; p != NULL; p = p->next) + if (p->type == bfd_indirect_link_order) + p->u.indirect.section->linker_mark = true; + /* Build the output symbol table. */ for (sub = info->input_bfds; sub != (bfd *) NULL; sub = sub->link_next) if (! _bfd_generic_link_output_symbols (abfd, sub, info, &outsymalloc)) @@ -2221,10 +2230,11 @@ _bfd_generic_link_output_symbols (output_bfd, input_bfd, info, psymalloc) /* This switch is straight from the old code in write_file_locals in ldsym.c. */ - if (info->strip == strip_some - && (bfd_hash_lookup (info->keep_hash, bfd_asymbol_name (sym), - false, false) - == (struct bfd_hash_entry *) NULL)) + if (info->strip == strip_all + || (info->strip == strip_some + && (bfd_hash_lookup (info->keep_hash, bfd_asymbol_name (sym), + false, false) + == (struct bfd_hash_entry *) NULL))) output = false; else if ((sym->flags & (BSF_GLOBAL | BSF_WEAK)) != 0) { @@ -2287,6 +2297,11 @@ _bfd_generic_link_output_symbols (output_bfd, input_bfd, info, psymalloc) else abort (); + /* If this symbol is in a section which is not being included + in the output file, then we don't want to output the symbol. */ + if (sym->section->linker_mark == false) + output = false; + if (output) { if (! generic_add_output_symbol (output_bfd, psymalloc, sym)) @@ -2646,7 +2661,11 @@ default_indirect_link_order (output_bfd, info, output_section, link_order, because somebody is attempting to link together different types of object files. Handling this case correctly is difficult, and sometimes impossible. */ - abort (); + (*_bfd_error_handler) + ("Attempt to do relocateable link with %s input and %s output", + bfd_get_target (input_bfd), bfd_get_target (output_bfd)); + bfd_set_error (bfd_error_wrong_format); + return false; } if (! generic_linker)