diff options
| -rw-r--r-- | libelf/ChangeLog | 5 | ||||
| -rw-r--r-- | libelf/elf_getdata.c | 4 | ||||
| -rw-r--r-- | tests/ChangeLog | 10 | ||||
| -rw-r--r-- | tests/Makefile.am | 5 | ||||
| -rwxr-xr-x | tests/run-strip-nobitsalign.sh | 35 | ||||
| -rwxr-xr-x | tests/run-strip-test.sh | 4 | ||||
| -rwxr-xr-x | tests/testfile-nobitsalign.bz2 | bin | 0 -> 2921 bytes | |||
| -rwxr-xr-x | tests/testfile-nobitsalign.strip.bz2 | bin | 0 -> 1723 bytes |
8 files changed, 58 insertions, 5 deletions
diff --git a/libelf/ChangeLog b/libelf/ChangeLog index afe6a6a5..ec56b534 100644 --- a/libelf/ChangeLog +++ b/libelf/ChangeLog @@ -1,3 +1,8 @@ +2016-02-04 Mark Wielaard <[email protected]> + + * elf_getdata.c (__libelf_set_rawdata_wrlock): Don't adjust align + for SHT_NOBITS sections. + 2016-01-22 Chih-Hung Hsieh <[email protected]> * elf_compress.c (__libelf_compress): Move nested function diff --git a/libelf/elf_getdata.c b/libelf/elf_getdata.c index 4ec94b98..d1fafbfe 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 <[email protected]>, 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 diff --git a/tests/ChangeLog b/tests/ChangeLog index 37f98112..a043ade6 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,13 @@ +2016-02-04 Mark Wielaard <[email protected]> + + * 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 <[email protected]> * dwfl-bug-fd-leak.c: Skip test unless on __linux__. diff --git a/tests/Makefile.am b/tests/Makefile.am index 7b9e1083..f3e7c01c 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,6 +1,6 @@ ## 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 @@ -80,6 +80,7 @@ TESTS = run-arextract.sh run-arsymtest.sh newfile test-nlist \ 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 \ @@ -163,6 +164,8 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.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 \ diff --git a/tests/run-strip-nobitsalign.sh b/tests/run-strip-nobitsalign.sh new file mode 100755 index 00000000..db9b1d9e --- /dev/null +++ b/tests/run-strip-nobitsalign.sh @@ -0,0 +1,35 @@ +#! /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 diff --git a/tests/run-strip-test.sh b/tests/run-strip-test.sh index 43d27e53..42aa9888 100755 --- a/tests/run-strip-test.sh +++ b/tests/run-strip-test.sh @@ -34,13 +34,13 @@ status=0 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 diff --git a/tests/testfile-nobitsalign.bz2 b/tests/testfile-nobitsalign.bz2 Binary files differnew file mode 100755 index 00000000..7f0d4249 --- /dev/null +++ b/tests/testfile-nobitsalign.bz2 diff --git a/tests/testfile-nobitsalign.strip.bz2 b/tests/testfile-nobitsalign.strip.bz2 Binary files differnew file mode 100755 index 00000000..f72000cc --- /dev/null +++ b/tests/testfile-nobitsalign.strip.bz2 |
