diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2015-04-12 13:47:50 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2015-04-13 08:50:23 -0700 |
commit | bfe3202c32c6f4ab39c7158babe2f71be705dba1 (patch) | |
tree | 2ffde92276ed3ad2da127d3886e61db12fa19777 | |
parent | fac317981f45b68738860ca372297644f4800f00 (diff) |
Use bfd_mmap_resizeusers/hjl/mmap
-rw-r--r-- | bfd/elf.c | 4 | ||||
-rw-r--r-- | bfd/elflink.c | 12 | ||||
-rw-r--r-- | bfd/opncls.c | 5 |
3 files changed, 15 insertions, 6 deletions
diff --git a/bfd/elf.c b/bfd/elf.c index 5fb52e28e62..4a4fe46585c 100644 --- a/bfd/elf.c +++ b/bfd/elf.c @@ -3734,6 +3734,8 @@ _bfd_elf_compute_section_file_positions (bfd *abfd, elf_next_file_pos (abfd) = off; + bfd_mmap_resize (abfd, off); + /* Now that we know where the .strtab section goes, write it out. */ if (bfd_seek (abfd, hdr->sh_offset, SEEK_SET) != 0 @@ -5538,6 +5540,8 @@ _bfd_elf_assign_file_positions_for_relocs (bfd *abfd) i_ehdrp->e_shoff = off; off += i_ehdrp->e_shnum * i_ehdrp->e_shentsize; elf_next_file_pos (abfd) = off; + + bfd_mmap_resize (abfd, off); } bfd_boolean diff --git a/bfd/elflink.c b/bfd/elflink.c index 26d4b005055..c57cfbf10df 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -8539,6 +8539,7 @@ elf_link_flush_output_syms (struct elf_final_link_info *flinfo, hdr = &elf_tdata (flinfo->output_bfd)->symtab_hdr; pos = hdr->sh_offset + hdr->sh_size; amt = flinfo->symbuf_count * bed->s->sizeof_sym; + bfd_mmap_resize (flinfo->output_bfd, pos + amt); if (bfd_seek (flinfo->output_bfd, pos, SEEK_SET) != 0 || bfd_bwrite (flinfo->symbuf, amt, flinfo->output_bfd) != amt) return FALSE; @@ -10640,6 +10641,7 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info) asection *attr_section = NULL; bfd_vma attr_size = 0; const char *std_attrs_section; + file_ptr off; if (! is_elf_hash_table (info->hash)) return FALSE; @@ -10887,6 +10889,8 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info) esdo->rela.count = 0; } + off = elf_next_file_pos (abfd); + bfd_mmap_resize (abfd, off); abfd->output_has_begun = TRUE; /* We have now assigned file positions for all the sections except @@ -10928,8 +10932,6 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info) if (info->strip != strip_all || emit_relocs) { - file_ptr off = elf_next_file_pos (abfd); - _bfd_elf_assign_file_position_for_section (symtab_hdr, off, TRUE); /* Note that at this point elf_next_file_pos (abfd) is @@ -11307,7 +11309,7 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info) /* Finish up and write out the symbol string table (.strtab) section. */ Elf_Internal_Shdr *symstrtab_hdr; - file_ptr off = symtab_hdr->sh_offset + symtab_hdr->sh_size; + off = symtab_hdr->sh_offset + symtab_hdr->sh_size; symtab_shndx_hdr = &elf_tdata (abfd)->symtab_shndx_hdr; if (symtab_shndx_hdr->sh_name != 0) @@ -11342,6 +11344,8 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info) off, TRUE); elf_next_file_pos (abfd) = off; + bfd_mmap_resize (abfd, off); + if (bfd_seek (abfd, symstrtab_hdr->sh_offset, SEEK_SET) != 0 || ! _bfd_stringtab_emit (abfd, flinfo.symstrtab)) return FALSE; @@ -11606,8 +11610,6 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info) { /* The contents of the .dynstr section are actually in a stringtab. */ - file_ptr off; - off = elf_section_data (o->output_section)->this_hdr.sh_offset; if (bfd_seek (abfd, off, SEEK_SET) != 0 || ! _bfd_elf_strtab_emit (abfd, diff --git a/bfd/opncls.c b/bfd/opncls.c index ed1e0db6367..0ebf203f61a 100644 --- a/bfd/opncls.c +++ b/bfd/opncls.c @@ -784,7 +784,10 @@ bfd_close_all_done (bfd *abfd) ret = bfd_cache_close (abfd); if (ret) - _maybe_make_executable (abfd); + { + _maybe_make_executable (abfd); + ret = bfd_mmap_close (abfd); + } _bfd_delete_bfd (abfd); |