elf: Properly compute offsets of note descriptor and next note
authorH.J. Lu <hjl.tools@gmail.com>
Fri, 24 Nov 2017 14:41:40 +0000 (06:41 -0800)
committerH.J. Lu <hjl.tools@gmail.com>
Fri, 24 Nov 2017 14:41:52 +0000 (06:41 -0800)
commit650444eb540f9fd85e821567a3f943b4bc41b8be
tree2c5e0bf7934a74df34cfd3a0c9377d62903717bb
parenta63f2d2feedcfce401ae1d7d03d119bfa5e4d8bc
elf: Properly compute offsets of note descriptor and next note

According to gABI, in a note entry, the note name field, not note name
size, is padded for the note descriptor.  And the note descriptor field,
not note descriptor size, is padded for the next note entry.  Also notes
are aligned to 4 bytes in 32-bit objects and 8 bytes in 64-bit objects.
Since on Linux, .note.ABI-tag and .note.gnu.build-id notes are always
aligned to 4 bytes, we need to use alignment of note section or note
segment, instead of assuming alignment based on ELF file class.

Tested on i686 and x86-64.

bfd/

PR binutils/22444
* elf.c (elf_read_notes): Add an argument for note aligment.
(elf_parse_notes): Likewise.
(_bfd_elf_make_section_from_shdr): Pass section aligment to
elf_parse_notes.
(bfd_section_from_phdr): Pass segment aligment to elf_read_notes.
(elf_parse_notes): Add an argument for note aligment.  Use
ELF_NOTE_DESC_OFFSET to get the offset of the note descriptor.
Use ELF_NOTE_NEXT_OFFSET to get the offset of the next note
entry.
(elf_read_notes): Add an argument for note aligment and pass it
to elf_parse_notes.

binutils/

PR binutils/22444
* readelf.c (process_notes_at): Use ELF_NOTE_DESC_OFFSET to get
the offset of the note descriptor.  Use ELF_NOTE_NEXT_OFFSET to
get the offset of the next note entry.

include/

PR binutils/22444
* elf/external.h (ELF_ALIGN_UP): New.
(ELF_NOTE_DESC_OFFSET): Likewise.
(ELF_NOTE_NEXT_OFFSET): Likewise.
bfd/ChangeLog
bfd/elf.c
binutils/ChangeLog
binutils/readelf.c
include/ChangeLog
include/elf/external.h
This page took 0.031477 seconds and 4 git commands to generate.