/* COFF specific linker code.
- Copyright (C) 1994-2016 Free Software Foundation, Inc.
+ Copyright (C) 1994-2017 Free Software Foundation, Inc.
Written by Ian Lance Taylor, Cygnus Support.
This file is part of BFD, the Binary File Descriptor library.
if (h->type != bfd_link_hash_undefined)
return TRUE;
+ /* PR 22369 - Skip non COFF objects in the archive. */
+ if (! bfd_family_coff (abfd))
+ return TRUE;
+
+ /* Include this element? */
if (!(*info->callbacks->add_archive_element) (info, abfd, name, &abfd))
- return FALSE;
+ return TRUE;
*pneeded = TRUE;
return coff_link_add_object_symbols (abfd, info);
& COFF_LINK_HASH_PE_SECTION_SYMBOL) == 0
&& (*sym_hash)->root.type != bfd_link_hash_undefined
&& (*sym_hash)->root.type != bfd_link_hash_undefweak)
- (*_bfd_error_handler)
- ("Warning: symbol `%s' is both section and non-section",
+ _bfd_error_handler
+ (_("Warning: symbol `%s' is both section and non-section"),
name);
addit = FALSE;
&& !(DTYPE ((*sym_hash)->type) == DTYPE (sym.n_type)
&& (BTYPE ((*sym_hash)->type) == T_NULL
|| BTYPE (sym.n_type) == T_NULL)))
- (*_bfd_error_handler)
- (_("Warning: type of symbol `%s' changed from %d to %d in %B"),
- abfd, name, (*sym_hash)->type, sym.n_type);
+ _bfd_error_handler
+ /* xgettext: c-format */
+ (_("Warning: type of symbol `%s' changed"
+ " from %d to %d in %B"),
+ name, (*sym_hash)->type, sym.n_type, abfd);
/* We don't want to change from a meaningful
base type to a null one, but if we know
in the relocation table. This will then be picked up in the
skip/don't-skip pass. */
for (; irel < irelend; irel++)
- flaginfo->sym_indices[ irel->r_symndx ] = -1;
+ if ((unsigned long) irel->r_symndx < obj_raw_syment_count (input_bfd))
+ flaginfo->sym_indices[irel->r_symndx] = -1;
}
}
if ((o->flags & SEC_RELOC) != 0
&& o->reloc_count != 0)
{
- (*_bfd_error_handler)
+ _bfd_error_handler
+ /* xgettext: c-format */
(_("%B: relocs in section `%A', but it has no contents"),
input_bfd, o);
bfd_set_error (bfd_error_no_contents);
/* Complain if definition comes from an excluded section. */
if (ps->flags & SEC_EXCLUDE)
(*flaginfo->info->callbacks->einfo)
+ /* xgettext: c-format */
(_("%X`%s' referenced in section `%A' of %B: "
"defined in discarded section `%A' of %B\n"),
h->root.root.string, o, input_bfd, ps, ps->owner);
if (name == NULL)
return FALSE;
- if (! ((*flaginfo->info->callbacks->unattached_reloc)
- (flaginfo->info, name, input_bfd, o,
- irel->r_vaddr)))
- return FALSE;
+ (*flaginfo->info->callbacks->unattached_reloc)
+ (flaginfo->info, name, input_bfd, o, irel->r_vaddr);
}
}
}
if (sec->reloc_count > 0xffff
&& (! obj_pe (output_bfd)
|| bfd_link_relocatable (flaginfo->info)))
- (*_bfd_error_handler)
- (_("%s: %s: reloc overflow: 0x%lx > 0xffff"),
- bfd_get_filename (output_bfd),
- bfd_get_section_name (output_bfd, sec),
- sec->reloc_count);
+ _bfd_error_handler
+ /* xgettext: c-format */
+ (_("%B: %A: reloc overflow: %#x > 0xffff"),
+ output_bfd, sec, sec->reloc_count);
if (sec->lineno_count > 0xffff
&& (! obj_pe (output_bfd)
|| bfd_link_relocatable (flaginfo->info)))
- (*_bfd_error_handler)
- (_("%s: warning: %s: line number overflow: 0x%lx > 0xffff"),
- bfd_get_filename (output_bfd),
- bfd_get_section_name (output_bfd, sec),
- sec->lineno_count);
+ _bfd_error_handler
+ /* xgettext: c-format */
+ (_("%B: warning: %A: line number overflow: %#x > 0xffff"),
+ output_bfd, sec, sec->lineno_count);
auxp->x_scn.x_nreloc = sec->reloc_count;
auxp->x_scn.x_nlinno = sec->lineno_count;
case bfd_reloc_outofrange:
abort ();
case bfd_reloc_overflow:
- if (! ((*flaginfo->info->callbacks->reloc_overflow)
- (flaginfo->info, NULL,
- (link_order->type == bfd_section_reloc_link_order
- ? bfd_section_name (output_bfd,
- link_order->u.reloc.p->u.section)
- : link_order->u.reloc.p->u.name),
- howto->name, link_order->u.reloc.p->addend,
- (bfd *) NULL, (asection *) NULL, (bfd_vma) 0)))
- {
- free (buf);
- return FALSE;
- }
+ (*flaginfo->info->callbacks->reloc_overflow)
+ (flaginfo->info, NULL,
+ (link_order->type == bfd_section_reloc_link_order
+ ? bfd_section_name (output_bfd,
+ link_order->u.reloc.p->u.section)
+ : link_order->u.reloc.p->u.name),
+ howto->name, link_order->u.reloc.p->addend,
+ (bfd *) NULL, (asection *) NULL, (bfd_vma) 0);
break;
}
loc = link_order->offset * bfd_octets_per_byte (output_bfd);
}
else
{
- if (! ((*flaginfo->info->callbacks->unattached_reloc)
- (flaginfo->info, link_order->u.reloc.p->u.name, (bfd *) NULL,
- (asection *) NULL, (bfd_vma) 0)))
- return FALSE;
+ (*flaginfo->info->callbacks->unattached_reloc)
+ (flaginfo->info, link_order->u.reloc.p->u.name,
+ (bfd *) NULL, (asection *) NULL, (bfd_vma) 0);
irel->r_symndx = 0;
}
}
else if (symndx < 0
|| (unsigned long) symndx >= obj_raw_syment_count (input_bfd))
{
- (*_bfd_error_handler)
- ("%B: illegal symbol index %ld in relocs", input_bfd, symndx);
+ _bfd_error_handler
+ /* xgettext: c-format */
+ (_("%B: illegal symbol index %ld in relocs"), input_bfd, symndx);
return FALSE;
}
else
else
{
sec = sections[symndx];
+
+ /* PR 19623: Relocations against symbols in
+ the absolute sections should ignored. */
+ if (bfd_is_abs_section (sec))
+ continue;
+
val = (sec->output_section->vma
+ sec->output_offset
+ sym->n_value);
}
else if (! bfd_link_relocatable (info))
- {
- if (! ((*info->callbacks->undefined_symbol)
- (info, h->root.root.string, input_bfd, input_section,
- rel->r_vaddr - input_section->vma, TRUE)))
- return FALSE;
- }
+ (*info->callbacks->undefined_symbol)
+ (info, h->root.root.string, input_bfd, input_section,
+ rel->r_vaddr - input_section->vma, TRUE);
}
/* If the input section defining the symbol has been discarded
case bfd_reloc_ok:
break;
case bfd_reloc_outofrange:
- (*_bfd_error_handler)
- (_("%B: bad reloc address 0x%lx in section `%A'"),
- input_bfd, input_section, (unsigned long) rel->r_vaddr);
+ _bfd_error_handler
+ /* xgettext: c-format */
+ (_("%B: bad reloc address %#Lx in section `%A'"),
+ input_bfd, rel->r_vaddr, input_section);
return FALSE;
case bfd_reloc_overflow:
{
return FALSE;
}
- if (! ((*info->callbacks->reloc_overflow)
- (info, (h ? &h->root : NULL), name, howto->name,
- (bfd_vma) 0, input_bfd, input_section,
- rel->r_vaddr - input_section->vma)))
- return FALSE;
+ (*info->callbacks->reloc_overflow)
+ (info, (h ? &h->root : NULL), name, howto->name,
+ (bfd_vma) 0, input_bfd, input_section,
+ rel->r_vaddr - input_section->vma);
}
}
}