diff options
author | Josh Stone <jistone@redhat.com> | 2015-10-09 10:10:37 -0700 |
---|---|---|
committer | Josh Stone <jistone@redhat.com> | 2015-10-09 10:10:37 -0700 |
commit | 3425454a10d307fae891fb667cf7969e945cde79 (patch) | |
tree | ba30fbaff59ca353f4dad8759770600853fb00c1 /tests/run-lfs-symbols.sh | |
parent | f17d101232d6d40e192e61441aa02a12ee8cf9b8 (diff) | |
download | android_external_elfutils-3425454a10d307fae891fb667cf7969e945cde79.tar.gz android_external_elfutils-3425454a10d307fae891fb667cf7969e945cde79.tar.bz2 android_external_elfutils-3425454a10d307fae891fb667cf7969e945cde79.zip |
Trust AC_SYS_LARGEFILE to provide large file support
AC_SYS_LARGEFILE defines _FILE_OFFSET_BITS in config.h if needed for
LFS, and this automatically maps things like open to open64. But quite
a few places used explicit 64-bit names, which won't work on platforms
like FreeBSD where off_t is always 64-bit and there are no foo64 names.
It's better to just trust that AC_SYS_LARGEFILE is doing it correctly.
But we can verify this too, as some file could easily forget to include
config.h. The new tests/run-lfs-symbols.sh checks all build targets
against lfs-symbols (taken from lintian) to make sure everything was
implicitly mapped to 64-bit variants when _FILE_OFFSET_BITS is set.
Signed-off-by: Josh Stone <jistone@redhat.com>
Diffstat (limited to 'tests/run-lfs-symbols.sh')
-rwxr-xr-x | tests/run-lfs-symbols.sh | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/tests/run-lfs-symbols.sh b/tests/run-lfs-symbols.sh new file mode 100755 index 00000000..f0894405 --- /dev/null +++ b/tests/run-lfs-symbols.sh @@ -0,0 +1,86 @@ +#! /bin/bash +# Copyright (C) 2015 Red Hat, Inc. +# 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/>. + +. $srcdir/test-subr.sh + +if ! grep -q -F '#define _FILE_OFFSET_BITS' ${abs_top_builddir}/config.h; then + echo "LFS testing is irrelevent on this system" + exit 77 +fi + +# #include <stdio.h> +# int main () { +# FILE *f = fopen ("/dev/null", "r"); +# return f == NULL; +# } +# +# Built for Linux i686, without setting _FILE_OFFSET_BITS. +# $ gcc -m32 -O2 nolfs.c -o testfile-nolfs +testfiles testfile-nolfs + +LFS_FORMAT='BEGIN { + while ((getline < "%s") > 0) + /^\w/ && bad[$0] + FS="@" +} +/@@GLIBC_/ && $1 in bad { print $1 }' + +LFS=$(printf "$LFS_FORMAT" "${abs_srcdir}/lfs-symbols") + +makeprint() { + make print-$1 -C $2 |& awk -F= "/^$1=/{ print \$2 }" +} + +testrun_lfs() { + bad=$(testrun ${abs_top_builddir}/src/nm -u "$1" | awk "$LFS") + if [ -n "$bad" ]; then + echo "$1 contains non-lfs symbols:" $bad + exit_status=1 + fi +} + +# First sanity-check that LFS detection works. +exit_status=0 +testrun_lfs ./testfile-nolfs +if [ $exit_status -eq 0 ]; then + echo "Didn't detect any problem with testfile-nolfs!" + exit 99 +fi + +exit_status=0 + +# Check all normal build targets. +for dir in libelf libdw libasm libcpu src; do + dir=${abs_top_builddir}/$dir + for program in $(makeprint PROGRAMS $dir); do + testrun_lfs $dir/$program + done +done + +# Check all libebl modules. +dir=${abs_top_builddir}/backends +for module in $(makeprint modules $dir); do + testrun_lfs $dir/libebl_$module.so +done + +# Check all test programs. +dir=${abs_builddir} +for program in $(makeprint check_PROGRAMS $dir); do + testrun_lfs $dir/$program +done + +exit $exit_status |