]> git.ipfire.org Git - thirdparty/elfutils.git/commit
libelf: Split checks for ehdr and shdr, drop phdr check in file_read_elf.
authorMark Wielaard <mjw@redhat.com>
Tue, 2 Jun 2015 08:54:26 +0000 (10:54 +0200)
committerMark Wielaard <mjw@redhat.com>
Mon, 8 Jun 2015 09:12:38 +0000 (11:12 +0200)
commitb9fd0eee50b028e4752595a8cc293bf2c331b1b9
tree8362f49e59e8a6c6e209f6c4212a05065bdc78b9
parent8aaf4fc46f5b0b1ed2b567734d06875a39047dd9
libelf: Split checks for ehdr and shdr, drop phdr check in file_read_elf.

There are various places in the code that check whether mmapped structures
are correctly aligned (or ALLOW_UNALIGNED is set). Some of these checks
are asserts. Like the one in elf(32|64)_getshdr. We should not get into
that part of the code if the shdr scn structure was cached in elf_begin
because it was mmapped in and properly aligned.

These asserts could trigger because in elf_begin.c file_read_elf ()
all alignment checks were combined. So even though only one of the ehdr,
shdr or phdr structures were not properly aligned all structures would be
copied. Also the phdr structure was not even read in elf_begin, so the
alignment check was unnecessary.

This patch splits the alignment checks and reading of ehdr and shdr
structures into separate code paths. It also drops the phdr alignment
checks in elf_begin. Those phdr checks are done in elf(32|64)_getphdr
already.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
libelf/ChangeLog
libelf/elf_begin.c