X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=bfd%2Felf.c;h=b8a300e4a64ae13cc1954d1cc2236e53f1332082;hb=759365550adde37c0e94b0109b128e41bc65418d;hp=8dcb4d5ae2fc809a171b08bcef59e67148e0e665;hpb=aecc8f8acd0b3be16ffe73ddec39d5eb9816c7fa;p=deliverable%2Fbinutils-gdb.git diff --git a/bfd/elf.c b/bfd/elf.c index 8dcb4d5ae2..b8a300e4a6 100644 --- a/bfd/elf.c +++ b/bfd/elf.c @@ -2,21 +2,21 @@ 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 @@ -371,7 +371,7 @@ bfd_elf_get_elf_syms (ibfd, symtab_hdr, symcount, symoffset, { 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; @@ -1418,10 +1418,12 @@ _bfd_elf_link_hash_newfunc (entry, table, string) 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. */ @@ -1439,22 +1441,22 @@ _bfd_elf_link_hash_copy_indirect (dir, ind) /* 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) { @@ -2443,7 +2445,20 @@ elf_fake_sections (abfd, asect, failedptrarg) 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 @@ -2760,8 +2775,9 @@ assign_section_numbers (abfd) 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; @@ -4812,9 +4828,11 @@ copy_private_bfd_data (ibfd, obfd) /* 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 @@ -4831,7 +4849,10 @@ copy_private_bfd_data (ibfd, obfd) 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; @@ -5551,7 +5572,11 @@ _bfd_elf_canonicalize_dynamic_symtab (abfd, alocation) 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 @@ -6020,7 +6045,7 @@ _bfd_elf_find_nearest_line (abfd, section, symbols, offset, functionname_ptr, line_ptr, &elf_tdata (abfd)->line_info)) return false; - if (found) + if (found && (*functionname_ptr || *line_ptr)) return true; if (symbols == NULL)