aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorHans-Peter Nilsson <hp@axis.com>2008-11-13 03:01:15 +0000
committerHans-Peter Nilsson <hp@axis.com>2008-11-13 03:01:15 +0000
commit5726889422ca1dd271be75f64a0f152c04bc1476 (patch)
tree1b42a13bb6da9f40c3fd3262a3c155f4855c9a35 /bfd
parent84290f2fa20e40e8a5288b7d6236d0f4bdb22ca0 (diff)
downloadgdb-5726889422ca1dd271be75f64a0f152c04bc1476.zip
gdb-5726889422ca1dd271be75f64a0f152c04bc1476.tar.gz
gdb-5726889422ca1dd271be75f64a0f152c04bc1476.tar.bz2
PR ld/7028
* elf.c (assign_file_positions_for_load_sections): Allocate phrds with bfd_zalloc2 instead of bfd_alloc2. For the amount, use the possibly-preset header-size, not the computed one.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog7
-rw-r--r--bfd/elf.c16
2 files changed, 22 insertions, 1 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 3d5c022..4610334 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,10 @@
+2008-11-13 Hans-Peter Nilsson <hp@axis.com>
+
+ PR ld/7028
+ * elf.c (assign_file_positions_for_load_sections): Allocate phrds
+ with bfd_zalloc2 instead of bfd_alloc2. For the amount, use
+ the possibly-preset header-size, not the computed one.
+
2008-11-13 Alan Modra <amodra@bigpond.net.au>
PR 7023
diff --git a/bfd/elf.c b/bfd/elf.c
index cb7d2fc..3d52724 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -4183,7 +4183,21 @@ assign_file_positions_for_load_sections (bfd *abfd,
return TRUE;
}
- phdrs = bfd_alloc2 (abfd, alloc, sizeof (Elf_Internal_Phdr));
+ /* We're writing the size in elf_tdata (abfd)->program_header_size,
+ see assign_file_positions_except_relocs, so make sure we have
+ that amount allocated, with trailing space cleared.
+ The variable alloc contains the computed need, while elf_tdata
+ (abfd)->program_header_size contains the size used for the
+ layout.
+ See ld/emultempl/elf-generic.em:gld${EMULATION_NAME}_map_segments
+ where the layout is forced to according to a larger size in the
+ last iterations for the testcase ld-elf/header. */
+ BFD_ASSERT (elf_tdata (abfd)->program_header_size % bed->s->sizeof_phdr
+ == 0);
+ phdrs = bfd_zalloc2 (abfd,
+ (elf_tdata (abfd)->program_header_size
+ / bed->s->sizeof_phdr),
+ sizeof (Elf_Internal_Phdr));
elf_tdata (abfd)->phdr = phdrs;
if (phdrs == NULL)
return FALSE;