aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog8
-rw-r--r--bfd/elf-bfd.h2
-rw-r--r--bfd/elf.c25
-rw-r--r--bfd/elflink.c8
4 files changed, 24 insertions, 19 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 8cbab99..882d994 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,11 @@
+2014-09-10 Alan Modra <amodra@gmail.com>
+
+ * elf.c (assign_file_positions_except_relocs): Move section header
+ placement to..
+ (_bfd_elf_assign_file_positions_for_relocs): ..here. Make static.
+ * elf-bfd.h (_bfd_elf_assign_file_positions_for_relocs): Delete.
+ * elflink.c (bfd_elf_final_link): Don't call above function.
+
2014-08-30 Alan Modra <amodra@gmail.com>
* elf32-ppc.c (ppc_elf_relax_section): Fix off by one error.
diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
index 63ffa85..2f24274 100644
--- a/bfd/elf-bfd.h
+++ b/bfd/elf-bfd.h
@@ -1988,8 +1988,6 @@ extern long _bfd_elf_link_lookup_local_dynindx
(struct bfd_link_info *, bfd *, long);
extern bfd_boolean _bfd_elf_compute_section_file_positions
(bfd *, struct bfd_link_info *);
-extern void _bfd_elf_assign_file_positions_for_relocs
- (bfd *);
extern file_ptr _bfd_elf_assign_file_position_for_section
(Elf_Internal_Shdr *, file_ptr, bfd_boolean);
diff --git a/bfd/elf.c b/bfd/elf.c
index 9dc6b6d..a772db0 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -5124,7 +5124,6 @@ assign_file_positions_except_relocs (bfd *abfd,
{
struct elf_obj_tdata *tdata = elf_tdata (abfd);
Elf_Internal_Ehdr *i_ehdrp = elf_elfheader (abfd);
- file_ptr off;
const struct elf_backend_data *bed = get_elf_backend_data (abfd);
if ((abfd->flags & (EXEC_P | DYNAMIC)) == 0
@@ -5134,6 +5133,7 @@ assign_file_positions_except_relocs (bfd *abfd,
unsigned int num_sec = elf_numsections (abfd);
Elf_Internal_Shdr **hdrpp;
unsigned int i;
+ file_ptr off;
/* Start after the ELF header. */
off = i_ehdrp->e_ehsize;
@@ -5157,6 +5157,8 @@ assign_file_positions_except_relocs (bfd *abfd,
else
off = _bfd_elf_assign_file_position_for_section (hdr, off, TRUE);
}
+
+ elf_next_file_pos (abfd) = off;
}
else
{
@@ -5203,17 +5205,8 @@ assign_file_positions_except_relocs (bfd *abfd,
if (bfd_seek (abfd, (bfd_signed_vma) bed->s->sizeof_ehdr, SEEK_SET) != 0
|| bed->s->write_out_phdrs (abfd, tdata->phdr, alloc) != 0)
return FALSE;
-
- off = elf_next_file_pos (abfd);
}
- /* Place the section headers. */
- off = align_file_position (off, 1 << bed->s->log_file_align);
- i_ehdrp->e_shoff = off;
- off += i_ehdrp->e_shnum * i_ehdrp->e_shentsize;
-
- elf_next_file_pos (abfd) = off;
-
return TRUE;
}
@@ -5306,14 +5299,16 @@ prep_headers (bfd *abfd)
}
/* Assign file positions for all the reloc sections which are not part
- of the loadable file image. */
+ of the loadable file image, and the file position of section headers. */
-void
+static void
_bfd_elf_assign_file_positions_for_relocs (bfd *abfd)
{
file_ptr off;
unsigned int i, num_sec;
Elf_Internal_Shdr **shdrpp;
+ Elf_Internal_Ehdr *i_ehdrp;
+ const struct elf_backend_data *bed;
off = elf_next_file_pos (abfd);
@@ -5328,6 +5323,12 @@ _bfd_elf_assign_file_positions_for_relocs (bfd *abfd)
off = _bfd_elf_assign_file_position_for_section (shdrp, off, TRUE);
}
+/* Place the section headers. */
+ i_ehdrp = elf_elfheader (abfd);
+ bed = get_elf_backend_data (abfd);
+ off = align_file_position (off, 1 << bed->s->log_file_align);
+ i_ehdrp->e_shoff = off;
+ off += i_ehdrp->e_shnum * i_ehdrp->e_shentsize;
elf_next_file_pos (abfd) = off;
}
diff --git a/bfd/elflink.c b/bfd/elflink.c
index c1e7948..d33efe0 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -10691,12 +10691,10 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info)
esdo->rela.count = 0;
}
- _bfd_elf_assign_file_positions_for_relocs (abfd);
-
/* We have now assigned file positions for all the sections except
- .symtab and .strtab. We start the .symtab section at the current
- file position, and write directly to it. We build the .strtab
- section in memory. */
+ .symtab, .strtab, and non-loaded reloc sections. We start the
+ .symtab section at the current file position, and write directly
+ to it. We build the .strtab section in memory. */
bfd_get_symcount (abfd) = 0;
symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
/* sh_name is set in prep_headers. */