]> git.ipfire.org Git - thirdparty/elfutils.git/commit
libelf: Get alignment correct when calling conversion functions.
authorMark Wielaard <mark@klomp.org>
Sat, 17 Nov 2018 23:21:49 +0000 (00:21 +0100)
committerMark Wielaard <mark@klomp.org>
Wed, 21 Nov 2018 11:30:12 +0000 (12:30 +0100)
commit5f9fab9efb042d803fcd2546f29613493f55d666
treea985fc7c4f4dd356ce161b9d5477802254b7c025
parentf5810ec76caed5155c27c2ed3d0ba2b3f0d4ad22
libelf: Get alignment correct when calling conversion functions.

When writing out data that needs to be converted we have to make sure
the conversion function is called on correctly aligned buffers. When
using mmap this might mean we have to convert into a temporarily buffer
if the user wants to write out the section at a location that is not
correctly aligned for the section type.

Older gas would generate misaligned ELF notes for the .version
directive. When copying over such notes using mmap from files with
a different endianness using mmap we would get the alignment of the
conversion destination wrong.

The new testcase would fail with configure --enable-sanitize-undefined
on little endian systems. The GCC undefinited sanitizer caught a similar
issue with testfile1 on big endian systems.

gelf_xlate.h:47:1: runtime error: member access within misaligned address
0x7f8145d770d5 for type 'struct Elf32_Nhdr', which requires 4 byte alignment

Signed-off-by: Mark Wielaard <mark@klomp.org>
libelf/ChangeLog
libelf/elf32_updatefile.c
tests/ChangeLog
tests/Makefile.am
tests/run-strip-version.sh [new file with mode: 0755]
tests/testfile-version.bz2 [new file with mode: 0755]