This is the mail archive of the
binutils-cvs@sourceware.org
mailing list for the binutils project.
[binutils-gdb] Always pass a valid section header offset to elf_parse_notes
- From: Gary Benson <gary at sourceware dot org>
- To: bfd-cvs at sourceware dot org
- Date: 2 Dec 2016 11:35:31 -0000
- Subject: [binutils-gdb] Always pass a valid section header offset to elf_parse_notes
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=08698b7b46c9c932530dcbcd7e851d27a7d2c503
commit 08698b7b46c9c932530dcbcd7e851d27a7d2c503
Author: Gary Benson <gbenson@redhat.com>
Date: Tue Nov 29 11:14:02 2016 +0000
Always pass a valid section header offset to elf_parse_notes
_bfd_elf_make_section_from_shdr calls elf_parse_notes with an offset
of -1. This argument is used to calculate Elf_Internal_Note.descpos,
which ends up set to a positive but meaningless value. This commit
updates _bfd_elf_make_section_from_shdr to pass the correct offset to
elf_parse_notes, making Elf_Internal_Note.descpos correct in all cases.
bfd/ChangeLog:
* elf.c (_bfd_elf_make_section_from_shdr): Pass offset to
elf_parse_notes.
Diff:
---
bfd/ChangeLog | 5 +++++
bfd/elf.c | 2 +-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index cef1c4b..d061e66 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,8 @@
+2016-12-02 Gary Benson <gbenson@redhat.com>
+
+ * elf.c (_bfd_elf_make_section_from_shdr): Pass offset to
+ elf_parse_notes.
+
2016-12-02 Josh Conner <joshconner@google.com>
* configure.tgt: Add support for fuchsia (OS).
diff --git a/bfd/elf.c b/bfd/elf.c
index 3d1a28a..98be1db 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -1062,7 +1062,7 @@ _bfd_elf_make_section_from_shdr (bfd *abfd,
if (!bfd_malloc_and_get_section (abfd, newsect, &contents))
return FALSE;
- elf_parse_notes (abfd, (char *) contents, hdr->sh_size, -1);
+ elf_parse_notes (abfd, (char *) contents, hdr->sh_size, hdr->sh_offset);
free (contents);
}