aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2011-02-08 09:40:05 +0000
committerNick Clifton <nickc@redhat.com>2011-02-08 09:40:05 +0000
commit82f2dbf73d32c8c82e62d2073a99da8b1ec03fa1 (patch)
tree3005705c64e9bb89aa75c953be12568983265bf9 /bfd
parent84ced98a310603805f69d4d6616e02a196232438 (diff)
downloadgdb-82f2dbf73d32c8c82e62d2073a99da8b1ec03fa1.zip
gdb-82f2dbf73d32c8c82e62d2073a99da8b1ec03fa1.tar.gz
gdb-82f2dbf73d32c8c82e62d2073a99da8b1ec03fa1.tar.bz2
PR binutils/12467
* readelf.c (process_program_headers): Issue a warning if there are no program headers but the file header has a non-zero program header offset. (process_section_headers): Issue a warning if there are no section headers but the file header has a non-zero section header offset. (process_section_groups): Reword the no section message so that it can be distinguished from the one issued by process_section_headers. * elf.c (assign_file_positions_for_load_sections): Set the program header offset and entry size to zero if there are no program headers.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog7
-rw-r--r--bfd/elf.c14
2 files changed, 19 insertions, 2 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 8a6c44f..9935a84 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,10 @@
+2011-02-08 Nick Clifton <nickc@redhat.com>
+
+ PR binutils/12467
+ * elf.c (assign_file_positions_for_load_sections): Set the program
+ header offset and entry size to zero if there are no program
+ headers.
+
2011-02-08 Alan Modra <amodra@gmail.com>
* elf64-ppc.c (ppc64_elf_edit_toc): Don't segfault on NULL
diff --git a/bfd/elf.c b/bfd/elf.c
index 257cc8c..c77dced 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -4334,8 +4334,18 @@ assign_file_positions_for_load_sections (bfd *abfd,
header_pad = m->header_size;
}
- elf_elfheader (abfd)->e_phoff = bed->s->sizeof_ehdr;
- elf_elfheader (abfd)->e_phentsize = bed->s->sizeof_phdr;
+ if (alloc)
+ {
+ elf_elfheader (abfd)->e_phoff = bed->s->sizeof_ehdr;
+ elf_elfheader (abfd)->e_phentsize = bed->s->sizeof_phdr;
+ }
+ else
+ {
+ /* PR binutils/12467. */
+ elf_elfheader (abfd)->e_phoff = 0;
+ elf_elfheader (abfd)->e_phentsize = 0;
+ }
+
elf_elfheader (abfd)->e_phnum = alloc;
if (elf_tdata (abfd)->program_header_size == (bfd_size_type) -1)