X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=bfd%2Felf.c;h=c3339f93b7a66bd96635a513a60f20b44be276eb;hb=41241523bf023fabf97f1df7b02940347e45cd2f;hp=020771bcbc0cda7f421950f2e1d31ab75858fa69;hpb=dba143efb31cb98d480dc790bb9cde79b846fa32;p=deliverable%2Fbinutils-gdb.git diff --git a/bfd/elf.c b/bfd/elf.c index 020771bcbc..c3339f93b7 100644 --- a/bfd/elf.c +++ b/bfd/elf.c @@ -665,11 +665,12 @@ _bfd_elf_make_section_from_shdr (abfd, hdr, name) && (hdr->sh_offset + hdr->sh_size <= phdr->p_offset + phdr->p_memsz) && ((flags & SEC_LOAD) == 0 - || (phdr->p_offset + phdr->p_filesz - >= hdr->sh_offset + hdr->sh_size))) + || (hdr->sh_offset + hdr->sh_size + <= phdr->p_offset + phdr->p_filesz))) { if ((flags & SEC_LOAD) == 0) - newsect->lma += phdr->p_paddr - phdr->p_vaddr; + newsect->lma = (phdr->p_paddr + + hdr->sh_addr - phdr->p_vaddr); else /* We used to use the same adjustment for SEC_LOAD sections, but that doesn't work if the segment @@ -680,7 +681,15 @@ _bfd_elf_make_section_from_shdr (abfd, hdr, name) LMAs, even if the VMAs are not. */ newsect->lma = (phdr->p_paddr + hdr->sh_offset - phdr->p_offset); - break; + + /* With contiguous segments, we can't tell from file + offsets whether a section with zero size should + be placed at the end of one segment or the + beginning of the next. Decide based on vaddr. */ + if (hdr->sh_addr >= phdr->p_vaddr + && (hdr->sh_addr + hdr->sh_size + <= phdr->p_vaddr + phdr->p_memsz)) + break; } } } @@ -805,6 +814,19 @@ _bfd_elf_merge_sections (abfd, info) merge_sections_remove_hook); return true; } + +void +_bfd_elf_link_just_syms (sec, info) + asection *sec; + struct bfd_link_info *info; +{ + sec->output_section = bfd_abs_section_ptr; + sec->output_offset = sec->vma; + if (!is_elf_hash_table (info)) + return; + + elf_section_data (sec)->sec_info_type = ELF_INFO_TYPE_JUST_SYMS; +} /* Copy the program header and other data from one object module to another. */ @@ -1351,13 +1373,13 @@ _bfd_elf_link_hash_table_create (abfd) struct elf_link_hash_table *ret; bfd_size_type amt = sizeof (struct elf_link_hash_table); - ret = (struct elf_link_hash_table *) bfd_alloc (abfd, amt); + ret = (struct elf_link_hash_table *) bfd_malloc (amt); if (ret == (struct elf_link_hash_table *) NULL) return NULL; if (! _bfd_elf_link_hash_table_init (ret, abfd, _bfd_elf_link_hash_newfunc)) { - bfd_release (abfd, ret); + free (ret); return NULL; } @@ -3872,7 +3894,6 @@ prep_headers (abfd) Elf_Internal_Ehdr *i_ehdrp; /* Elf file header, internal form */ Elf_Internal_Phdr *i_phdrp = 0; /* Program header table, internal form */ Elf_Internal_Shdr **i_shdrp; /* Section header table, internal form */ - int count; struct elf_strtab_hash *shstrtab; struct elf_backend_data *bed = get_elf_backend_data (abfd); @@ -3895,12 +3916,6 @@ prep_headers (abfd) bfd_big_endian (abfd) ? ELFDATA2MSB : ELFDATA2LSB; i_ehdrp->e_ident[EI_VERSION] = bed->s->ev_current; - i_ehdrp->e_ident[EI_OSABI] = ELFOSABI_NONE; - i_ehdrp->e_ident[EI_ABIVERSION] = 0; - - for (count = EI_PAD; count < EI_NIDENT; count++) - i_ehdrp->e_ident[count] = 0; - if ((abfd->flags & DYNAMIC) != 0) i_ehdrp->e_type = ET_DYN; else if ((abfd->flags & EXEC_P) != 0) @@ -5113,7 +5128,9 @@ _bfd_elf_get_symtab_upper_bound (abfd) Elf_Internal_Shdr *hdr = &elf_tdata (abfd)->symtab_hdr; symcount = hdr->sh_size / get_elf_backend_data (abfd)->s->sizeof_sym; - symtab_size = (symcount - 1 + 1) * (sizeof (asymbol *)); + symtab_size = (symcount + 1) * (sizeof (asymbol *)); + if (symcount > 0) + symtab_size -= sizeof (asymbol *); return symtab_size; } @@ -5133,7 +5150,9 @@ _bfd_elf_get_dynamic_symtab_upper_bound (abfd) } symcount = hdr->sh_size / get_elf_backend_data (abfd)->s->sizeof_sym; - symtab_size = (symcount - 1 + 1) * (sizeof (asymbol *)); + symtab_size = (symcount + 1) * (sizeof (asymbol *)); + if (symcount > 0) + symtab_size -= sizeof (asymbol *); return symtab_size; } @@ -6437,7 +6456,7 @@ elfcore_netbsd_get_lwpid (note, lwpidp) cp = strchr (note->namedata, '@'); if (cp != NULL) { - *lwpidp = atoi(cp); + *lwpidp = atoi(cp + 1); return true; } return false;