Commit Graph

16 Commits

Author SHA1 Message Date
e2a3370f67 mpers.m4: workaround missing gnu/stubs-*.h files
On some systems missing gnu/stubs-*.h files make -m32/-mx32 compilation
checks fail.  As we want to support multiple personalities despite of
this limitation, workaround the check by creating empty gnu stub files
if necessary.

* m4/mpers.m4 (st_MPERS): Check for the gnu stub file.  Create an empty
gnu stub file if the system one is missing.
* Makefile.am (DISTCLEANFILES): Add gnu/stubs-32.h and gnu/stubs-x32.h.
2015-08-28 08:46:24 +00:00
Elvira Khabirova
092942206c Add mpers support
Add a subsystem for semi-automatical definition of how parsers should
work with personality-dependent (mpers) types of tracee's data.  Create
auxiliary libraries containing mpers syscall parsers and printer
functions, one library for each possible nonnative target personality.

Currently some parsers do not handle differences in definitions of data
types between personalities, namely LP64 and ILP32.  When
this is the case, long integers, pointers, and all compound
types containing long and pointer members may be printed incorrectly,
because of differences in sizes, offsets and alignments.

Since in most cases these are the only differences in desired behaviour
of parsers and printers for different personalities, a correct way
would be to compile one source code into multiple parsers, differing
only in definitions of mpers types.

To get a definition of a given type for nonnative personality
a very basic .c file containing a declaration of a variable of this type
is being compiled for this personality (using -m32 or -mx32 compiler
flag).  Information about the type is then being extracted from
this binary's DWARF debug info with an awk script and put
into a corresponding header file.  Resulting headers are being used to
compile mpers variations of syscall parsers and printer functions.

In addition to syscall parsers, there can occur a need to create mpers
printing functions, which then can be called from many places
in the code (for example, printsiginfo_at).  Such functions (printers)
are marked in a special manner.

For each possible nonnative target personality a library is being
created, containing mpers variations of syscall parsers and printers.
Only syscall parsers from files marked in a special manner and specially
marked functions from such files are being recompiled and included
in these libraries.

generate_mpers_am.sh is called by bootstrap to find the files
from strace_SOURCES which include MPERS_DEFS.  During compilation,
these files are being inspected for inclusions of DEF_MPERS_TYPE,
and nonnative variations of each included type are being generated
by an awk script.

Mpers parser names are being modified during inclusions of syscallent
headers for nonnative personalities.  Pointers to printers are
being stored in structs struct_printers, and a master
pointer printers is being updated on every set_personality.

* README-mpers: New README explaining how to use mpers support.
* empty.h: New empty file.
* generate_mpers_am.sh: New file.
* mpers.awk: Likewise.
* mpers.sh: Likewise.
* mpers_test.sh: Likewise.
* mpers_type.h: Likewise.
* Makefile.am (strace_SOURCES): Add empty.h and mpers_type.h.
(strace_CPPFLAGS, strace_LDFLAGS, strace_LDADD): Move to the beginning
of the file.
(strace_LDADD, noinst_LIBRARIES): Add libmpers-%.a.
(EXTRA_DIST): Add mpers.awk, mpers.sh, mpers_test.sh.
(BUILT_SOURCES, CLEANFILES): Add new generated files:
native_printer_decls.h, native_printer_defs.h, printers.h,
[HAVE_M32_MPERS] $(mpers_m32_targets), and [HAVE_MX32_MPERS]
$(mpers_mx32_targets).
(mpers_NAME, mpers_PREFIX, mpers_DEFS, mpers_INCLUDES, mpers_CPPFLAGS,
mpers_sh_opts, libmpers_CPPFLAGS, libmpers_m[x]32_a_SOURCES,
libmpers_m[x]32_a_CPPFLAGS, mpers_m[x]32_targets): New variables.
(mpers-m[x]32.stamp, m[x]32_defs.h, m[x]32_funcs.h, printers.h,
%_printer_decls.h, %_printer_defs.h, clean-local,
native_printer_decls.h, native_printer_defs.h, $mpers_m[x]32_targets):
New targets.
* bootstrap: Add generate_mpers_am.sh.
* configure.ac: Add AC_PROG_RANLIB.
* m4/mpers.m4: Add HAVE_MPERS variable.  Add $st_cv_mpers checks.
* defs.h: Include mpers_type.h.
Include printers.h, native_printer_decls.h, define MPERS_PRINTER_NAME.
Redefine SYS_FUNC_NAME.  Define MPERS_PRINTER_DECL.
[HAVE_M32_MPERS]: define PERSONALITY1_INCLUDE_FUNCS,
PERSONALITY1_INCLUDE_PRINTERS_DECLS, PERSONALITY1_INCLUDE_PRINTERS_DEFS
for X86_64, X32.
[HAVE_MX32_MPERS]: define PERSONALITY2_INCLUDE_FUNCS,
PERSONALITY2_INCLUDE_PRINTERS_DECLS, PERSONALITY2_INCLUDE_PRINTERS_DEFS
for X86_64.
Add fallback definitions of
PERSONALITY1_INCLUDE_FUNCS, PERSONALITY2_INCLUDE_FUNCS,
PERSONALITY0_INCLUDE_PRINTERS_DECLS, PERSONALITY0_INCLUDE_PRINTERS_DEFS,
PERSONALITY1_INCLUDE_PRINTERS_DECLS, PERSONALITY1_INCLUDE_PRINTERS_DEFS,
PERSONALITY2_INCLUDE_PRINTERS_DECLS, PERSONALITY2_INCLUDE_PRINTERS_DEFS.
* syscall.c: Include PERSONALITY1_INCLUDE_FUNCS,
PERSONALITY2_INCLUDE_FUNCS,
PERSONALITY0_INCLUDE_PRINTERS_DECLS, PERSONALITY0_INCLUDE_PRINTERS_DEFS,
PERSONALITY1_INCLUDE_PRINTERS_DECLS, PERSONALITY1_INCLUDE_PRINTERS_DEFS,
PERSONALITY2_INCLUDE_PRINTERS_DECLS, PERSONALITY2_INCLUDE_PRINTERS_DEFS.
(printers): New struct.  Update it when needed.
* .gitignore: Add libmpers-m32.a, libmpers-mx32.a, m32_defs.h,
m32_funcs.h, m32_printer_decls.h, m32_printer_defs.h, mpers-m32,
mpers-m32.stamp, mpers-mx32, mpers-mx32.stamp, mpers.am, mx32_defs.h,
mx32_funcs.h, mx32_printer_decls.h, mx32_printer_defs.h,
native_printer_decls.h, native_printer_defs.h, and printers.h.
2015-08-28 08:46:23 +00:00
f8b49133b7 Macroize -m32/-mx32 configure checks
Prepare for additional configure checks that would be needed
for new multiple personalities support.

* m4/mpers.m4: New file.
* configure.ac: Use it.
2015-07-23 11:39:32 +00:00
Mike Frysinger
58c7fe9903 Fix cross-compiling of ioctlsort
Use the AX_PROG_CC_FOR_BUILD helper to set up build settings when cross
compiling.  This way ioctlsort uses the build tools all the time.

* configure.ac: Call AX_PROG_CC_FOR_BUILD.
* Makefile.am (ioctlsort_CC): Set to CC_FOR_BUILD.
(ioctlsort_CPPFLAGS): Change CPPFLAGS to CPPFLAGS_FOR_BUILD.
(ioctlsort_CFLAGS): Change CFLAGS to CFLAGS_FOR_BUILD.
(ioctlsort_LDFLAGS): Change LDFLAGS to LDFLAGS_FOR_BUILD.
(ioctlsort_LD): Delete.
(ioctlsort%): Change to ioctlsort%$(BUILD_EXEEXT).  Use ioctlsort_CFLAGS.
* m4/ax_prog_cc_for_build.m4: Import from the autoconf-archive package.
2015-02-27 04:43:06 +00:00
174583df28 Update warnings.m4
* m4/warnings.m4: Update from gnulib.
2015-01-21 21:06:10 +00:00
69099e714c configure.ac: remove unused AC_INCLUDEDIR
* configure.ac (AC_INCLUDEDIR): Remove.
* m4/includedir.m4: Remove.
2015-01-21 16:43:18 +00:00
9e6a7bf202 Use AC_CHECK_TYPES to check for struct statfs64
* m4/statfs.m4: Remove.
* configure.ac (AC_STATFS64): Remove.
(AC_CHECK_TYPES): Add struct statfs64.
* statfs.c: Replace HAVE_STATFS64 with HAVE_STRUCT_STATFS64.
2015-01-08 04:12:29 +00:00
7b9bc44e63 Use AC_CHECK_TYPES to check for struct stat64
* m4/stat.m4: Remove.
* configure.ac (AC_STAT64): Remove.
(AC_CHECK_TYPES): Add struct stat64.
* file.c: Replace HAVE_STAT64 with HAVE_STRUCT_STAT64.
2015-01-08 04:06:06 +00:00
437ae19fc8 Remove unused AC_OFF_T_IS_LONG_LONG configure check
* configure.ac: Remove AC_OFF_T_IS_LONG_LONG.
* m4/long_long.m4: Likewise.
2013-11-12 15:43:06 +00:00
b468f2320a Implement prlimit64 decoding, rewrite [gs]etrlimit decoding
* configure.ac: Remove AC_RLIM_T_IS_LONG_LONG call.
Define SIZEOF_RLIM_T.
* m4/long_long.m4 (AC_RLIM_T_IS_LONG_LONG): Remove.
* linux/dummy.h (sys_prlimit64): Remove.
* linux/syscall.h (sys_prlimit64): New prototype.
* resource.c (resources): Reindent, add RLIMIT_RTTIME.
(sprintrlim, print_rlimit32, sys_getrlimit, sys_setrlimit): Remove.
[HAVE_LONG_LONG_RLIM_T]: Remove dead code.
[_LFS64_LARGEFILE || HAVE_LONG_LONG_RLIM_T]: Likewise.
(sprint_rlim64, print_rlimit64, decode_rlimit64, sprint_rlim32,
print_rlimit32, decode_rlimit, sys_getrlimit, sys_setrlimit,
sys_prlimit64): New functions.
2012-03-16 19:05:21 +00:00
ee245d8ca3 Remove parts of automake machinery which are not needed on Linux
This change is a verbatim part of Dmitry's changes to remove support
for non-Linux architectures.

* Makefile.am: Don't install PORTING file. Install README-linux-ptrace file.
Set OS variable to linux unconditionally.
* configure.ac: Remove code to set opsys variable, and its usage.
Remove checks for headers which are never present on Linux.
* m4/stat.m4: Remove 'ifdef LINUX' check.
* m4/statfs.m4: Likewise.

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-02-25 15:34:10 +01:00
Denys Vlasenko
5afdf12572 Manual removal of non-Linux source, documentation, etc.
Remove non-Linux source directories: freebsd/, svr4/, sunos4/, svr4/.
Remove README-freebsd, README-sunos4, README-svr4, m4/procfs.m4.

linux/sparc/{errnoent1,ioctlent1,signalent1}.h used to point to svr4/ files -
replace their contents with copies of used (and now deleted) files.
Make linux/sparc64/{errnoent1,ioctlent1,signalent1}.h include these files
instead of svr4/* ones.

Makefile.am: remove references to deleted files.
configure.ac: Remove a few tests which make no sense on Linux.
Man page: remove non-Linux quirks information.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-02-25 02:30:32 +01:00
Mike Frysinger
584ba2d31d Fix off_t/rlim_t size checks when cross-compiling
The current off_t/rlim_t size checks (wrt size of long long) use AC_RUN
which obviously doesn't work when cross-compiling.  While we don't hit
any configure errors, the fall back code is pretty dumb (which is to say
there isn't any).  Considering the code in question though, we can use
some fun compiler tricks with sizeof and array lengths to turn it into
a pure build test and avoid the RUN issue completely.

* m4/long_long.m4 (AC_OFF_T_IS_LONG_LONG, AC_RLIM_T_IS_LONG_LONG):
Convert from AC_RUN_IFELSE to AC_COMPILE_IFELSE.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2010-09-15 15:36:00 +00:00
Mike Frysinger
6d12afdac4 Fix long long little endian detection when cross-compiling
The long long endian detection code does an AC_TRY_RUN() and since that
doesn't work when cross-compiling, it sets a fallback value.  However,
rather than do any sort of default endian detection, the code simply
sets it to "no".  This probably breaks most little endian systems out
there when cross-compiling for them.  It certainly breaks Blackfin
systems.  So use the common endian detection code provided by autoconf
and key off of that when cross-compiling.

* configure.ac: Call AC_C_BIGENDIAN.
* m4/long_long.m4 (AC_LITTLE_ENDIAN_LONG_LONG): Set cross-compiling
logic based on ac_cv_c_bigendian.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2010-09-15 15:36:00 +00:00
918e49bac7 Import warnings.m4 from gnulib
* m4/warnings.m4: Replace with warnings.m4 from gnulib.
* configure.ac: Use gl_WARN_ADD from new warnings.m4.
* Makefile.am (AM_CFLAGS): Update for new warnings.m4.
2010-09-09 23:20:25 +00:00
916adeda63 Split acinclude.m4
* Makefile.am (ACLOCAL_AMFLAGS): Add "-I m4".
* acinclude.m4: Remove.
* m4/includedir.m4: New file, with definition of AC_INCLUDEDIR from
acinclude.m4.
* m4/long_long.m4: New file, with definitions of AC_OFF_T_IS_LONG_LONG,
AC_RLIM_T_IS_LONG_LONG and AC_LITTLE_ENDIAN_LONG_LONG from acinclude.m4.
* m4/procfs.m4: New file, with definitions of AC_MP_PROCFS,
AC_POLLABLE_PROCFS and AC_STRUCT_PR_SYSCALL from acinclude.m4.
* m4/stat.m4: New file, with definition of AC_STAT64 from acinclude.m4.
* m4/statfs.m4: New file, with definition of AC_STATFS64 from
acinclude.m4.
* m4/warnings.m4: New file, with definition of AC_WARNFLAGS from
acinclude.m4.
2010-09-09 23:20:24 +00:00