Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
Free Software Foundation, Inc.
-This file is part of BFD, the Binary File Descriptor library.
+ This file is part of BFD, the Binary File Descriptor library.
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* SECTION
{
Elf_Internal_Shdr *shndx_hdr;
PTR alloc_ext;
- const PTR esym;
+ const bfd_byte *esym;
Elf_External_Sym_Shndx *alloc_extshndx;
Elf_External_Sym_Shndx *shndx;
Elf_Internal_Sym *isym;
old indirect symbol. Also used for copying flags to a weakdef. */
void
-_bfd_elf_link_hash_copy_indirect (dir, ind)
+_bfd_elf_link_hash_copy_indirect (bed, dir, ind)
+ struct elf_backend_data *bed;
struct elf_link_hash_entry *dir, *ind;
{
bfd_signed_vma tmp;
+ bfd_signed_vma lowest_valid = bed->can_refcount;
/* Copy down any references that we may have already seen to the
symbol which just became indirect. */
/* Copy over the global and procedure linkage table refcount entries.
These may have been already set up by a check_relocs routine. */
tmp = dir->got.refcount;
- if (tmp <= 0)
+ if (tmp < lowest_valid)
{
dir->got.refcount = ind->got.refcount;
ind->got.refcount = tmp;
}
else
- BFD_ASSERT (ind->got.refcount <= 0);
+ BFD_ASSERT (ind->got.refcount < lowest_valid);
tmp = dir->plt.refcount;
- if (tmp <= 0)
+ if (tmp < lowest_valid)
{
dir->plt.refcount = ind->plt.refcount;
ind->plt.refcount = tmp;
}
else
- BFD_ASSERT (ind->plt.refcount <= 0);
+ BFD_ASSERT (ind->plt.refcount < lowest_valid);
if (dir->dynindx == -1)
{
if ((asect->flags & SEC_GROUP) == 0 && elf_group_name (asect) != NULL)
this_hdr->sh_flags |= SHF_GROUP;
if ((asect->flags & SEC_THREAD_LOCAL) != 0)
- this_hdr->sh_flags |= SHF_TLS;
+ {
+ this_hdr->sh_flags |= SHF_TLS;
+ if (asect->_raw_size == 0 && (asect->flags & SEC_HAS_CONTENTS) == 0)
+ {
+ struct bfd_link_order *o;
+
+ this_hdr->sh_size = 0;
+ for (o = asect->link_order_head; o != NULL; o = o->next)
+ if (this_hdr->sh_size < o->offset + o->size)
+ this_hdr->sh_size = o->offset + o->size;
+ if (this_hdr->sh_size)
+ this_hdr->sh_type = SHT_NOBITS;
+ }
+ }
/* Check for processor-specific section types. */
if (bed->elf_backend_fake_sections
elf_section_data (s)->this_hdr.sh_link = d->this_idx;
/* This is a .stab section. */
- elf_section_data (s)->this_hdr.sh_entsize =
- 4 + 2 * bfd_get_arch_size (abfd) / 8;
+ if (elf_section_data (s)->this_hdr.sh_entsize == 0)
+ elf_section_data (s)->this_hdr.sh_entsize
+ = 4 + 2 * bfd_get_arch_size (abfd) / 8;
}
}
break;
/* The Solaris native linker always sets p_paddr to 0.
We try to catch that case here, and set it to the
- correct value. */
+ correct value. Note - some backends require that
+ p_paddr be left as zero. */
if (segment->p_paddr == 0
&& segment->p_vaddr != 0
+ && (! bed->want_p_paddr_set_to_zero)
&& isec == 0
&& output_section->lma != 0
&& (output_section->vma == (segment->p_vaddr
LMA address of the output section. */
if (IS_CONTAINED_BY_LMA (output_section, segment, map->p_paddr)
|| IS_CONTAINED_BY_FILEPOS (section, segment, bed)
- || IS_COREFILE_NOTE (segment, section))
+ || IS_COREFILE_NOTE (segment, section)
+ || (bed->want_p_paddr_set_to_zero &&
+ IS_CONTAINED_BY_VMA (output_section, segment))
+ )
{
if (matching_lma == 0)
matching_lma = output_section->lma;
asymbol **alocation;
{
struct elf_backend_data *bed = get_elf_backend_data (abfd);
- return bed->s->slurp_symbol_table (abfd, alocation, true);
+ long symcount = bed->s->slurp_symbol_table (abfd, alocation, true);
+
+ if (symcount >= 0)
+ bfd_get_dynamic_symcount (abfd) = symcount;
+ return symcount;
}
/* Return the size required for the dynamic reloc entries. Any
functionname_ptr, line_ptr,
&elf_tdata (abfd)->line_info))
return false;
- if (found)
+ if (found && (*functionname_ptr || *line_ptr))
return true;
if (symbols == NULL)