Upstream proposed patch. Note that this backport doesn't actually contain the new testcase. It is just the elf_getdata fix. commit edff83d3416a136ce58a21a1244c99805e98f6d8 Author: Mark Wielaard Date: Thu Feb 4 09:53:41 2016 +0100 libelf: elf_getdata should not adjust alignment for SHT_NOBITS sections. In commit c0748e "libelf: More checking of valid sh_addralign values." we adjusted bogus alignment of data buffers if they were greater than the offset of the data in the file. This works OK, except when there is no data in the file. So make sure to not adjust any NOBITS sections. Also adds a test that shows the issue and makes sure elflint is called with --gnu in run-strip-test.sh. https://bugzilla.redhat.com/show_bug.cgi?id=1303845 Signed-off-by: Mark Wielaard diff --git a/libelf/elf_getdata.c b/libelf/elf_getdata.c index 4ec94b9..d1fafbf 100644 --- a/libelf/elf_getdata.c +++ b/libelf/elf_getdata.c @@ -1,5 +1,5 @@ /* Return the next data element from the section after possibly converting it. - Copyright (C) 1998-2005, 2006, 2007, 2015 Red Hat, Inc. + Copyright (C) 1998-2005, 2006, 2007, 2015, 2016 Red Hat, Inc. This file is part of elfutils. Written by Ulrich Drepper , 1998. @@ -363,7 +363,7 @@ __libelf_set_rawdata_wrlock (Elf_Scn *scn) at least an ehdr this will only trigger for alignment values > 64 which should be uncommon. */ align = align ?: 1; - if (align > offset) + if (type != SHT_NOBITS && align > offset) align = offset; scn->rawdata.d.d_align = align; if (elf->class == ELFCLASS32