mpers: fix cross-compiling

In cross builds, a target version of readelf has to be used
instead of a native one.

* configure.ac (AC_CHECK_TOOL): Add readelf.
* Makefile.am (READELF): New variable.
(mpers-m%.stamp): Pass it to $(srcdir)/mpers.sh.
* m4/mpers.m4 (st_MPERS): Pass READELF environment variable
to $srcdir/mpers_test.sh.
* mpers.sh (READELF): New variable.
Use it instead of readelf.
* maint/ioctls_sym.sh: Likewise.
* NEWS: Mention this fix.

Reported-by: Rolf Eike Beer <eb@emlix.com>
This commit is contained in:
Дмитрий Левин 2017-11-25 01:55:44 +00:00
parent 3d2a5884ce
commit acffeae467
6 changed files with 18 additions and 5 deletions

View File

@ -45,6 +45,8 @@ OS = linux
# ARCH is `i386', `m68k', `sparc', etc.
ARCH = @arch@
READELF = @READELF@
ACLOCAL_AMFLAGS = -I m4
AM_CFLAGS = $(WARN_CFLAGS)
AM_CPPFLAGS = -I$(builddir)/$(OS)/$(ARCH) \
@ -987,8 +989,11 @@ libmpers_CFLAGS = $(strace_CFLAGS)
mpers-m%.stamp: $(srcdir_mpers_source_files) | printers.h
for f in $^; do \
CC="$(CC)" CFLAGS="$(mpers_sh_opts) -DMPERS_IS_$(mpers_NAME)" \
CPP="$(CPP)" CPPFLAGS="$(mpers_sh_opts) -DIN_MPERS -DMPERS_IS_$(mpers_NAME)" \
READELF="$(READELF)" \
CC="$(CC)" \
CFLAGS="$(mpers_sh_opts) -DMPERS_IS_$(mpers_NAME)" \
CPP="$(CPP)" \
CPPFLAGS="$(mpers_sh_opts) -DIN_MPERS -DMPERS_IS_$(mpers_NAME)" \
$(srcdir)/mpers.sh -$(mpers_NAME) $$f || exit; \
done
> $@

3
NEWS
View File

@ -12,6 +12,9 @@ Noteworthy changes in release ?.?? (????-??-??)
* Enhanced decoding of BPF_MAP_CREATE command of bpf syscall.
* Updated lists of MSG_* and SHM_* constants.
* Bug fixes
* Fixed multi-personality support in cross builds.
Noteworthy changes in release 4.20 (2017-11-13)
===============================================

View File

@ -785,6 +785,8 @@ AC_SUBST(dl_LIBS)
AC_PATH_PROG([PERL], [perl])
AC_CHECK_TOOL([READELF], [readelf])
dnl stack trace with libunwind
libunwind_CPPFLAGS=
libunwind_LDFLAGS=

View File

@ -115,7 +115,8 @@ case "$arch" in
[st_cv_runtime=no],
[st_cv_runtime=no])])
AC_CACHE_CHECK([whether mpers.sh CFLAG works], [st_cv_mpers],
[if CC="$CC" CPP="$CPP" CPPFLAGS="$CPPFLAGS" \
[if READELF="$READELF" \
CC="$CC" CPP="$CPP" CPPFLAGS="$CPPFLAGS" \
$srcdir/mpers_test.sh [$1]; then
st_cv_mpers=yes
else

View File

@ -88,6 +88,7 @@ LC_COLLATE=C sort -u -o "$tmpdir"/headers.list "$tmpdir"/headers.list
msg "processing $(wc -l < "$tmpdir"/headers.list) header files from $inc_dir"
failed=0
READELF="${READELF:-readelf}"
CC="${CC:-gcc}"
CPP="${CPP:-cpp}"
CPPFLAGS="${CPPFLAGS-} -D__EXPORTED_HEADERS__"
@ -423,7 +424,7 @@ s/^\([[:space:]]\+[^),]\+)\),$/\1/' >> "$tmpdir/$f"
# If something is wrong with the file, this will fail.
$CC $INCLUDES $CFLAGS -c -o "$tmpdir"/printents.o "$tmpdir"/printents.c
readelf --wide --debug-dump=info "$tmpdir"/printents.o \
$READELF --wide --debug-dump=info "$tmpdir"/printents.o \
> "$tmpdir"/debug-dump
sed -r -n '

View File

@ -32,6 +32,7 @@ MPERS_AWK="${0%/*}/mpers.awk"
ARCH_FLAG=$1
PARSER_FILE=$2
READELF="${READELF:-readelf}"
CC="${CC-gcc}"
CFLAGS="$CFLAGS -gdwarf-2 -c"
CPP="${CPP-$CC -E}"
@ -62,7 +63,7 @@ for m_type; do
continue
sed -i -e '/DEF_MPERS_TYPE/d' "${f_c}"
$CC $CFLAGS $ARCH_FLAG "${f_c}" -o "${f_o}"
readelf --debug-dump=info "${f_o}" > "${f_d1}"
$READELF --debug-dump=info "${f_o}" > "${f_d1}"
sed -r -n '
/^[[:space:]]*<1>/,/^[[:space:]]*<1><[^>]+>: Abbrev Number: 0/!d
/^[[:space:]]*<[^>]*><[^>]*>: Abbrev Number: 0/d