/* COFF specific linker code.
- Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
- 2004, 2005, 2006, 2007, 2008, 2009, 2011 Free Software Foundation, Inc.
+ Copyright (C) 1994-2014 Free Software Foundation, Inc.
Written by Ian Lance Taylor, Cygnus Support.
This file is part of BFD, the Binary File Descriptor library.
{
bfd_size_type string_offset = 0;
asection *stab;
-
+
for (stab = abfd->sections; stab; stab = stab->next)
if (CONST_STRNEQ (stab->name, ".stab")
&& (!stab->name[5]
struct coff_link_hash_table *table;
struct coff_section_tdata *secdata
= coff_section_data (abfd, stab);
-
+
if (secdata == NULL)
{
amt = sizeof (struct coff_section_tdata);
the opportunity to clear the output_has_begun fields of all the
input BFD's. */
max_sym_count = 0;
- for (sub = info->input_bfds; sub != NULL; sub = sub->link_next)
+ for (sub = info->input_bfds; sub != NULL; sub = sub->link.next)
{
size_t sz;
if (flaginfo.info->strip != strip_all && flaginfo.info->discard != discard_all)
{
/* Add local symbols from foreign inputs. */
- for (sub = info->input_bfds; sub != NULL; sub = sub->link_next)
+ for (sub = info->input_bfds; sub != NULL; sub = sub->link.next)
{
unsigned int i;
elsewhere. */
struct internal_reloc incount;
bfd_byte *excount = (bfd_byte *)bfd_malloc (relsz);
-
+
memset (&incount, 0, sizeof (incount));
incount.r_vaddr = o->reloc_count + 1;
bfd_coff_swap_reloc_out (abfd, &incount, excount);
struct internal_reloc * irel;
struct internal_reloc * irelend;
- if ((a->flags & SEC_RELOC) == 0 || a->reloc_count < 1)
+ if ((a->flags & SEC_RELOC) == 0 || a->reloc_count < 1
+ || a->linker_mark == 0)
continue;
/* Don't mark relocs in excluded sections. */
if (a->output_section == bfd_abs_section_ptr)
contents = secdata->contents;
else
{
- bfd_size_type x = o->rawsize ? o->rawsize : o->size;
- if (! bfd_get_section_contents (input_bfd, o, flaginfo->contents, 0, x))
- return FALSE;
contents = flaginfo->contents;
+ if (! bfd_get_full_section_contents (input_bfd, o, &contents))
+ return FALSE;
}
if ((o->flags & SEC_RELOC) != 0)
? (flaginfo->section_info[target_index].relocs
+ o->output_section->reloc_count)
: flaginfo->internal_relocs)));
- if (internal_relocs == NULL)
+ if (internal_relocs == NULL
+ && o->reloc_count > 0)
return FALSE;
/* Run through the relocs looking for relocs against symbols
else
{
sec = sections[symndx];
+
+ /* If the output section has been discarded then ignore this reloc. */
+ if (sec->output_section->vma == 0)
+ continue;
+
val = (sec->output_section->vma
+ sec->output_offset
+ sym->n_value);