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 <mjw@redhat.com>
+2016-02-04 Mark Wielaard <mjw@redhat.com>
+
+ * elf_getdata.c (__libelf_set_rawdata_wrlock): Don't adjust align
+ for SHT_NOBITS sections.
+
2016-01-22 Chih-Hung Hsieh <chh@google.com>
* elf_compress.c (__libelf_compress): Move nested function
/* 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 <drepper@redhat.com>, 1998.
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
+2016-02-04 Mark Wielaard <mjw@redhat.com>
+
+ * run-strip-nobitsalign.sh: New test.
+ * testfile-nobitsalign.bz2: New testfile.
+ * testfile-nobitsalign.strip.bz2: Likewise.
+ * Makefile.am (TESTS): Add run-strip-nobitsalign.sh.
+ (EXTRA_DIST): Add run-strip-nobitsalign.sh, testfile-nobitsalign.bz2
+ and testfile-nobitsalign.strip.bz2.
+ * run-strip-test.sh: Add --gnu to elflint calls.
+
2016-01-13 Mark Wielaard <mjw@redhat.com>
* dwfl-bug-fd-leak.c: Skip test unless on __linux__.
## Process this file with automake to create Makefile.in
##
-## Copyright (C) 1996-2015 Red Hat, Inc.
+## Copyright (C) 1996-2016 Red Hat, Inc.
## This file is part of elfutils.
##
## This file is free software; you can redistribute it and/or modify
run-strip-test6.sh run-strip-test7.sh run-strip-test8.sh \
run-strip-test9.sh run-strip-test10.sh \
run-strip-groups.sh run-strip-reloc.sh run-strip-strmerge.sh \
+ run-strip-nobitsalign.sh \
run-unstrip-test.sh run-unstrip-test2.sh \
run-unstrip-test3.sh run-unstrip-M.sh run-elfstrmerge-test.sh \
run-ecp-test.sh run-ecp-test2.sh run-alldts.sh \
run-strip-test4.sh run-strip-test5.sh run-strip-test6.sh \
run-strip-test7.sh run-strip-test8.sh run-strip-groups.sh \
run-strip-test9.sh run-strip-test10.sh run-strip-strmerge.sh \
+ run-strip-nobitsalign.sh \
+ testfile-nobitsalign.bz2 testfile-nobitsalign.strip.bz2 \
run-strip-reloc.sh hello_i386.ko.bz2 hello_x86_64.ko.bz2 \
hello_ppc64.ko.bz2 hello_s390.ko.bz2 hello_aarch64.ko.bz2 \
run-unstrip-test.sh run-unstrip-test2.sh \
--- /dev/null
+#! /bin/sh
+# Copyright (C) Red Hat, Inc., 2016.
+# This file is part of elfutils.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# elfutils is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# static unsigned char buffer[4096] __attribute((aligned (4096)));
+#
+# char
+# f (int i)
+# {
+# return buffer[i];
+# }
+#
+# int
+# main (int argc, char **argv)
+# {
+# return buffer[argc] == 0;
+# }
+
+original=testfile-nobitsalign
+stripped=testfile-nobitsalign.strip
+
+. $srcdir/run-strip-test.sh
cmp $stripped testfile.temp || status=$?
# Check elflint and the expected result.
-testrun ${abs_top_builddir}/src/elflint -q testfile.temp || status=$?
+testrun ${abs_top_builddir}/src/elflint --gnu -q testfile.temp || status=$?
test -z "$debugfile" || {
cmp $debugfile testfile.debug.temp || status=$?
# Check elflint and the expected result.
-testrun ${abs_top_builddir}/src/elflint -q -d testfile.debug.temp || status=$?
+testrun ${abs_top_builddir}/src/elflint --gnu -q -d testfile.debug.temp || status=$?
# Now test unstrip recombining those files.
testrun ${abs_top_builddir}/src/unstrip -o testfile.unstrip testfile.temp testfile.debug.temp