X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=bfd%2Flinker.c;h=533eff8715d5375e462ce20a20e1816203ef3b94;hb=de5b02b698cb34f1a7f7f0be87d140f88297da0e;hp=f2290e0ccdf99210fb81f864e2ec3f3f50c47d4a;hpb=a6af384b19c63bab4a1803c09592c5b5bd8674c2;p=deliverable%2Fbinutils-gdb.git diff --git a/bfd/linker.c b/bfd/linker.c index f2290e0ccd..533eff8715 100644 --- a/bfd/linker.c +++ b/bfd/linker.c @@ -1,5 +1,5 @@ /* linker.c -- BFD linker routines - Copyright (C) 1993-2015 Free Software Foundation, Inc. + Copyright (C) 1993-2016 Free Software Foundation, Inc. Written by Steve Chamberlain and Ian Lance Taylor, Cygnus Support This file is part of BFD, the Binary File Descriptor library. @@ -1475,7 +1475,8 @@ _bfd_generic_link_add_one_symbol (struct bfd_link_info *info, else if (bfd_is_com_section (section)) { row = COMMON_ROW; - if (strcmp (name, "__gnu_lto_slim") == 0) + if (!bfd_link_relocatable (info) + && strcmp (name, "__gnu_lto_slim") == 0) (*_bfd_error_handler) (_("%s: plugin needed to handle lto object"), bfd_get_filename (abfd)); @@ -1543,9 +1544,8 @@ _bfd_generic_link_add_one_symbol (struct bfd_link_info *info, /* We have found a definition for a symbol which was previously common. */ BFD_ASSERT (h->type == bfd_link_hash_common); - if (! ((*info->callbacks->multiple_common) - (info, h, abfd, bfd_link_hash_defined, 0))) - return FALSE; + (*info->callbacks->multiple_common) (info, h, abfd, + bfd_link_hash_defined, 0); /* Fall through. */ case DEF: case DEFW: @@ -1602,10 +1602,9 @@ _bfd_generic_link_add_one_symbol (struct bfd_link_info *info, if (oldtype == bfd_link_hash_defweak) abort (); - if (! ((*info->callbacks->constructor) - (info, c == 'I', - h->root.string, abfd, section, value))) - return FALSE; + (*info->callbacks->constructor) (info, c == 'I', + h->root.string, abfd, + section, value); } } } @@ -1674,9 +1673,8 @@ _bfd_generic_link_add_one_symbol (struct bfd_link_info *info, already had a common definition. Use the maximum of the two sizes, and use the section required by the larger symbol. */ BFD_ASSERT (h->type == bfd_link_hash_common); - if (! ((*info->callbacks->multiple_common) - (info, h, abfd, bfd_link_hash_common, value))) - return FALSE; + (*info->callbacks->multiple_common) (info, h, abfd, + bfd_link_hash_common, value); if (value > h->u.c.size) { unsigned int power; @@ -1714,9 +1712,8 @@ _bfd_generic_link_add_one_symbol (struct bfd_link_info *info, case CREF: /* We have found a common definition for a symbol which was already defined. */ - if (! ((*info->callbacks->multiple_common) - (info, h, abfd, bfd_link_hash_common, value))) - return FALSE; + (*info->callbacks->multiple_common) (info, h, abfd, + bfd_link_hash_common, value); break; case MIND: @@ -1727,17 +1724,15 @@ _bfd_generic_link_add_one_symbol (struct bfd_link_info *info, /* Fall through. */ case MDEF: /* Handle a multiple definition. */ - if (! ((*info->callbacks->multiple_definition) - (info, h, abfd, section, value))) - return FALSE; + (*info->callbacks->multiple_definition) (info, h, + abfd, section, value); break; case CIND: /* Create an indirect symbol from an existing common symbol. */ BFD_ASSERT (h->type == bfd_link_hash_common); - if (! ((*info->callbacks->multiple_common) - (info, h, abfd, bfd_link_hash_indirect, 0))) - return FALSE; + (*info->callbacks->multiple_common) (info, h, abfd, + bfd_link_hash_indirect, 0); /* Fall through. */ case IND: if (inh->type == bfd_link_hash_indirect @@ -1778,9 +1773,8 @@ _bfd_generic_link_add_one_symbol (struct bfd_link_info *info, case SET: /* Add an entry to a set. */ - if (! (*info->callbacks->add_to_set) (info, h, BFD_RELOC_CTOR, - abfd, section, value)) - return FALSE; + (*info->callbacks->add_to_set) (info, h, BFD_RELOC_CTOR, + abfd, section, value); break; case WARNC: @@ -1789,10 +1783,8 @@ _bfd_generic_link_add_one_symbol (struct bfd_link_info *info, if (h->u.i.warning != NULL && (abfd->flags & BFD_PLUGIN) == 0) { - if (! (*info->callbacks->warning) (info, h->u.i.warning, - h->root.string, abfd, - NULL, 0)) - return FALSE; + (*info->callbacks->warning) (info, h->u.i.warning, + h->root.string, abfd, NULL, 0); /* Only issue a warning once. */ h->u.i.warning = NULL; } @@ -1818,9 +1810,8 @@ _bfd_generic_link_add_one_symbol (struct bfd_link_info *info, && (h->u.undef.next != NULL || info->hash->undefs_tail == h)) || h->non_ir_ref) { - if (! (*info->callbacks->warning) (info, string, h->root.string, - hash_entry_bfd (h), NULL, 0)) - return FALSE; + (*info->callbacks->warning) (info, string, h->root.string, + hash_entry_bfd (h), NULL, 0); break; } /* Fall through. */ @@ -2411,9 +2402,8 @@ _bfd_generic_reloc_link_order (bfd *abfd, if (h == NULL || ! h->written) { - if (! ((*info->callbacks->unattached_reloc) - (info, link_order->u.reloc.p->u.name, NULL, NULL, 0))) - return FALSE; + (*info->callbacks->unattached_reloc) + (info, link_order->u.reloc.p->u.name, NULL, NULL, 0); bfd_set_error (bfd_error_bad_value); return FALSE; } @@ -2447,17 +2437,13 @@ _bfd_generic_reloc_link_order (bfd *abfd, case bfd_reloc_outofrange: abort (); case bfd_reloc_overflow: - if (! ((*info->callbacks->reloc_overflow) - (info, NULL, - (link_order->type == bfd_section_reloc_link_order - ? bfd_section_name (abfd, link_order->u.reloc.p->u.section) - : link_order->u.reloc.p->u.name), - r->howto->name, link_order->u.reloc.p->addend, - NULL, NULL, 0))) - { - free (buf); - return FALSE; - } + (*info->callbacks->reloc_overflow) + (info, NULL, + (link_order->type == bfd_section_reloc_link_order + ? bfd_section_name (abfd, link_order->u.reloc.p->u.section) + : link_order->u.reloc.p->u.name), + r->howto->name, link_order->u.reloc.p->addend, + NULL, NULL, 0); break; } loc = link_order->offset * bfd_octets_per_byte (abfd); @@ -3306,89 +3292,43 @@ bfd_hide_sym_by_version (struct bfd_elf_version_tree *verdefs, /* FUNCTION - bfd_link_get_defined_symbol + bfd_link_check_relocs SYNOPSIS - bfd_boolean bfd_link_get_defined_symbol - (struct bfd_link_info *info, struct bfd_link_hash_entry *h, - asection **sec, bfd_vma *value); + bfd_boolean bfd_link_check_relocs + (bfd *abfd, struct bfd_link_info *info); DESCRIPTION - Return TRUE, store symbol section and value in @var{*sec} and - @var{*value} if symbol @var{h} is defined during a final link. + Checks the relocs in ABFD for validity. + Does not execute the relocs. + Return TRUE if everything is OK, FALSE otherwise. + This is the external entry point to this code. */ bfd_boolean -bfd_link_get_defined_symbol (struct bfd_link_info *info, - struct bfd_link_hash_entry *h, - asection **sec, bfd_vma *value) +bfd_link_check_relocs (bfd *abfd, struct bfd_link_info *info) { - if (h->type == bfd_link_hash_defined - || h->type == bfd_link_hash_defweak) - { - if (sec) - *sec = h->u.def.section; - if (value) - *value = h->u.def.value; - return TRUE; - } - - if (h->type == bfd_link_hash_new - || h->type == bfd_link_hash_undefined - || h->type == bfd_link_hash_undefweak) - { - /* Check yet undefined reference to __start_XXX or __stop_XXX - symbols. The linker will later define such symbols for output - sections that have a name representable as a C identifier. */ - const char *sec_name; - if (strncmp (h->root.string, "__start_", 8) == 0) - sec_name = h->root.string + 8; - else if (strncmp (h->root.string, "__stop_", 7) == 0) - sec_name = h->root.string + 7; - else - sec_name = NULL; - - if (sec_name != NULL && *sec_name != '\0') - { - bfd *i; - - for (i = info->input_bfds; i != NULL; i = i->link.next) - { - asection *s = bfd_get_section_by_name (i, sec_name); - if (s != NULL) - { - asection *asect; - bfd_vma size; - - if (sec) - *sec = s; + return BFD_SEND (abfd, _bfd_link_check_relocs, (abfd, info)); +} - if (!value) - return TRUE; - if (sec_name == (h->root.string + 8)) - { - /* Set __start_XXX symbol value. */ - *value = 0; - return TRUE; - } +/* +FUNCTION + _bfd_generic_link_check_relocs - /* Get the size of the output XXX section for - __stop_XXX symbol value. */ - size = 0; - for (asect = s->output_section->map_head.s; - asect != NULL; - asect = asect->map_head.s) - { - size = align_power (size, asect->alignment_power); - size += asect->size; - } +SYNOPSIS + bfd_boolean _bfd_generic_link_check_relocs + (bfd *abfd, struct bfd_link_info *info); - *value = size; - return TRUE; - } - } - } - } +DESCRIPTION + Stub function for targets that do not implement reloc checking. + Return TRUE. + This is an internal function. It should not be called from + outside the BFD library. +*/ - return FALSE; +bfd_boolean +_bfd_generic_link_check_relocs (bfd *abfd ATTRIBUTE_UNUSED, + struct bfd_link_info *info ATTRIBUTE_UNUSED) +{ + return TRUE; }