/* COFF specific linker code.
- Copyright (C) 1994-2017 Free Software Foundation, Inc.
+ Copyright (C) 1994-2020 Free Software Foundation, Inc.
Written by Ian Lance Taylor, Cygnus Support.
This file is part of BFD, the Binary File Descriptor library.
return TRUE;
*pneeded = TRUE;
- return coff_link_add_object_symbols (abfd, info);
+ return bfd_link_add_symbols (abfd, info);
}
/* Add all the symbols from an object file to the hash table. */
case COFF_SYMBOL_GLOBAL:
flags = BSF_EXPORT | BSF_GLOBAL;
section = coff_section_from_bfd_index (abfd, sym.n_scnum);
- if (! obj_pe (abfd))
+ if (discarded_section (section))
+ section = bfd_und_section_ptr;
+ else if (! obj_pe (abfd))
value -= section->vma;
break;
case COFF_SYMBOL_PE_SECTION:
flags = BSF_SECTION_SYM | BSF_GLOBAL;
section = coff_section_from_bfd_index (abfd, sym.n_scnum);
+ if (discarded_section (section))
+ section = bfd_und_section_ptr;
break;
}
&& (*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"),
+ (_("warning: symbol `%s' is both section and non-section"),
name);
addit = FALSE;
|| BTYPE (sym.n_type) == T_NULL)))
_bfd_error_handler
/* xgettext: c-format */
- (_("Warning: type of symbol `%s' changed"
- " from %d to %d in %B"),
+ (_("warning: type of symbol `%s' changed"
+ " from %d to %d in %pB"),
name, (*sym_hash)->type, sym.n_type, abfd);
/* We don't want to change from a meaningful
bfd_asymbol_name(sym), FALSE, FALSE)
== NULL))
|| (((flaginfo.info->discard == discard_sec_merge
- && (bfd_get_section (sym)->flags & SEC_MERGE)
+ && (bfd_asymbol_section (sym)->flags & SEC_MERGE)
&& ! bfd_link_relocatable (flaginfo.info))
|| flaginfo.info->discard == discard_l)
&& bfd_is_local_label_name (sub, bfd_asymbol_name(sym))))
_bfd_stringtab_free (flaginfo.strtab);
- /* Setting bfd_get_symcount to 0 will cause write_object_contents to
+ /* Setting symcount to 0 will cause write_object_contents to
not try to write out the symbols. */
- bfd_get_symcount (abfd) = 0;
+ abfd->symcount = 0;
return TRUE;
case C_FCN:
if (obj_pe (input_bfd)
- && strcmp (isym.n_name, ".bf") != 0
+ && memcmp (isym.n_name, ".bf", sizeof ".bf") != 0
&& isym.n_scnum > 0)
{
/* For PE, .lf and .ef get their value left alone,
{
_bfd_error_handler
/* xgettext: c-format */
- (_("%B: relocs in section `%A', but it has no contents"),
+ (_("%pB: relocs in section `%pA', but it has no contents"),
input_bfd, o);
bfd_set_error (bfd_error_no_contents);
return FALSE;
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"),
+ (_("%X`%s' referenced in section `%pA' of %pB: "
+ "defined in discarded section `%pA' of %pB\n"),
h->root.root.string, o, input_bfd, ps, ps->owner);
}
/* Write out the modified section contents. */
if (secdata == NULL || secdata->stab_info == NULL)
{
- file_ptr loc = o->output_offset * bfd_octets_per_byte (output_bfd);
+ file_ptr loc = (o->output_offset
+ * bfd_octets_per_byte (output_bfd, o));
if (! bfd_set_section_contents (output_bfd, o->output_section,
contents, loc, o->size))
return FALSE;
|| bfd_link_relocatable (flaginfo->info)))
_bfd_error_handler
/* xgettext: c-format */
- (_("%B: %A: reloc overflow: %#x > 0xffff"),
+ (_("%pB: %pA: reloc overflow: %#x > 0xffff"),
output_bfd, sec, sec->reloc_count);
if (sec->lineno_count > 0xffff
|| bfd_link_relocatable (flaginfo->info)))
_bfd_error_handler
/* xgettext: c-format */
- (_("%B: warning: %A: line number overflow: %#x > 0xffff"),
+ (_("%pB: warning: %pA: line number overflow: %#x > 0xffff"),
output_bfd, sec, sec->lineno_count);
auxp->x_scn.x_nreloc = sec->reloc_count;
return FALSE;
rstat = _bfd_relocate_contents (howto, output_bfd,
- (bfd_vma) link_order->u.reloc.p->addend,\
+ (bfd_vma) link_order->u.reloc.p->addend,
buf);
switch (rstat)
{
(*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)
+ ? bfd_section_name (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);
+ loc = link_order->offset * bfd_octets_per_byte (output_bfd,
+ output_section);
ok = bfd_set_section_contents (output_bfd, output_section, buf,
loc, size);
free (buf);
{
_bfd_error_handler
/* xgettext: c-format */
- (_("%B: illegal symbol index %ld in relocs"), input_bfd, symndx);
+ (_("%pB: illegal symbol index %ld in relocs"), input_bfd, symndx);
return FALSE;
}
else
if (sec != NULL && discarded_section (sec))
{
_bfd_clear_contents (howto, input_bfd, input_section,
- contents + (rel->r_vaddr - input_section->vma));
+ contents, rel->r_vaddr - input_section->vma);
continue;
}
case bfd_reloc_outofrange:
_bfd_error_handler
/* xgettext: c-format */
- (_("%B: bad reloc address %#Lx in section `%A'"),
- input_bfd, rel->r_vaddr, input_section);
+ (_("%pB: bad reloc address %#" PRIx64 " in section `%pA'"),
+ input_bfd, (uint64_t) rel->r_vaddr, input_section);
return FALSE;
case bfd_reloc_overflow:
{