public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] gprofng: 30089 [display text] Invalid number of threads
@ 2023-03-27 18:53 Vladimir Mezentsev
  0 siblings, 0 replies; only message in thread
From: Vladimir Mezentsev @ 2023-03-27 18:53 UTC (permalink / raw)
  To: bfd-cvs, gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=66f76c545b293f8b89fef0f996a3a48fa59fae61

commit 66f76c545b293f8b89fef0f996a3a48fa59fae61
Author: Vladimir Mezentsev <vladimir.mezentsev@oracle.com>
Date:   Thu Mar 23 11:46:08 2023 -0700

    gprofng: 30089 [display text] Invalid number of threads
    
    The real problem is that libcollector doesn't interpose thread_create@GLIBC_2.34
    We interpose a lot of libC functions (dlopen, fork, pthread_create, etc.).
    Some of these functions have versions. For example, dlopen@GLIBC_2.34,
    dlopen@GLIBC_2.17, dlopen@GLIBC_2.2.5, etc.
    We have to interpose each of the functions because we don't know
    which version of libC will be used during profiling.
    Historically, we have used three versions of scripts (mapfile.aarch64-Linux,
    mapfile.amd64-Linux, mapfile.intel-Linux).
    Three are not needed. One is enough
    
    The fixes below include:
     - merged all version symbols into one version script.
     - added new version symbols which are defined in latest versions of libC.
     - removed unused defines and duplicated code.
     - added the DCL_FUNC_VER macro to define the version symbols.
    
    Tested on x86_64 and aarch64 (OL8/OL9). No regression.
    
    gprofng/ChangeLog
    2023-03-23  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>
    
            PR gprofng/30089
            * libcollector/Makefile.am: Use libgprofng.ver instead of mapfile.*
            * libcollector/configure.ac: Delete GPROFNG_VARIANT.
            * src/collector_module.h: Move the SYMVER_ATTRIBUTE macro to collector.h
            * libcollector/collector.h: Add macros (SYMVER_ATTRIBUTE, DCL_FUNC_VER).
            Remove unused defines.
            * libcollector/dispatcher.c: Interpose functions from libC.
            Clean up the old code.
            * libcollector/iotrace.c: Likewise.
            * libcollector/libcol_util.c: Likewise.
            * libcollector/linetrace.c: Likewise.
            * libcollector/mmaptrace.c: Likewise.
            * libcollector/synctrace.c: Likewise.
            * libcollector/libgprofng.ver: New file.
            * libcollector/Makefile.in: Rebuild.
            * libcollector/configure: Rebuild.
            * libcollector/mapfile.aarch64-Linux: Removed.
            * libcollector/mapfile.amd64-Linux: Removed.
            * libcollector/mapfile.intel-Linux: Removed.
            * libcollector/mapfile.sparc-Linux: Removed.
            * libcollector/mapfile.sparcv9-Linux: Removed.

Diff:
---
 gprofng/libcollector/Makefile.am           |    4 +-
 gprofng/libcollector/Makefile.in           |    3 +-
 gprofng/libcollector/collector.h           |   80 +-
 gprofng/libcollector/configure             |   22 +-
 gprofng/libcollector/configure.ac          |   17 -
 gprofng/libcollector/dispatcher.c          |  425 ++++++-----
 gprofng/libcollector/iotrace.c             | 1135 ++++++++--------------------
 gprofng/libcollector/libcol_util.c         |   77 +-
 gprofng/libcollector/libgprofng.ver        |  125 +++
 gprofng/libcollector/linetrace.c           |  492 +++++-------
 gprofng/libcollector/mapfile.aarch64-Linux |   40 -
 gprofng/libcollector/mapfile.amd64-Linux   |   79 --
 gprofng/libcollector/mapfile.intel-Linux   |   81 --
 gprofng/libcollector/mapfile.sparc-Linux   |   40 -
 gprofng/libcollector/mapfile.sparcv9-Linux |   58 --
 gprofng/libcollector/mmaptrace.c           |  183 +++--
 gprofng/libcollector/synctrace.c           |  696 ++++++-----------
 gprofng/src/collector_module.h             |   11 -
 18 files changed, 1229 insertions(+), 2339 deletions(-)

diff --git a/gprofng/libcollector/Makefile.am b/gprofng/libcollector/Makefile.am
index 9dd888864c1..0610fb00594 100644
--- a/gprofng/libcollector/Makefile.am
+++ b/gprofng/libcollector/Makefile.am
@@ -19,8 +19,6 @@
 AUTOMAKE_OPTIONS = foreign
 ACLOCAL_AMFLAGS = -I . -I ../.. 
 
-GPROFNG_VARIANT = @GPROFNG_VARIANT@
-
 CSOURCES = \
 	gethrtime.c \
 	dispatcher.c \
@@ -46,7 +44,7 @@ AM_CPPFLAGS = $(GPROFNG_CPPFLAGS) -I.. -I$(srcdir) \
 	-I$(srcdir)/../common -I$(srcdir)/../src \
 	-I$(srcdir)/../../include
 AM_LDFLAGS = -module -avoid-version \
-	-Wl,--version-script,$(srcdir)/mapfile.$(GPROFNG_VARIANT) \
+	-Wl,--version-script,$(srcdir)/libgprofng.ver \
 	$(LD_NO_AS_NEEDED) -Wl,-lrt -Wl,-ldl
 
 myincludedir = @includedir@
diff --git a/gprofng/libcollector/Makefile.in b/gprofng/libcollector/Makefile.in
index eef61ba85f7..dc76a76bd67 100644
--- a/gprofng/libcollector/Makefile.in
+++ b/gprofng/libcollector/Makefile.in
@@ -325,7 +325,6 @@ EGREP = @EGREP@
 EXEEXT = @EXEEXT@
 FGREP = @FGREP@
 GPROFNG_NO_NONNULL_COMPARE_CFLAGS = @GPROFNG_NO_NONNULL_COMPARE_CFLAGS@
-GPROFNG_VARIANT = @GPROFNG_VARIANT@
 GREP = @GREP@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -448,7 +447,7 @@ AM_CPPFLAGS = $(GPROFNG_CPPFLAGS) -I.. -I$(srcdir) \
 	-I$(srcdir)/../../include
 
 AM_LDFLAGS = -module -avoid-version \
-	-Wl,--version-script,$(srcdir)/mapfile.$(GPROFNG_VARIANT) \
+	-Wl,--version-script,$(srcdir)/libgprofng.ver \
 	$(LD_NO_AS_NEEDED) -Wl,-lrt -Wl,-ldl
 
 myincludedir = @includedir@
diff --git a/gprofng/libcollector/collector.h b/gprofng/libcollector/collector.h
index 77957ec537d..12a6e15a733 100644
--- a/gprofng/libcollector/collector.h
+++ b/gprofng/libcollector/collector.h
@@ -32,9 +32,25 @@
 #define CALL_REAL(x)	(__real_##x)
 #define NULL_PTR(x)	(__real_##x == NULL)
 
+#define SYS_LIBC_NAME   "libc.so.6"
+
+#ifdef __has_attribute
+#if __has_attribute (__symver__)
+#define SYMVER_ATTRIBUTE(sym, symver)  __attribute__ ((__symver__ (#symver)))
+#endif
+#endif
+#ifndef SYMVER_ATTRIBUTE
+# define SYMVER_ATTRIBUTE(sym, symver)  __asm__(".symver " #sym "," #symver);
+#endif
+
 #if defined(__MUSL_LIBC)
 #define dlvsym(f, nm, v)  dlsym (f, nm)
 #define SIGEV_THREAD_ID   4
+#define DCL_FUNC_VER(REAL_DCL, sym, ver)
+#else
+#define DCL_FUNC_VER(REAL_DCL, sym, ver) \
+  SYMVER_ATTRIBUTE (__collector_ ## sym, ver) \
+  REAL_DCL (__collector_ ## sym, CALL_REAL (sym))
 #endif
 
 extern hrtime_t __collector_start_time;
@@ -51,7 +67,8 @@ extern int __collector_write_packet (struct DataHandle*, CM_Packet*);
 extern int __collector_write_string (struct DataHandle*, char*, int);
 extern FrameInfo __collector_get_frame_info (hrtime_t, int, void *);
 extern FrameInfo __collector_getUID (CM_Array *arg, FrameInfo uid);
-extern int __collector_getStackTrace (void *buf, int size, void *bptr, void *eptr, void *arg);
+extern int __collector_getStackTrace (void *buf, int size, void *bptr,
+				      void *eptr, void *arg);
 extern void *__collector_ext_return_address (unsigned level);
 extern void __collector_mmap_fork_child_cleanup ();
 
@@ -83,10 +100,8 @@ extern void __collector_ext_dispatcher_restart ();
 extern void __collector_ext_dispatcher_deinstall ();
 extern void __collector_ext_usage_sample (Smpl_type type, char *name);
 extern void __collector_ext_profile_handler (siginfo_t *, ucontext_t *);
-extern int __collector_ext_clone_pthread (int (*fn)(void *), void *child_stack, int flags, void *arg,
-					  va_list va /* pid_t *ptid, struct user_desc *tlspid_t *" ctid" */);
-
-/* D-light related functions */
+extern int __collector_ext_clone_pthread (int (*fn)(void *), void *child_stack,
+					  int flags, void *arg, va_list va);
 extern int __collector_sigprof_install ();
 extern int __collector_ext_hwc_active ();
 extern void __collector_ext_hwc_check (siginfo_t *, ucontext_t *);
@@ -98,7 +113,8 @@ extern int (*__collector_VM_ReadByteInstruction)(unsigned char *);
 extern int (*__collector_omp_stack_trace)(char*, int, hrtime_t, void*);
 extern hrtime_t (*__collector_gethrtime)();
 extern int (*__collector_mpi_stack_trace)(char*, int, hrtime_t);
-extern int __collector_open_experiment (const char *exp, const char *par, sp_origin_t origin);
+extern int __collector_open_experiment (const char *exp, const char *par,
+					sp_origin_t origin);
 extern void __collector_suspend_experiment (char *why);
 extern void __collector_resume_experiment ();
 extern void __collector_clean_state ();
@@ -198,56 +214,4 @@ enum
 
 #endif /* DEBUG */
 
-// To find the glibc version:
-//   objdump -T /lib*/*so /lib*/*/*.so | grep popen
-// IMPORTANT: The GLIBC_* versions below must match those in mapfile.<variant>
- #if ARCH(Aarch64)
-  #define SYS_LIBC_NAME                 "libc.so.6"
-  #define SYS_PTHREAD_CREATE_VERSION    "GLIBC_2.17"
-  #define SYS_DLOPEN_VERSION            "GLIBC_2.17"
-  #define SYS_POPEN_VERSION             "GLIBC_2.17"
-  #define SYS_FOPEN_X_VERSION           "GLIBC_2.17"
-  #define SYS_FGETPOS_X_VERSION         "GLIBC_2.17"
-
-#elif ARCH(Intel)
-  #define SYS_LIBC_NAME                 "libc.so.6"
-  #define SYS_POSIX_SPAWN_VERSION       "GLIBC_2.15"
-  #if WSIZE(32)
-   #define SYS_PTHREAD_CREATE_VERSION   "GLIBC_2.1"
-   #define SYS_DLOPEN_VERSION           "GLIBC_2.1"
-   #define SYS_POPEN_VERSION            "GLIBC_2.1"
-   #define SYS_TIMER_X_VERSION          "GLIBC_2.2"
-   #define SYS_FOPEN_X_VERSION          "GLIBC_2.1"
-   #define SYS_FGETPOS_X_VERSION        "GLIBC_2.2"
-   #define SYS_FGETPOS64_X_VERSION      "GLIBC_2.2"
-   #define SYS_OPEN64_X_VERSION         "GLIBC_2.2"
-   #define SYS_PREAD_X_VERSION          "GLIBC_2.2"
-   #define SYS_PWRITE_X_VERSION         "GLIBC_2.2"
-   #define SYS_PWRITE64_X_VERSION       "GLIBC_2.2"
-  #else /* WSIZE(64) */
-   #define SYS_PTHREAD_CREATE_VERSION   "GLIBC_2.2.5"
-   #define SYS_DLOPEN_VERSION           "GLIBC_2.2.5"
-   #define SYS_POPEN_VERSION            "GLIBC_2.2.5"
-   #define SYS_TIMER_X_VERSION          "GLIBC_2.3.3"
-   #define SYS_FOPEN_X_VERSION          "GLIBC_2.2.5"
-   #define SYS_FGETPOS_X_VERSION        "GLIBC_2.2.5"
-  #endif
-
- #elif ARCH(SPARC)
-  #define SYS_LIBC_NAME                 "libc.so.6"
-  #define SYS_DLOPEN_VERSION            "GLIBC_2.1"
-  #if WSIZE(32)
-   #define SYS_PTHREAD_CREATE_VERSION   "GLIBC_2.1"
-   #define SYS_POPEN_VERSION            "GLIBC_2.1"
-   #define SYS_FOPEN_X_VERSION          "GLIBC_2.1"
-   #define SYS_FGETPOS_X_VERSION        "GLIBC_2.2"
-  #else /* WSIZE(64) */
-   #define SYS_PTHREAD_CREATE_VERSION   "GLIBC_2.2"
-   #define SYS_POPEN_VERSION            "GLIBC_2.2"
-   #define SYS_TIMER_X_VERSION          "GLIBC_2.3.3"
-   #define SYS_FOPEN_X_VERSION          "GLIBC_2.2"
-   #define SYS_FGETPOS_X_VERSION        "GLIBC_2.2"
-  #endif
- #endif
-
 #endif
diff --git a/gprofng/libcollector/configure b/gprofng/libcollector/configure
index 002f23ff2d5..18f2e449207 100755
--- a/gprofng/libcollector/configure
+++ b/gprofng/libcollector/configure
@@ -634,7 +634,6 @@ am__EXEEXT_TRUE
 LTLIBOBJS
 LIBOBJS
 GPROFNG_NO_NONNULL_COMPARE_CFLAGS
-GPROFNG_VARIANT
 CXXCPP
 OTOOL64
 OTOOL
@@ -12064,7 +12063,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12067 "configure"
+#line 12066 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12170,7 +12169,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12173 "configure"
+#line 12172 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -15475,23 +15474,6 @@ if test "$enable_shared" != "yes"; then
 $as_echo "$as_me: WARNING: Cannot set --enable-shared for gprofng/libcollector. Profiling will be unavailable." >&2;}
 fi
 
-GPROFNG_VARIANT=unknown
-x=`echo | $CC $CFLAGS -dM -E - | grep -w __x86_64`
-if test -n "$x"; then
-  GPROFNG_VARIANT=amd64-Linux
-else
-  x=`echo | $CC $CFLAGS -dM -E - | grep -w __i386__`
-  if test -n "$x"; then
-    GPROFNG_VARIANT=intel-Linux
-  else
-    x=`echo | $CC $CFLAGS -dM -E - | grep -w __aarch64__`
-    if test -n "$x"; then
-      GPROFNG_VARIANT=aarch64-Linux
-    fi
-  fi
-fi
-
-
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
diff --git a/gprofng/libcollector/configure.ac b/gprofng/libcollector/configure.ac
index 495963c51e0..7af958145c7 100644
--- a/gprofng/libcollector/configure.ac
+++ b/gprofng/libcollector/configure.ac
@@ -41,23 +41,6 @@ if test "$enable_shared" != "yes"; then
   AC_MSG_WARN([Cannot set --enable-shared for gprofng/libcollector. Profiling will be unavailable.])
 fi
 
-GPROFNG_VARIANT=unknown
-x=`echo | $CC $CFLAGS -dM -E - | grep -w __x86_64`
-if test -n "$x"; then
-  GPROFNG_VARIANT=amd64-Linux
-else
-  x=`echo | $CC $CFLAGS -dM -E - | grep -w __i386__`
-  if test -n "$x"; then
-    GPROFNG_VARIANT=intel-Linux
-  else
-    x=`echo | $CC $CFLAGS -dM -E - | grep -w __aarch64__`
-    if test -n "$x"; then
-      GPROFNG_VARIANT=aarch64-Linux
-    fi
-  fi
-fi
-AC_SUBST(GPROFNG_VARIANT)
-
 ACX_PROG_CC_WARNING_OPTS([-Wno-nonnull-compare], [GPROFNG_NO_NONNULL_COMPARE_CFLAGS])
 AC_SUBST(GPROFNG_NO_NONNULL_COMPARE_CFLAGS)
 
diff --git a/gprofng/libcollector/dispatcher.c b/gprofng/libcollector/dispatcher.c
index 5c5a06ec1b4..82c4bb7a533 100644
--- a/gprofng/libcollector/dispatcher.c
+++ b/gprofng/libcollector/dispatcher.c
@@ -63,19 +63,39 @@ static int (*__real_timer_settime) (timer_t timerid, int flags,
 static int (*__real_timer_delete) (timer_t timerid) = NULL;
 static int (*__real_timer_gettime) (timer_t timerid,
 				    struct itimerspec *curr_value) = NULL;
-#if ARCH(Intel) && WSIZE(32)
+
+static int (*__real_pthread_create_2_34) (pthread_t *thread,
+			const pthread_attr_t *attr,
+			void *(*start_routine) (void *), void *arg) = NULL;
+static int (*__real_pthread_create_2_17) (pthread_t *thread,
+			const pthread_attr_t *attr,
+			void *(*start_routine) (void *), void *arg) = NULL;
+static int (*__real_pthread_create_2_2_5) (pthread_t *thread,
+			const pthread_attr_t *attr,
+			void *(*start_routine) (void *), void *arg) = NULL;
 static int (*__real_pthread_create_2_1) (pthread_t *thread,
 			const pthread_attr_t *attr,
 			void *(*start_routine) (void *), void *arg) = NULL;
 static int (*__real_pthread_create_2_0) (pthread_t *thread,
 			const pthread_attr_t *attr,
 			void *(*start_routine) (void *), void *arg) = NULL;
-#elif ARCH(Intel) && WSIZE(64)
+
+static int (*__real_timer_create_2_34) (clockid_t clockid,
+				struct sigevent *sevp, timer_t *timerid) = NULL;
+static int (*__real_timer_create_2_17) (clockid_t clockid,
+				struct sigevent *sevp, timer_t *timerid) = NULL;
 static int (*__real_timer_create_2_3_3) (clockid_t clockid,
 				struct sigevent *sevp, timer_t *timerid) = NULL;
 static int (*__real_timer_create_2_2_5) (clockid_t clockid,
 				struct sigevent *sevp, timer_t *timerid) = NULL;
-#endif
+static int (*__real_timer_create_2_2) (clockid_t clockid,
+				struct sigevent *sevp, timer_t *timerid) = NULL;
+
+int (*__real_pthread_sigmask_2_32) (int, const sigset_t *, sigset_t *) = NULL;
+int (*__real_pthread_sigmask_2_17) (int, const sigset_t *, sigset_t *) = NULL;
+int (*__real_pthread_sigmask_2_2_5) (int, const sigset_t *, sigset_t *) = NULL;
+int (*__real_pthread_sigmask_2_0) (int, const sigset_t *, sigset_t *) = NULL;
+
 
 /* Original SIGPROF handler which will be replaced with the dispatcher.  Used
  * to properly interact with libaio, which uses SIGPROF as its SIGAIOCANCEL. */
@@ -637,12 +657,6 @@ protect_profiling_signals (sigset_t* lset)
     }
 }
 
-#define SYS_SETITIMER_NAME      "setitimer"
-#define SYS_SIGACTION_NAME      "sigaction"
-#define SYS_SIGPROCMASK_NAME    "sigprocmask"
-#define SYS_PTHREAD_SIGMASK     "pthread_sigmask"
-#define SYS_THR_SIGSETMASK      "thr_sigsetmask"
-
 static int
 init_interposition_intf ()
 {
@@ -652,15 +666,10 @@ init_interposition_intf ()
   /* Linux requires RTLD_LAZY, Solaris can do just RTLD_NOLOAD */
   void *handle = dlopen (SYS_LIBC_NAME, RTLD_LAZY | RTLD_NOLOAD);
 
-#if ARCH(SPARC) && WSIZE(64)
-  /* dlopen a bogus path to avoid CR 23608692 */
-  dlopen ("/bogus_path_for_23608692_workaround/", RTLD_LAZY | RTLD_NOLOAD);
-#endif
-  __real_setitimer = dlsym (RTLD_NEXT, SYS_SETITIMER_NAME);
-
+  __real_setitimer = dlsym (RTLD_NEXT, "setitimer");
   if (__real_setitimer == NULL)
     {
-      __real_setitimer = dlsym (RTLD_DEFAULT, SYS_SETITIMER_NAME);
+      __real_setitimer = dlsym (RTLD_DEFAULT, "setitimer");
       if (__real_setitimer == NULL)
 	{
 	  TprintfT (DBG_LT2, "init_interposition_intf() setitimer not found\n");
@@ -673,54 +682,127 @@ init_interposition_intf ()
 
   TprintfT (DBG_LT2, "init_interposition_intf() using RTLD_%s\n",
 	    (dlflag == RTLD_DEFAULT) ? "DEFAULT" : "NEXT");
-  TprintfT (DBG_LT2, "@%p __real_setitimer\n", __real_setitimer);
 
-  __real_sigaction = dlsym (dlflag, SYS_SIGACTION_NAME);
-  TprintfT (DBG_LT2, "@%p __real_sigaction\n", __real_sigaction);
+  __real_sigaction = dlsym (dlflag, "sigaction");
 
   /* also explicitly get libc.so/setitimer (as a backup) */
-  __real_libc_setitimer = dlsym (handle, SYS_SETITIMER_NAME);
-  TprintfT (DBG_LT2, "@%p __real_libc_setitimer\n", __real_libc_setitimer);
-
-  __real_sigprocmask = dlsym (dlflag, SYS_SIGPROCMASK_NAME);
-  TprintfT (DBG_LT2, "@%p __real_sigprocmask\n", __real_sigprocmask);
+  __real_libc_setitimer = dlsym (handle, "setitimer");
 
-  __real_thr_sigsetmask = dlsym (dlflag, SYS_THR_SIGSETMASK);
-  TprintfT (DBG_LT2, "@%p __real_thr_sigsetmask\n", __real_thr_sigsetmask);
+  __real_sigprocmask = dlsym (dlflag, "sigprocmask");
+  __real_thr_sigsetmask = dlsym (dlflag, "thr_sigsetmask");
 
-  __real_pthread_sigmask = dlsym (dlflag, SYS_PTHREAD_SIGMASK);
-  TprintfT (DBG_LT2, "@%p __real_pthread_sigmask\n", __real_pthread_sigmask);
+  __real_pthread_sigmask_2_32 = dlvsym (dlflag, "pthread_sigmask", "GLIBC_2.32");
+  __real_pthread_sigmask_2_17 = dlvsym (dlflag, "pthread_sigmask", "GLIBC_2.17");
+  __real_pthread_sigmask_2_2_5 = dlvsym (dlflag, "pthread_sigmask", "GLIBC_2.2.5");
+  __real_pthread_sigmask_2_0 = dlvsym (dlflag, "pthread_sigmask", "GLIBC_2.0");
+  __real_pthread_sigmask = dlsym (dlflag, "pthread_sigmask");
 
-#if ARCH(Aarch64)
-  __real_pthread_create = dlvsym (dlflag, "pthread_create", SYS_PTHREAD_CREATE_VERSION);
-  __real_timer_create = dlsym (dlflag, "timer_create");
-  __real_timer_settime = dlsym (dlflag, "timer_settime");
-  __real_timer_delete = dlsym (dlflag, "timer_delete");
-  __real_timer_gettime = dlsym (dlflag, "timer_gettime");
-#else
-  __real_pthread_create = dlvsym (dlflag, "pthread_create", SYS_PTHREAD_CREATE_VERSION);
-  TprintfT (DBG_LT2, "[%s] @%p __real_pthread_create\n", SYS_PTHREAD_CREATE_VERSION, __real_pthread_create);
-  __real_timer_create = dlvsym (dlflag, "timer_create", SYS_TIMER_X_VERSION);
-  TprintfT (DBG_LT2, "init_lineage_intf() [%s] @0x%p __real_timer_create\n", SYS_TIMER_X_VERSION, __real_timer_create);
-  __real_timer_settime = dlvsym (dlflag, "timer_settime", SYS_TIMER_X_VERSION);
-  TprintfT (DBG_LT2, "init_lineage_intf() [%s] @0x%p __real_timer_settime\n", SYS_TIMER_X_VERSION, __real_timer_settime);
-  __real_timer_delete = dlvsym (dlflag, "timer_delete", SYS_TIMER_X_VERSION);
-  TprintfT (DBG_LT2, "init_lineage_intf() [%s] @0x%p __real_timer_delete\n", SYS_TIMER_X_VERSION, __real_timer_delete);
-  __real_timer_gettime = dlvsym (dlflag, "timer_gettime", SYS_TIMER_X_VERSION);
-  TprintfT (DBG_LT2, "init_lineage_intf() [%s] @0x%p __real_timer_gettime\n", SYS_TIMER_X_VERSION, __real_timer_gettime);
-  __real_clone = dlsym (dlflag, "clone");
-  TprintfT (DBG_LT2, "init_lineage_intf() @0x%p __real_clone\n", __real_clone);
-#if ARCH(Intel) && WSIZE(32)
-  __real_pthread_create_2_1 = __real_pthread_create;
+  __real_pthread_create_2_34 = dlvsym (dlflag, "pthread_create", "GLIBC_2.34");
+  __real_pthread_create_2_17 = dlvsym (dlflag, "pthread_create", "GLIBC_2.17");
+  __real_pthread_create_2_2_5 = dlvsym (dlflag, "pthread_create", "GLIBC_2.2.5");
+  __real_pthread_create_2_1 = dlvsym (dlflag, "pthread_create", "GLIBC_2.1");
   __real_pthread_create_2_0 = dlvsym (dlflag, "pthread_create", "GLIBC_2.0");
-#elif ARCH(Intel) && WSIZE(64)
-  __real_timer_create_2_3_3 = __real_timer_create;
+  if (__real_pthread_create_2_34)
+    __real_pthread_create = __real_pthread_create_2_34;
+  else if (__real_pthread_create_2_17)
+    __real_pthread_create = __real_pthread_create_2_17;
+  else if (__real_pthread_create_2_2_5)
+    __real_pthread_create = __real_pthread_create_2_2_5;
+  else if (__real_pthread_create_2_1)
+    __real_pthread_create = __real_pthread_create_2_1;
+  else if (__real_pthread_create_2_0)
+    __real_pthread_create = __real_pthread_create_2_0;
+  else
+    __real_pthread_create = dlsym (dlflag, "pthread_create");
+
+  __real_timer_create_2_34 = dlvsym (dlflag, "timer_create", "GLIBC_2.34");
+  __real_timer_create_2_17 = dlvsym (dlflag, "timer_create", "GLIBC_2.17");
+  __real_timer_create_2_3_3 = dlvsym (dlflag, "timer_create", "GLIBC_2.3.3");
   __real_timer_create_2_2_5 = dlvsym (dlflag, "timer_create", "GLIBC_2.2.5");
-#elif ARCH(SPARC) && WSIZE(64)
-  __real_timer_create_2_3_3 = __real_timer_create;
   __real_timer_create_2_2 = dlvsym (dlflag, "timer_create", "GLIBC_2.2");
-#endif /* ARCH() && SIZE() */
-#endif
+  if (__real_timer_create_2_34)
+    __real_timer_create = __real_timer_create_2_34;
+  else if (__real_timer_create_2_17)
+    __real_timer_create = __real_timer_create_2_17;
+  else if (__real_timer_create_2_3_3)
+    __real_timer_create = __real_timer_create_2_3_3;
+  else if (__real_timer_create_2_2_5)
+    __real_timer_create = __real_timer_create_2_2_5;
+  else if (__real_timer_create_2_2)
+    __real_timer_create = __real_timer_create_2_2;
+  else
+    __real_timer_create = dlsym (dlflag, "timer_create");
+
+  void *t;
+  if ((t = dlvsym (dlflag, "timer_settime", "GLIBC_2.34")) != NULL)
+    __real_timer_settime = t;
+  else if ((t = dlvsym (dlflag, "timer_settime", "GLIBC_2.17")) != NULL)
+    __real_timer_settime = t;
+  else if ((t = dlvsym (dlflag, "timer_settime", "GLIBC_2.3.3")) != NULL)
+    __real_timer_settime = t;
+  else if ((t = dlvsym (dlflag, "timer_settime", "GLIBC_2.2.5")) != NULL)
+    __real_timer_settime = t;
+  else if ((t = dlvsym (dlflag, "timer_settime", "GLIBC_2.0")) != NULL)
+    __real_timer_settime = t;
+  else
+    __real_timer_settime = dlsym (dlflag, "timer_settime");
+
+  if ((t = dlvsym (dlflag, "timer_delete", "GLIBC_2.34")) != NULL)
+    __real_timer_delete = t;
+  else if ((t = dlvsym (dlflag, "timer_delete", "GLIBC_2.17")) != NULL)
+    __real_timer_delete = t;
+  else if ((t = dlvsym (dlflag, "timer_delete", "GLIBC_2.3.3")) != NULL)
+    __real_timer_delete = t;
+  else if ((t = dlvsym (dlflag, "timer_delete", "GLIBC_2.2.5")) != NULL)
+    __real_timer_delete = t;
+  else if ((t = dlvsym (dlflag, "timer_delete", "GLIBC_2.2")) != NULL)
+    __real_timer_delete = t;
+  else
+    __real_timer_delete = dlsym (dlflag, "timer_delete");
+
+  if ((t = dlvsym (dlflag, "timer_gettime", "GLIBC_2.34")) != NULL)
+    __real_timer_gettime = t;
+  else if ((t = dlvsym (dlflag, "timer_gettime", "GLIBC_2.17")) != NULL)
+    __real_timer_gettime = t;
+  else if ((t = dlvsym (dlflag, "timer_gettime", "GLIBC_2.3.3")) != NULL)
+    __real_timer_gettime = t;
+  else if ((t = dlvsym (dlflag, "timer_gettime", "GLIBC_2.2.5")) != NULL)
+    __real_timer_gettime = t;
+  else if ((t = dlvsym (dlflag, "timer_gettime", "GLIBC_2.0")) != NULL)
+    __real_timer_gettime = t;
+  else
+    __real_timer_gettime = dlsym (dlflag, "timer_gettime");
+
+  __real_clone = dlsym (dlflag, "clone");
+
+#define PR_FUNC(f)  TprintfT (DBG_LT2, " dispetcher.c: " #f ": @%p\n", f)
+  PR_FUNC (__real_clone);
+  PR_FUNC (__real_libc_setitimer);
+  PR_FUNC (__real_pthread_create);
+  PR_FUNC (__real_pthread_create_2_0);
+  PR_FUNC (__real_pthread_create_2_1);
+  PR_FUNC (__real_pthread_create_2_17);
+  PR_FUNC (__real_pthread_create_2_2_5);
+  PR_FUNC (__real_pthread_create_2_34);
+  PR_FUNC (__real_pthread_sigmask);
+  PR_FUNC (__real_pthread_sigmask_2_0);
+  PR_FUNC (__real_pthread_sigmask_2_2_5);
+  PR_FUNC (__real_pthread_sigmask_2_17);
+  PR_FUNC (__real_pthread_sigmask_2_32);
+  PR_FUNC (__real_setitimer);
+  PR_FUNC (__real_sigaction);
+  PR_FUNC (__real_sigprocmask);
+  PR_FUNC (__real_thr_sigsetmask);
+  PR_FUNC (__real_timer_create);
+  PR_FUNC (__real_timer_create_2_17);
+  PR_FUNC (__real_timer_create_2_2);
+  PR_FUNC (__real_timer_create_2_2_5);
+  PR_FUNC (__real_timer_create_2_3_3);
+  PR_FUNC (__real_timer_create_2_34);
+  PR_FUNC (__real_timer_delete);
+  PR_FUNC (__real_timer_gettime);
+  PR_FUNC (__real_timer_settime);
+
   return 0;
 }
 
@@ -817,88 +899,44 @@ sigset (int sig, sighandler_t handler)
 /*------------------------------------------------------------- timer_create */
 
 // map interposed symbol versions
-#if WSIZE(64)
-#if ARCH(SPARC) || ARCH(Intel)
-static int
-__collector_timer_create_symver (int(real_timer_create) (), clockid_t clockid, struct sigevent *sevp,
-				 timer_t *timerid);
-
-SYMVER_ATTRIBUTE (__collector_timer_create_2_3_3, timer_create@GLIBC_2.3.3)
-int
-__collector_timer_create_2_3_3 (clockid_t clockid, struct sigevent *sevp,
-				timer_t *timerid)
-{
-  if (NULL_PTR (timer_create))
-    init_interposition_intf ();
-  TprintfT (DBG_LTT, "dispatcher: GLIBC: __collector_timer_create_2_3_3@%p\n", CALL_REAL (timer_create_2_3_3));
-  return __collector_timer_create_symver (CALL_REAL (timer_create_2_3_3), clockid, sevp, timerid);
-}
-#endif /* ARCH(SPARC) || ARCH(Intel)*/
-
-#if ARCH(SPARC)
-
-SYMVER_ATTRIBUTE (__collector_timer_create_2_2, timer_create@GLIBC_2.2)
-int
-__collector_timer_create_2_2 (clockid_t clockid, struct sigevent *sevp,
-			      timer_t *timerid)
-{
-  if (NULL_PTR (timer_create))
-    init_interposition_intf ();
-  TprintfT (DBG_LTT, "dispatcher: GLIBC: __collector_timer_create_2_2@%p\n", CALL_REAL (timer_create_2_2));
-  return __collector_timer_create_symver (CALL_REAL (timer_create_2_2), clockid, sevp, timerid);
-}
-
-#elif ARCH(Intel)
-
-SYMVER_ATTRIBUTE (__collector_timer_create_2_2_5, timer_create@GLIBC_2.2.5)
-int
-__collector_timer_create_2_2_5 (clockid_t clockid, struct sigevent *sevp,
-				timer_t *timerid)
-{
-  if (NULL_PTR (timer_create))
-    init_interposition_intf ();
-  TprintfT (DBG_LTT, "dispatcher: GLIBC: __collector_timer_create_2_2_5@%p\n", CALL_REAL (timer_create_2_2_5));
-  return __collector_timer_create_symver (CALL_REAL (timer_create_2_2_5), clockid, sevp, timerid);
-}
-#endif /* ARCH() */
-#endif /* WSIZE(64) */
-
-#if ARCH(Aarch64) || (ARCH(Intel) && WSIZE(32))
-int timer_create (clockid_t clockid, struct sigevent *sevp, timer_t *timerid)
-#else
 static int
-__collector_timer_create_symver (int(real_timer_create) (), clockid_t clockid,
-				 struct sigevent *sevp, timer_t *timerid)
-#endif
+gprofng_timer_create (int (real_func) (), clockid_t clockid,
+                      struct sigevent *sevp, timer_t *timerid)
 {
-  int ret;
-
-  if (NULL_PTR (timer_create))
-    init_interposition_intf ();
-
-  /* collector reserves SIGPROF
-   */
-  if (sevp == NULL || sevp->sigev_notify != SIGEV_SIGNAL
-      || sevp->sigev_signo != SIGPROF)
+  // collector reserves SIGPROF
+  if (sevp == NULL || sevp->sigev_notify != SIGEV_SIGNAL ||
+      sevp->sigev_signo != SIGPROF)
     {
-#if ARCH(Aarch64) || (ARCH(Intel) && WSIZE(32))
-      ret = CALL_REAL (timer_create)(clockid, sevp, timerid);
-#else
-      ret = (real_timer_create) (clockid, sevp, timerid);
-#endif
-      TprintfT (DBG_LT2, "Real timer_create(%d) returned %d\n",
-		clockid, ret);
+      int ret = real_func (clockid, sevp, timerid);
+      TprintfT (DBG_LT2, "timer_create @%p (%d) ret=%d\n", real_func,
+                (int) clockid, ret);
       return ret;
     }
 
   /* log that application's timer_create request is overridden */
   (void) __collector_log_write ("<event kind=\"%s\" id=\"%d\">%d</event>\n",
 				SP_JCMD_CWARN, COL_WARN_ITMROVR, -1);
-  ret = -1;
   errno = EBUSY;
-  TprintfT (DBG_LT2, "timer_create() returning %d\n", ret);
-  return ret;
+  TprintfT (DBG_LT2, "timer_create @%p (%d) ret=%d\n", real_func,
+                (int) clockid, -1); \
+  return -1;
 }
+
+#define DCL_TIMER_CREATE(dcl_f, real_f) \
+  int dcl_f (clockid_t clockid, struct sigevent *sevp, timer_t *timerid) \
+  { \
+    if ((real_f) == NULL) \
+      init_interposition_intf (); \
+    return gprofng_timer_create (real_f, clockid, sevp, timerid); \
+  }
+
+DCL_FUNC_VER (DCL_TIMER_CREATE, timer_create_2_34, timer_create@GLIBC_2.34)
+DCL_FUNC_VER (DCL_TIMER_CREATE, timer_create_2_17, timer_create@GLIBC_2.17)
+DCL_FUNC_VER (DCL_TIMER_CREATE, timer_create_2_3_3, timer_create@GLIBC_2.3.3)
+DCL_FUNC_VER (DCL_TIMER_CREATE, timer_create_2_2_5, timer_create@GLIBC_2.2.5)
+DCL_FUNC_VER (DCL_TIMER_CREATE, timer_create_2_2, timer_create@GLIBC_2.2)
+DCL_TIMER_CREATE (timer_create, CALL_REAL (timer_create))
+
 /*------------------------------------------------------------- setitimer */
 int
 _setitimer (int which, const struct itimerval *nval,
@@ -995,26 +1033,42 @@ __collector_thr_sigsetmask (int how, const sigset_t* iset, sigset_t* oset)
 }
 
 /*----------------------------------------------------------- pthread_sigmask */
+// map interposed symbol versions
 
-int
-pthread_sigmask (int how, const sigset_t* iset, sigset_t* oset)
+static int
+gprofng_pthread_sigmask (int (real_func) (),
+                         int how, const sigset_t *iset, sigset_t* oset)
 {
-  if (NULL_PTR (pthread_sigmask))
-    init_interposition_intf ();
-  TprintfT (DBG_LT1, "__collector_pthread_sigmask(%d) interposing\n", how);
   sigset_t lsigset;
   sigset_t* lset = NULL;
   if (iset)
     {
       lsigset = *iset;
       lset = &lsigset;
-      if ((how == SIG_BLOCK) || (how == SIG_SETMASK))
-	protect_profiling_signals (lset);
+      if (how == SIG_BLOCK || how == SIG_SETMASK)
+        protect_profiling_signals (lset);
     }
-  int ret = CALL_REAL (pthread_sigmask)(how, lset, oset);
-  TprintfT (DBG_LT1, "__collector_pthread_sigmask(%d) returning %d\n", how, ret);
+  int ret = (real_func) (how, lset, oset);
+  TprintfT (DBG_LT1, "real_pthread_sigmask @%p (%d) ret=%d\n",
+            real_func, how, ret);
   return ret;
+
 }
+
+#define DCL_PTHREAD_SIGMASK(dcl_f, real_f) \
+  int dcl_f (int how, const sigset_t *iset, sigset_t* oset) \
+  { \
+    if ((real_f) == NULL) \
+      init_interposition_intf (); \
+    return gprofng_pthread_sigmask (real_f, how, iset, oset); \
+  }
+
+DCL_FUNC_VER (DCL_PTHREAD_SIGMASK, pthread_sigmask_2_32, pthread_sigmask@GLIBC_2.32)
+DCL_FUNC_VER (DCL_PTHREAD_SIGMASK, pthread_sigmask_2_17, pthread_sigmask@GLIBC_2.17)
+DCL_FUNC_VER (DCL_PTHREAD_SIGMASK, pthread_sigmask_2_2_5, pthread_sigmask@GLIBC_2.2.5)
+DCL_FUNC_VER (DCL_PTHREAD_SIGMASK, pthread_sigmask_2_0, pthread_sigmask@GLIBC_2.0)
+DCL_PTHREAD_SIGMASK (pthread_sigmask, CALL_REAL(pthread_sigmask))
+
 /*----------------------------------------------------------- pthread_create */
 typedef struct _CollectorArgs
 {
@@ -1075,94 +1129,47 @@ collector_root (void *cargs)
 }
 
 // map interposed symbol versions
-#if ARCH(Intel) && WSIZE(32)
-static int
-__collector_pthread_create_symver (int(real_pthread_create) (),
-				   pthread_t *thread,
-				   const pthread_attr_t *attr,
-				   void *(*func)(void*),
-				   void *arg);
-
-SYMVER_ATTRIBUTE (__collector_pthread_create_2_1, pthread_create@GLIBC_2.1)
-int
-__collector_pthread_create_2_1 (pthread_t *thread,
-				const pthread_attr_t *attr,
-				void *(*func)(void*),
-				void *arg)
-{
-  if (NULL_PTR (pthread_create))
-    init_interposition_intf ();
-  TprintfT (DBG_LTT, "dispatcher: GLIBC: __collector_pthread_create_2_1@%p\n", CALL_REAL (pthread_create_2_1));
-  return __collector_pthread_create_symver (CALL_REAL (pthread_create_2_1), thread, attr, func, arg);
-}
-
-SYMVER_ATTRIBUTE (__collector_pthread_create_2_0, pthread_create@GLIBC_2.0)
-int
-__collector_pthread_create_2_0 (pthread_t *thread,
-				const pthread_attr_t *attr,
-				void *(*func)(void*),
-				void *arg)
-{
-  if (NULL_PTR (pthread_create))
-    init_interposition_intf ();
-  TprintfT (DBG_LTT, "dispatcher: GLIBC: __collector_pthread_create_2_0@%p\n", CALL_REAL (pthread_create_2_0));
-  return __collector_pthread_create_symver (CALL_REAL (pthread_create_2_0), thread, attr, func, arg);
-}
-
-#endif
 
-#if ARCH(Intel) && WSIZE(32)
 static int
-__collector_pthread_create_symver (int(real_pthread_create) (),
-				   pthread_t *thread,
-				   const pthread_attr_t *attr,
-				   void *(*func)(void*),
-				   void *arg)
-#else
-int
-pthread_create (pthread_t *thread, const pthread_attr_t *attr,
-		void *(*func)(void*), void *arg)
-#endif
+gprofng_pthread_create (int (real_func) (), pthread_t *thread,
+                        const pthread_attr_t *attr,
+                        void *(*func)(void*), void *arg)
 {
-  if (NULL_PTR (pthread_create))
-    init_interposition_intf ();
-
-  TprintfT (DBG_LT1, "pthread_create interposition called\n");
-
+  TprintfT (DBG_LTT, "gprofng_pthread_create @%p\n", real_func);
   if (dispatch_mode != DISPATCH_ON)
-    {
-#if ARCH(Intel) && WSIZE(32)
-      return (real_pthread_create) (thread, attr, func, arg);
-#else
-      return CALL_REAL (pthread_create)(thread, attr, func, arg);
-#endif
-    }
-  CollectorArgs *cargs = __collector_allocCSize (__collector_heap, sizeof (CollectorArgs), 1);
-
+    return (real_func) (thread, attr, func, arg);
+  CollectorArgs *cargs = __collector_allocCSize (__collector_heap,
+                                                 sizeof (CollectorArgs), 1);
   if (cargs == NULL)
-    {
-#if ARCH(Intel) && WSIZE(32)
-      return (real_pthread_create) (thread, attr, func, arg);
-#else
-      return CALL_REAL (pthread_create)(thread, attr, func, arg);
-#endif
-    }
+    return (real_func) (thread, attr, func, arg);
   cargs->func = func;
   cargs->arg = arg;
   cargs->stack = NULL;
   cargs->isPthread = 1;
-  int ret = -1;
-#if ARCH(Intel) && WSIZE(32)
-  ret = (real_pthread_create) (thread, attr, &collector_root, cargs);
-#else
-  ret = CALL_REAL (pthread_create)(thread, attr, &collector_root, cargs);
-#endif
+  int ret = (real_func) (thread, attr, &collector_root, cargs);
   if (ret)
     __collector_freeCSize (__collector_heap, cargs, sizeof (CollectorArgs));
-  TprintfT (DBG_LT1, "pthread_create returning %d\n", ret);
+  TprintfT (DBG_LT1, "gprofng_pthread_create @%p returns %d\n", real_func, ret);
   return ret;
 }
 
+
+#define DCL_PTHREAD_CREATE(dcl_f, real_f) \
+  int dcl_f (pthread_t *thread, const pthread_attr_t *attr, \
+             void *(*func)(void*), void *arg) \
+  { \
+    if ((real_f) == NULL) \
+      init_interposition_intf (); \
+     return gprofng_pthread_create (real_f, thread, attr, func, arg); \
+  }
+
+DCL_FUNC_VER (DCL_PTHREAD_CREATE, pthread_create_2_34, pthread_create@GLIBC_2.34)
+DCL_FUNC_VER (DCL_PTHREAD_CREATE, pthread_create_2_17, pthread_create@GLIBC_2.17)
+DCL_FUNC_VER (DCL_PTHREAD_CREATE, pthread_create_2_2_5, pthread_create@GLIBC_2.2.5)
+DCL_FUNC_VER (DCL_PTHREAD_CREATE, pthread_create_2_1, pthread_create@GLIBC_2.1)
+DCL_FUNC_VER (DCL_PTHREAD_CREATE, pthread_create_2_0, pthread_create@GLIBC_2.0)
+DCL_PTHREAD_CREATE (pthread_create, CALL_REAL (pthread_create))
+
 int
 __collector_ext_clone_pthread (int (*fn)(void *), void *child_stack, int flags, void *arg,
 			       va_list va /* pid_t *ptid, struct user_desc *tls, pid_t *" ctid" */)
diff --git a/gprofng/libcollector/iotrace.c b/gprofng/libcollector/iotrace.c
index 303e755df6e..d27f8524d7d 100644
--- a/gprofng/libcollector/iotrace.c
+++ b/gprofng/libcollector/iotrace.c
@@ -36,7 +36,6 @@
 #include "gp-defs.h"
 #include "collector.h"
 #include "gp-experiment.h"
-#include "data_pckts.h"
 #include "tsd.h"
 
 
@@ -132,38 +131,42 @@ static struct dirent *(*__real_readdir)(DIR *dirp) = NULL;
 static int (*__real_flock)(int fd, int operation) = NULL;
 static int (*__real_lockf)(int fildes, int function, off_t size) = NULL;
 static int (*__real_fflush)(FILE *stream) = NULL;
-
-#if WSIZE(32)
 static int (*__real_open64)(const char *path, int oflag, ...) = NULL;
+static int (*__real_open64_2_2)(const char *path, int oflag, ...) = NULL;
 static int (*__real_creat64)(const char *path, mode_t mode) = NULL;
 static int (*__real_fgetpos64)(FILE *stream, fpos64_t *pos) = NULL;
 static int (*__real_fsetpos64)(FILE *stream, const fpos64_t *pos) = NULL;
-
-#if ARCH(Intel)
+static FILE *(*__real_fopen_2_17)(const char *filename, const char *mode) = NULL;
+static FILE *(*__real_fopen_2_2_5)(const char *filename, const char *mode) = NULL;
 static FILE *(*__real_fopen_2_1)(const char *filename, const char *mode) = NULL;
+static FILE *(*__real_fopen_2_0)(const char *filename, const char *mode) = NULL;
+static int (*__real_fclose_2_17)(FILE *stream) = NULL;
+static int (*__real_fclose_2_2_5)(FILE *stream) = NULL;
 static int (*__real_fclose_2_1)(FILE *stream) = NULL;
+static int (*__real_fclose_2_0)(FILE *stream) = NULL;
+static FILE *(*__real_fdopen_2_17)(int fildes, const char *mode) = NULL;
+static FILE *(*__real_fdopen_2_2_5)(int fildes, const char *mode) = NULL;
 static FILE *(*__real_fdopen_2_1)(int fildes, const char *mode) = NULL;
+static FILE *(*__real_fdopen_2_0)(int fildes, const char *mode) = NULL;
+static int (*__real_fgetpos_2_17)(FILE *stream, fpos_t *pos) = NULL;
+static int (*__real_fgetpos_2_2_5)(FILE *stream, fpos_t *pos) = NULL;
 static int (*__real_fgetpos_2_2)(FILE *stream, fpos_t *pos) = NULL;
+static int (*__real_fgetpos_2_0)(FILE *stream, fpos_t *pos) = NULL;
+static int (*__real_fsetpos_2_17)(FILE *stream, const fpos_t *pos) = NULL;
+static int (*__real_fsetpos_2_2_5)(FILE *stream, const fpos_t *pos) = NULL;
 static int (*__real_fsetpos_2_2)(FILE *stream, const fpos_t *pos) = NULL;
-static int (*__real_fgetpos64_2_2)(FILE *stream, fpos64_t *pos) = NULL;
-static int (*__real_fsetpos64_2_2)(FILE *stream, const fpos64_t *pos) = NULL;
-static int (*__real_open64_2_2)(const char *path, int oflag, ...) = NULL;
+static int (*__real_fsetpos_2_0)(FILE *stream, const fpos_t *pos) = NULL;
 static ssize_t (*__real_pread_2_2)(int fildes, void *buf, size_t nbyte, off_t offset) = NULL;
 static ssize_t (*__real_pwrite_2_2)(int fildes, const void *buf, size_t nbyte, off_t offset) = NULL;
-static ssize_t (*__real_pwrite64_2_2)(int fildes, const void *buf, size_t nbyte, off64_t offset) = NULL;
-static FILE *(*__real_fopen_2_0)(const char *filename, const char *mode) = NULL;
-static int (*__real_fclose_2_0)(FILE *stream) = NULL;
-static FILE *(*__real_fdopen_2_0)(int fildes, const char *mode) = NULL;
-static int (*__real_fgetpos_2_0)(FILE *stream, fpos_t *pos) = NULL;
-static int (*__real_fsetpos_2_0)(FILE *stream, const fpos_t *pos) = NULL;
+static int (*__real_fgetpos64_2_17)(FILE *stream, fpos64_t *pos) = NULL;
+static int (*__real_fgetpos64_2_2_5)(FILE *stream, fpos64_t *pos) = NULL;
+static int (*__real_fgetpos64_2_2)(FILE *stream, fpos64_t *pos) = NULL;
 static int (*__real_fgetpos64_2_1)(FILE *stream, fpos64_t *pos) = NULL;
+static int (*__real_fsetpos64_2_17)(FILE *stream, const fpos64_t *pos) = NULL;
+static int (*__real_fsetpos64_2_2_5)(FILE *stream, const fpos64_t *pos) = NULL;
+static int (*__real_fsetpos64_2_2)(FILE *stream, const fpos64_t *pos) = NULL;
 static int (*__real_fsetpos64_2_1)(FILE *stream, const fpos64_t *pos) = NULL;
-static int (*__real_open64_2_1)(const char *path, int oflag, ...) = NULL;
-static ssize_t (*__real_pread_2_1)(int fildes, void *buf, size_t nbyte, off_t offset) = NULL;
-static ssize_t (*__real_pwrite_2_1)(int fildes, const void *buf, size_t nbyte, off_t offset) = NULL;
-static ssize_t (*__real_pwrite64_2_1)(int fildes, const void *buf, size_t nbyte, off64_t offset) = NULL;
-#endif /* ARCH() */
-#endif /* WSIZE(32) */
+static ssize_t (*__real_pwrite64_2_2)(int fildes, const void *buf, size_t nbyte, off64_t offset) = NULL;
 
 static int
 collector_align_pktsize (int sz)
@@ -378,6 +381,26 @@ detach_experiment (void)
   return 0;
 }
 
+static int
+init_fopen (void *dlflag)
+{
+  __real_fopen_2_17 = dlvsym (dlflag, "fopen", "GLIBC_2.17");
+  __real_fopen_2_2_5 = dlvsym (dlflag, "fopen", "GLIBC_2.2.5");
+  __real_fopen_2_1 = dlvsym (dlflag, "fopen", "GLIBC_2.1");
+  __real_fopen_2_0 = dlvsym (dlflag, "fopen", "GLIBC_2.0");
+  if (__real_fopen_2_17)
+    __real_fopen = __real_fopen_2_17;
+  else if (__real_fopen_2_2_5)
+    __real_fopen = __real_fopen_2_2_5;
+  else if (__real_fopen_2_1)
+    __real_fopen = __real_fopen_2_1;
+  else if (__real_fopen_2_0)
+    __real_fopen = __real_fopen_2_0;
+  else 
+    __real_fopen = dlsym (dlflag, "fopen");
+  return __real_fopen ? 1 : 0;
+}
+
 static int
 init_io_intf ()
 {
@@ -400,46 +423,11 @@ init_io_intf ()
   else
     abort ();
 
-#if ARCH(Intel)
-#if WSIZE(32)
-#define SYS_FOPEN_X_VERSION "GLIBC_2.1"
-#define SYS_FGETPOS_X_VERSION "GLIBC_2.2"
-#define SYS_FGETPOS64_X_VERSION "GLIBC_2.2"
-#define SYS_OPEN64_X_VERSION "GLIBC_2.2"
-#define SYS_PREAD_X_VERSION "GLIBC_2.2"
-#define SYS_PWRITE_X_VERSION "GLIBC_2.2"
-#define SYS_PWRITE64_X_VERSION "GLIBC_2.2"
-#else /* WSIZE(64) */
-#define SYS_FOPEN_X_VERSION "GLIBC_2.2.5"
-#define SYS_FGETPOS_X_VERSION "GLIBC_2.2.5"
-#endif
-#elif ARCH(SPARC)
-#if WSIZE(32)
-#define SYS_FOPEN_X_VERSION "GLIBC_2.1"
-#define SYS_FGETPOS_X_VERSION "GLIBC_2.2"
-#else /* WSIZE(64) */
-#define SYS_FOPEN_X_VERSION "GLIBC_2.2"
-#define SYS_FGETPOS_X_VERSION "GLIBC_2.2"
-#endif
-#elif ARCH(Aarch64)
-#define SYS_FOPEN_X_VERSION      "GLIBC_2.17"
-#define SYS_FGETPOS_X_VERSION    "GLIBC_2.17"
-#endif /* ARCH() */
-
-#if WSIZE(32)
   dlflag = RTLD_NEXT;
-  __real_fopen = (FILE * (*)(const char*, const char*))dlvsym (dlflag, "fopen", SYS_FOPEN_X_VERSION);
-  if (__real_fopen == NULL)
-    {
-      /* We are probably dlopened after libc,
-       * try to search in the previously loaded objects
-       */
-      __real_fopen = (FILE * (*)(const char*, const char*))dlvsym (RTLD_DEFAULT, "fopen", SYS_FOPEN_X_VERSION);
-      if (__real_fopen != NULL)
-	{
-	  Tprintf (0, "iotrace: WARNING: init_io_intf() using RTLD_DEFAULT for Linux io routines\n");
-	  dlflag = RTLD_DEFAULT;
-	}
+  if (init_fopen (dlflag) == 0)
+    {
+      if (init_fopen (RTLD_DEFAULT))
+	dlflag = RTLD_DEFAULT;
       else
 	{
 	  CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT fopen\n");
@@ -447,212 +435,129 @@ init_io_intf ()
 	}
     }
 
-  __real_fclose = (int (*)(FILE*))dlvsym (dlflag, "fclose", SYS_FOPEN_X_VERSION);
-  if (__real_fclose == NULL)
-    {
-      CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT fclose\n");
-      rc = COL_ERROR_IOINIT;
-    }
-
-  __real_fdopen = (FILE * (*)(int, const char*))dlvsym (dlflag, "fdopen", SYS_FOPEN_X_VERSION);
-  if (__real_fdopen == NULL)
-    {
-      CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT fdopen\n");
-      rc = COL_ERROR_IOINIT;
-    }
-
-  __real_fgetpos = (int (*)(FILE*, fpos_t*))dlvsym (dlflag, "fgetpos", SYS_FGETPOS_X_VERSION);
-  if (__real_fgetpos == NULL)
-    {
-      CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT fgetpos\n");
-      rc = COL_ERROR_IOINIT;
-    }
-
-  __real_fsetpos = (int (*)(FILE*, const fpos_t*))dlvsym (dlflag, "fsetpos", SYS_FGETPOS_X_VERSION);
-  if (__real_fsetpos == NULL)
-    {
-      CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT fsetpos\n");
-      rc = COL_ERROR_IOINIT;
-    }
-
-
-#if ARCH(Intel)
-  __real_fopen_2_1 = __real_fopen;
-  __real_fclose_2_1 = __real_fclose;
-  __real_fdopen_2_1 = __real_fdopen;
-  __real_fgetpos_2_2 = __real_fgetpos;
-  __real_fsetpos_2_2 = __real_fsetpos;
-
-  __real_fopen_2_0 = (FILE * (*)(const char*, const char*))dlvsym (dlflag, "fopen", "GLIBC_2.0");
-  if (__real_fopen_2_0 == NULL)
-    {
-      CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT fopen_2_0\n");
-      rc = COL_ERROR_IOINIT;
-    }
-
-  __real_fclose_2_0 = (int (*)(FILE*))dlvsym (dlflag, "fclose", "GLIBC_2.0");
-  if (__real_fclose_2_0 == NULL)
-    {
-      CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT fclose_2_0\n");
-      rc = COL_ERROR_IOINIT;
-    }
-
-  __real_fdopen_2_0 = (FILE * (*)(int, const char*))dlvsym (dlflag, "fdopen", "GLIBC_2.0");
-  if (__real_fdopen_2_0 == NULL)
-    {
-      CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT fdopen_2_0\n");
-      rc = COL_ERROR_IOINIT;
-    }
-
-  __real_fgetpos_2_0 = (int (*)(FILE*, fpos_t*))dlvsym (dlflag, "fgetpos", "GLIBC_2.0");
-  if (__real_fgetpos_2_0 == NULL)
-    {
-      CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT fgetpos_2_0\n");
-      rc = COL_ERROR_IOINIT;
-    }
-
-  __real_fsetpos_2_0 = (int (*)(FILE*, const fpos_t*))dlvsym (dlflag, "fsetpos", "GLIBC_2.0");
-  if (__real_fsetpos_2_0 == NULL)
-    {
-      CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT fsetpos_2_0\n");
-      rc = COL_ERROR_IOINIT;
-    }
-
-  __real_fgetpos64_2_1 = (int (*)(FILE*, fpos64_t*))dlvsym (dlflag, "fgetpos64", "GLIBC_2.1");
-  if (__real_fgetpos64_2_1 == NULL)
-    {
-      CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT fgetpos64_2_1\n");
-      rc = COL_ERROR_IOINIT;
-    }
-
-  __real_fsetpos64_2_1 = (int (*)(FILE*, const fpos64_t*))dlvsym (dlflag, "fsetpos64", "GLIBC_2.1");
-  if (__real_fsetpos64_2_1 == NULL)
-    {
-      CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT fsetpos64_2_1\n");
-      rc = COL_ERROR_IOINIT;
-    }
-
-  __real_open64_2_1 = (int (*)(const char*, int, ...))dlvsym (dlflag, "open64", "GLIBC_2.1");
-  if (__real_open64_2_1 == NULL)
-    {
-      CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT open64_2_1\n");
-      rc = COL_ERROR_IOINIT;
-    }
-
-  __real_pread_2_1 = (int (*)(int fildes, void *buf, size_t nbyte, off_t offset))dlvsym (dlflag, "pread", "GLIBC_2.1");
-  if (__real_pread_2_1 == NULL)
-    {
-      CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT pread_2_1\n");
-      rc = COL_ERROR_IOINIT;
-    }
-
-  __real_pwrite_2_1 = (int (*)(int fildes, const void *buf, size_t nbyte, off_t offset))dlvsym (dlflag, "pwrite", "GLIBC_2.1");
-  if (__real_pwrite_2_1 == NULL)
-    {
-      CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT pwrite_2_1\n");
-      rc = COL_ERROR_IOINIT;
-    }
-
-  __real_pwrite64_2_1 = (int (*)(int fildes, const void *buf, size_t nbyte, off64_t offset))dlvsym (dlflag, "pwrite64", "GLIBC_2.1");
-  if (__real_pwrite64_2_1 == NULL)
-    {
-      CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT pwrite64_2_1\n");
-      rc = COL_ERROR_IOINIT;
-    }
-
-  __real_fgetpos64_2_2 = (int (*)(FILE*, fpos64_t*))dlvsym (dlflag, "fgetpos64", SYS_FGETPOS64_X_VERSION);
-  if (__real_fgetpos64_2_2 == NULL)
-    {
-      CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT fgetpos64_2_2\n");
-      rc = COL_ERROR_IOINIT;
-    }
-
-  __real_fsetpos64_2_2 = (int (*)(FILE*, const fpos64_t*))dlvsym (dlflag, "fsetpos64", SYS_FGETPOS64_X_VERSION);
-  if (__real_fsetpos64_2_2 == NULL)
-    {
-      CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT fsetpos64_2_2\n");
-      rc = COL_ERROR_IOINIT;
-    }
-
-  __real_open64_2_2 = (int (*)(const char*, int, ...))dlvsym (dlflag, "open64", SYS_OPEN64_X_VERSION);
-  if (__real_open64_2_2 == NULL)
-    {
-      CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT open64_2_2\n");
-      rc = COL_ERROR_IOINIT;
-    }
-
-  __real_pread_2_2 = (int (*)(int fildes, void *buf, size_t nbyte, off_t offset))dlvsym (dlflag, "pread", SYS_PREAD_X_VERSION);
-  if (__real_pread_2_2 == NULL)
-    {
-      CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT pread_2_2\n");
-      rc = COL_ERROR_IOINIT;
-    }
+  __real_fgetpos64_2_17 = dlvsym (dlflag, "fgetpos64", "GLIBC_2.17");
+  __real_fgetpos64_2_2_5 = dlvsym (dlflag, "fgetpos64", "GLIBC_2.2.5");
+  __real_fgetpos64_2_2 = dlvsym (dlflag, "fgetpos64", "GLIBC_2.2");
+  __real_fgetpos64_2_1 = dlvsym (dlflag, "fgetpos64", "GLIBC_2.1");
+  if (__real_fgetpos64_2_17)
+    __real_fgetpos64 = __real_fgetpos64_2_17;
+  else if (__real_fgetpos64_2_2_5)
+    __real_fgetpos64 = __real_fgetpos64_2_2_5;
+  else if (__real_fgetpos64_2_2)
+    __real_fgetpos64 = __real_fgetpos64_2_2;
+  else if (__real_fgetpos64_2_1)
+    __real_fgetpos64 = __real_fgetpos64_2_1;
+  else
+    __real_fgetpos64 = dlsym (dlflag, "fgetpos64");
 
-  __real_pwrite_2_2 = (int (*)(int fildes, const void *buf, size_t nbyte, off_t offset))dlvsym (dlflag, "pwrite", SYS_PWRITE_X_VERSION);
-  if (__real_pwrite_2_2 == NULL)
+  __real_pread_2_2 = dlvsym (dlflag, "pread", "GLIBC_2.2");
+  if (__real_pread_2_2)
+    __real_pread = __real_pread_2_2;
+  else
+    __real_pread = dlsym (dlflag, "pread");
+  if (__real_pread == NULL)
     {
-      CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT pwrite_2_2\n");
+      CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT pread\n");
       rc = COL_ERROR_IOINIT;
     }
 
-  __real_pwrite64_2_2 = (int (*)(int fildes, const void *buf, size_t nbyte, off64_t offset))dlvsym (dlflag, "pwrite64", SYS_PWRITE64_X_VERSION);
-  if (__real_pwrite64_2_2 == NULL)
+  __real_pwrite_2_2 = dlvsym (dlflag, "pwrite", "GLIBC_2.2");
+  if (__real_pwrite_2_2)
+    __real_pwrite = __real_pwrite_2_2;
+  else
+    __real_pwrite = dlsym (dlflag, "pwrite");
+  if (__real_pwrite == NULL)
     {
-      CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT pwrite64_2_2\n");
+      CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT pwrite\n");
       rc = COL_ERROR_IOINIT;
     }
 
-#endif
 
-#else /* WSIZE(64) */
-  dlflag = RTLD_NEXT;
-  __real_fopen = (FILE * (*)(const char*, const char*))dlvsym (dlflag, "fopen", SYS_FOPEN_X_VERSION);
-  if (__real_fopen == NULL)
-    {
-      /* We are probably dlopened after libc,
-       * try to search in the previously loaded objects
-       */
-      __real_fopen = (FILE * (*)(const char*, const char*))dlvsym (RTLD_DEFAULT, "fopen", SYS_FOPEN_X_VERSION);
-      if (__real_fopen != NULL)
-	{
-	  Tprintf (0, "iotrace: WARNING: init_io_intf() using RTLD_DEFAULT for Linux io routines\n");
-	  dlflag = RTLD_DEFAULT;
-	}
-      else
-	{
-	  CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT fopen\n");
-	  rc = COL_ERROR_IOINIT;
-	}
-    }
-
-  __real_fclose = (int (*)(FILE*))dlvsym (dlflag, "fclose", SYS_FOPEN_X_VERSION);
+  __real_pwrite64_2_2 = dlvsym (dlflag, "pwrite64", "GLIBC_2.2");
+  if (__real_pwrite64_2_2)
+    __real_pwrite64 = __real_pwrite64_2_2;
+  else
+    __real_pwrite64 = dlsym (dlflag, "pwrite64");
+
+  __real_fclose_2_17 = dlvsym (dlflag, "fclose", "GLIBC_2.17");
+  __real_fclose_2_2_5 = dlvsym (dlflag, "fclose", "GLIBC_2.2.5");
+  __real_fclose_2_1 = dlvsym (dlflag, "fclose", "GLIBC_2.1");
+  __real_fclose_2_0 = dlvsym (dlflag, "fclose", "GLIBC_2.0");
+  if (__real_fclose_2_17)
+    __real_fclose = __real_fclose_2_17;
+  else if (__real_fclose_2_2_5)
+    __real_fclose = __real_fclose_2_2_5;
+  else if (__real_fclose_2_1)
+    __real_fclose = __real_fclose_2_1;
+  else if (__real_fclose_2_0)
+    __real_fclose = __real_fclose_2_0;
+  else
+    __real_fclose = dlsym (dlflag, "fclose");
   if (__real_fclose == NULL)
     {
       CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT fclose\n");
       rc = COL_ERROR_IOINIT;
     }
 
-  __real_fdopen = (FILE * (*)(int, const char*))dlvsym (dlflag, "fdopen", SYS_FOPEN_X_VERSION);
+  __real_fdopen_2_17 = dlvsym (dlflag, "fdopen", "GLIBC_2.17");
+  __real_fdopen_2_2_5 = dlvsym (dlflag, "fdopen", "GLIBC_2.2.5");
+  __real_fdopen_2_1 = dlvsym (dlflag, "fdopen", "GLIBC_2.1");
+  __real_fdopen_2_0 = dlvsym (dlflag, "fdopen", "GLIBC_2.0");
+  if (__real_fdopen_2_17)
+    __real_fdopen = __real_fdopen_2_17;
+  else if (__real_fdopen_2_2_5)
+    __real_fdopen = __real_fdopen_2_2_5;
+  else if (__real_fdopen_2_1)
+    __real_fdopen = __real_fdopen_2_1;
+  else if (__real_fdopen_2_0)
+    __real_fdopen = __real_fdopen_2_0;
+  else
+    __real_fdopen = dlsym (dlflag, "fdopen");
   if (__real_fdopen == NULL)
     {
       CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT fdopen\n");
       rc = COL_ERROR_IOINIT;
     }
 
-  __real_fgetpos = (int (*)(FILE*, fpos_t*))dlvsym (dlflag, "fgetpos", SYS_FGETPOS_X_VERSION);
+  __real_fgetpos_2_17 = dlvsym (dlflag, "fgetpos", "GLIBC_2.17");
+  __real_fgetpos_2_2_5 = dlvsym (dlflag, "fgetpos", "GLIBC_2.2.5");
+  __real_fgetpos_2_2 = dlvsym (dlflag, "fgetpos", "GLIBC_2.2");
+  __real_fgetpos_2_0 = dlvsym (dlflag, "fgetpos", "GLIBC_2.0");
+  if (__real_fgetpos_2_17)
+    __real_fgetpos = __real_fgetpos_2_17;
+  else if (__real_fgetpos_2_2_5)
+    __real_fgetpos = __real_fgetpos_2_2_5;
+  else if (__real_fgetpos_2_2)
+    __real_fgetpos = __real_fgetpos_2_2;
+  else if (__real_fgetpos_2_0)
+    __real_fgetpos = __real_fgetpos_2_0;
+  else
+    __real_fgetpos = dlsym (dlflag, "fgetpos");
   if (__real_fgetpos == NULL)
     {
       CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT fgetpos\n");
       rc = COL_ERROR_IOINIT;
     }
 
-  __real_fsetpos = (int (*)(FILE*, const fpos_t*))dlvsym (dlflag, "fsetpos", SYS_FGETPOS_X_VERSION);
+  __real_fsetpos_2_17 = dlvsym (dlflag, "fsetpos", "GLIBC_2.17");
+  __real_fsetpos_2_2_5 = dlvsym (dlflag, "fsetpos", "GLIBC_2.2.5");
+  __real_fsetpos_2_2 = dlvsym (dlflag, "fsetpos", "GLIBC_2.2");
+  __real_fsetpos_2_0 = dlvsym (dlflag, "fsetpos", "GLIBC_2.0");
+  if (__real_fsetpos_2_17)
+    __real_fsetpos = __real_fsetpos_2_17;
+  else if (__real_fsetpos_2_2_5)
+    __real_fsetpos = __real_fsetpos_2_2_5;
+  else if (__real_fsetpos_2_2)
+    __real_fsetpos = __real_fsetpos_2_2;
+  else if (__real_fsetpos_2_0)
+    __real_fsetpos = __real_fsetpos_2_0;
+  else
+    __real_fsetpos = dlsym (dlflag, "fsetpos");
   if (__real_fsetpos == NULL)
     {
       CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT fsetpos\n");
       rc = COL_ERROR_IOINIT;
     }
-#endif /* WSIZE(32) */
 
   __real_open = (int (*)(const char*, int, ...))dlsym (dlflag, "open");
   if (__real_open == NULL)
@@ -661,14 +566,11 @@ init_io_intf ()
       rc = COL_ERROR_IOINIT;
     }
 
-#if WSIZE(32)
-  __real_open64 = (int (*)(const char*, int, ...))dlsym (dlflag, "open64");
-  if (__real_open64 == NULL)
-    {
-      CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT open64\n");
-      rc = COL_ERROR_IOINIT;
-    }
-#endif
+  __real_open64_2_2 = dlvsym (dlflag, "open64", "GLIBC_2.2");
+  if (__real_open64_2_2)
+    __real_open64 = __real_open64_2_2;
+  else
+    __real_open64 = dlsym (dlflag, "open64");
 
   __real_fcntl = (int (*)(int, int, ...))dlsym (dlflag, "fcntl");
   if (__real_fcntl == NULL)
@@ -748,14 +650,12 @@ init_io_intf ()
       rc = COL_ERROR_IOINIT;
     }
 
-#if WSIZE(32)
   __real_creat64 = (int (*)(const char*, mode_t))dlsym (dlflag, "creat64");
   if (__real_creat64 == NULL)
     {
       CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT creat64\n");
       rc = COL_ERROR_IOINIT;
     }
-#endif
 
   __real_read = (ssize_t (*)(int, void*, size_t))dlsym (dlflag, "read");
   if (__real_read == NULL)
@@ -963,21 +863,6 @@ init_io_intf ()
       rc = COL_ERROR_IOINIT;
     }
 
-#if WSIZE(32)
-  __real_fgetpos64 = (int (*)(FILE*, fpos64_t*))dlsym (dlflag, "fgetpos64");
-  if (__real_fgetpos64 == NULL)
-    {
-      CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT fgetpos64\n");
-      rc = COL_ERROR_IOINIT;
-    }
-
-  __real_fsetpos64 = (int (*)(FILE*, const fpos64_t*))dlsym (dlflag, "fsetpos64");
-  if (__real_fsetpos64 == NULL)
-    {
-      CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT fsetpos64\n");
-      rc = COL_ERROR_IOINIT;
-    }
-#endif
   init_io_intf_finished++;
   return rc;
 }
@@ -1062,53 +947,9 @@ open (const char *path, int oflag, ...)
 }
 
 /*------------------------------------------------------------- open64 */
-#if ARCH(Intel) && WSIZE(32)
-// map interposed symbol versions
 static int
-__collector_open64_symver (int(real_open64) (const char *, int, ...),
-			   const char *path, int oflag, mode_t mode);
-
-SYMVER_ATTRIBUTE (__collector_open64_2_2, open64@GLIBC_2.2)
-int
-__collector_open64_2_2 (const char *path, int oflag, ...)
-{
-  mode_t mode;
-  va_list ap;
-  va_start (ap, oflag);
-  mode = va_arg (ap, mode_t);
-  va_end (ap);
-  TprintfT (DBG_LTT,
-	    "iotrace: __collector_open64_2_2@%p(path=%s, oflag=0%o, mode=0%o\n",
-	    CALL_REAL (open64_2_2), path ? path : "NULL", oflag, mode);
-  if (NULL_PTR (open64))
-    init_io_intf ();
-  return __collector_open64_symver (CALL_REAL (open64_2_2), path, oflag, mode);
-}
-
-SYMVER_ATTRIBUTE (__collector_open64_2_1, open64@GLIBC_2.1)
-int
-__collector_open64_2_1 (const char *path, int oflag, ...)
-{
-  mode_t mode;
-  va_list ap;
-  va_start (ap, oflag);
-  mode = va_arg (ap, mode_t);
-  va_end (ap);
-  TprintfT (DBG_LTT,
-	    "iotrace: __collector_open64_2_1@%p(path=%s, oflag=0%o, mode=0%o\n",
-	    CALL_REAL (open64_2_1), path ? path : "NULL", oflag, mode);
-  if (NULL_PTR (open64))
-    init_io_intf ();
-  return __collector_open64_symver (CALL_REAL (open64_2_1), path, oflag, mode);
-}
-
-#endif /* ARCH(Intel) && WSIZE(32) */
-#if WSIZE(32)
-#if ARCH(Intel) && WSIZE(32)
-
-static int
-__collector_open64_symver (int(real_open64) (const char *, int, ...),
-			   const char *path, int oflag, mode_t mode)
+gprofng_open64 (int(real_open64) (const char *, int, ...),
+		const char *path, int oflag, mode_t mode)
 {
   int *guard;
   int fd;
@@ -1116,39 +957,11 @@ __collector_open64_symver (int(real_open64) (const char *, int, ...),
   IOTrace_packet *iopkt;
   size_t sz;
   unsigned pktSize;
-  if (NULL_PTR (open64))
-    init_io_intf ();
   if (CHCK_REENTRANCE (guard) || path == NULL)
-    return (real_open64) (path, oflag, mode);
+    return real_open64 (path, oflag, mode);
   PUSH_REENTRANCE (guard);
   hrtime_t reqt = gethrtime ();
   fd = real_open64 (path, oflag, mode);
-#else /* ^ARCH(Intel) && WSIZE(32) */
-
-int
-open64 (const char *path, int oflag, ...)
-{
-  int *guard;
-  int fd;
-  void *packet;
-  IOTrace_packet *iopkt;
-  mode_t mode;
-  va_list ap;
-  size_t sz;
-  unsigned pktSize;
-
-  va_start (ap, oflag);
-  mode = va_arg (ap, mode_t);
-  va_end (ap);
-  if (NULL_PTR (open64))
-    init_io_intf ();
-  if (CHCK_REENTRANCE (guard) || path == NULL)
-    return CALL_REAL (open64)(path, oflag, mode);
-  PUSH_REENTRANCE (guard);
-  hrtime_t reqt = gethrtime ();
-  fd = CALL_REAL (open64)(path, oflag, mode);
-#endif /* ^ARCH(Intel) && WSIZE(32) */
-
   if (RECHCK_REENTRANCE (guard) || path == NULL)
     {
       POP_REENTRANCE (guard);
@@ -1174,7 +987,8 @@ open64 (const char *path, int oflag, ...)
       iopkt->fd = fd;
       iopkt->fstype = collector_fstype (path);
       collector_strncpy (&(iopkt->fname), path, sz);
-      iopkt->comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt->comm.tstamp, FRINFO_FROM_STACK, &iopkt);
+      iopkt->comm.frinfo = collector_interface->getFrameInfo (io_hndl,
+		iopkt->comm.tstamp, FRINFO_FROM_STACK_ARG, &iopkt);
       collector_interface->writeDataRecord (io_hndl, (Common_packet*) iopkt);
       collector_interface->freeCSize (io_heap, packet, pktSize);
     }
@@ -1186,7 +1000,23 @@ open64 (const char *path, int oflag, ...)
   POP_REENTRANCE (guard);
   return fd;
 }
-#endif
+
+#define DCL_OPEN64(dcl_f, real_f) \
+  int dcl_f (const char *path, int oflag, ...) \
+  { \
+    if ((real_f) == NULL) \
+      init_io_intf (); \
+    mode_t mode; \
+    va_list ap; \
+    va_start (ap, oflag); \
+    mode = va_arg (ap, mode_t); \
+    va_end (ap); \
+    return gprofng_open64 (real_f, path, oflag, mode); \
+  }
+
+DCL_FUNC_VER (DCL_OPEN64, open64_2_2, open64@GLIBC_2.2)
+DCL_OPEN64 (open64, CALL_REAL(open64))
+
 
 #define F_ERROR_ARG     0
 #define F_INT_ARG       1
@@ -1627,69 +1457,21 @@ close (int fildes)
 }
 
 /*------------------------------------------------------------- fopen */
-// map interposed symbol versions
-#if ARCH(Intel) && WSIZE(32)
-
 static FILE*
-__collector_fopen_symver (FILE*(real_fopen) (), const char *filename, const char *mode);
-
-SYMVER_ATTRIBUTE (__collector_fopen_2_1, fopen@GLIBC_2.1)
-FILE*
-__collector_fopen_2_1 (const char *filename, const char *mode)
-{
-  if (NULL_PTR (fopen))
-    init_io_intf ();
-  TprintfT (DBG_LTT, "iotrace: __collector_fopen_2_1@%p\n", CALL_REAL (fopen_2_1));
-  return __collector_fopen_symver (CALL_REAL (fopen_2_1), filename, mode);
-}
-
-SYMVER_ATTRIBUTE (__collector_fopen_2_0, fopen@GLIBC_2.0)
-FILE*
-__collector_fopen_2_0 (const char *filename, const char *mode)
-{
-  if (NULL_PTR (fopen))
-    init_io_intf ();
-  TprintfT (DBG_LTT, "iotrace: __collector_fopen_2_0@%p\n", CALL_REAL (fopen_2_0));
-  return __collector_fopen_symver (CALL_REAL (fopen_2_0), filename, mode);
-}
-
-#endif
-
-#if ARCH(Intel) && WSIZE(32)
-
-static FILE*
-__collector_fopen_symver (FILE*(real_fopen) (), const char *filename, const char *mode)
-{
-#else
-
-FILE*
-fopen (const char *filename, const char *mode)
+gprofng_fopen (FILE*(real_fopen) (), const char *filename, const char *mode)
 {
-#endif
   int *guard;
   FILE *fp = NULL;
   void *packet;
   IOTrace_packet *iopkt;
   size_t sz;
   unsigned pktSize;
-  if (NULL_PTR (fopen))
-    init_io_intf ();
   if (CHCK_REENTRANCE (guard) || filename == NULL)
-    {
-#if ARCH(Intel) && WSIZE(32)
-      return (real_fopen) (filename, mode);
-#else
-      return CALL_REAL (fopen)(filename, mode);
-#endif
-    }
+    return real_fopen (filename, mode);
   PUSH_REENTRANCE (guard);
   hrtime_t reqt = gethrtime ();
 
-#if ARCH(Intel) && WSIZE(32)
-  fp = (real_fopen) (filename, mode);
-#else
-  fp = CALL_REAL (fopen)(filename, mode);
-#endif
+  fp = real_fopen (filename, mode);
   if (RECHCK_REENTRANCE (guard))
     {
       POP_REENTRANCE (guard);
@@ -1720,12 +1502,8 @@ fopen (const char *filename, const char *mode)
 	}
       iopkt->fstype = collector_fstype (filename);
       collector_strncpy (&(iopkt->fname), filename, sz);
-
-#if ARCH(Intel) && WSIZE(32)
-      iopkt->comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt->comm.tstamp, FRINFO_FROM_STACK_ARG, &iopkt);
-#else
-      iopkt->comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt->comm.tstamp, FRINFO_FROM_STACK, &iopkt);
-#endif
+      iopkt->comm.frinfo = collector_interface->getFrameInfo (io_hndl,
+			iopkt->comm.tstamp, FRINFO_FROM_STACK_ARG, &iopkt);
       collector_interface->writeDataRecord (io_hndl, (Common_packet*) iopkt);
       collector_interface->freeCSize (io_heap, packet, pktSize);
     }
@@ -1738,66 +1516,32 @@ fopen (const char *filename, const char *mode)
   return fp;
 }
 
-/*------------------------------------------------------------- fclose */
-// map interposed symbol versions
-#if ARCH(Intel) && WSIZE(32)
-
-static int
-__collector_fclose_symver (int(real_fclose) (), FILE *stream);
-
-SYMVER_ATTRIBUTE (__collector_fclose_2_1, fclose@GLIBC_2.1)
-int
-__collector_fclose_2_1 (FILE *stream)
-{
-  if (NULL_PTR (fclose))
-    init_io_intf ();
-  TprintfT (DBG_LTT, "iotrace: __collector_fclose_2_1@%p\n", CALL_REAL (fclose_2_1));
-  return __collector_fclose_symver (CALL_REAL (fclose_2_1), stream);
-}
-
-SYMVER_ATTRIBUTE (__collector_fclose_2_0, fclose@GLIBC_2.0)
-int
-__collector_fclose_2_0 (FILE *stream)
-{
-  if (NULL_PTR (fclose))
-    init_io_intf ();
-  TprintfT (DBG_LTT, "iotrace: __collector_fclose_2_0@%p\n", CALL_REAL (fclose_2_0));
-  return __collector_fclose_symver (CALL_REAL (fclose_2_0), stream);
-}
-
-#endif
+#define DCL_FOPEN(dcl_f, real_f) \
+  FILE *dcl_f (const char *filename, const char *mode) \
+  { \
+    if ((real_f) == NULL) \
+      init_io_intf (); \
+    return gprofng_fopen (real_f, filename, mode); \
+  }
 
-#if ARCH(Intel) && WSIZE(32)
+DCL_FUNC_VER (DCL_FOPEN, fopen_2_17, fopen@GLIBC_2.17)
+DCL_FUNC_VER (DCL_FOPEN, fopen_2_2_5, fopen@GLIBC_2.2.5)
+DCL_FUNC_VER (DCL_FOPEN, fopen_2_1, fopen@GLIBC_2.1)
+DCL_FUNC_VER (DCL_FOPEN, fopen_2_0, fopen@GLIBC_2.0)
+DCL_FOPEN (fopen, CALL_REAL(fopen))
 
+/*------------------------------------------------------------- fclose */
 static int
-__collector_fclose_symver (int(real_fclose) (), FILE *stream)
-{
-#else
-
-int
-fclose (FILE *stream)
+gprofng_fclose (int(real_fclose) (), FILE *stream)
 {
-#endif
   int *guard;
   int stat;
   IOTrace_packet iopkt;
-  if (NULL_PTR (fclose))
-    init_io_intf ();
   if (CHCK_REENTRANCE (guard) || stream == NULL)
-    {
-#if ARCH(Intel) && WSIZE(32)
-      return (real_fclose) (stream);
-#else
-      return CALL_REAL (fclose)(stream);
-#endif
-    }
+    return real_fclose (stream);
   PUSH_REENTRANCE (guard);
   hrtime_t reqt = gethrtime ();
-#if ARCH(Intel) && WSIZE(32)
-  stat = (real_fclose) (stream);
-#else
-  stat = CALL_REAL (fclose)(stream);
-#endif
+  stat = real_fclose (stream);
   if (RECHCK_REENTRANCE (guard))
     {
       POP_REENTRANCE (guard);
@@ -1813,17 +1557,27 @@ fclose (FILE *stream)
   else
     iopkt.iotype = CLOSE_TRACE_ERROR;
   iopkt.fd = fileno (stream);
-
-#if ARCH(Intel) && WSIZE(32)
-  iopkt.comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt.comm.tstamp, FRINFO_FROM_STACK_ARG, &iopkt);
-#else
-  iopkt.comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt.comm.tstamp, FRINFO_FROM_STACK, &iopkt);
-#endif
+  iopkt.comm.frinfo = collector_interface->getFrameInfo (io_hndl,
+			iopkt.comm.tstamp, FRINFO_FROM_STACK_ARG, &iopkt);
   collector_interface->writeDataRecord (io_hndl, (Common_packet*) & iopkt);
   POP_REENTRANCE (guard);
   return stat;
 }
 
+#define DCL_FCLOSE(dcl_f, real_f) \
+  int dcl_f (FILE *stream) \
+  { \
+    if ((real_f) == NULL) \
+      init_io_intf (); \
+    return gprofng_fclose (real_f, stream); \
+  }
+
+DCL_FUNC_VER (DCL_FCLOSE, fclose_2_17, fclose@GLIBC_2.17)
+DCL_FUNC_VER (DCL_FCLOSE, fclose_2_2_5, fclose@GLIBC_2.2.5)
+DCL_FUNC_VER (DCL_FCLOSE, fclose_2_1, fclose@GLIBC_2.1)
+DCL_FUNC_VER (DCL_FCLOSE, fclose_2_0, fclose@GLIBC_2.0)
+DCL_FCLOSE (fclose, CALL_REAL(fclose))
+
 /*------------------------------------------------------------- fflush */
 int
 fflush (FILE *stream)
@@ -1863,63 +1617,19 @@ fflush (FILE *stream)
 }
 
 /*------------------------------------------------------------- fdopen */
-// map interposed symbol versions
-#if ARCH(Intel) && WSIZE(32)
-
 static FILE*
-__collector_fdopen_symver (FILE*(real_fdopen) (), int fildes, const char *mode);
-
-SYMVER_ATTRIBUTE (__collector_fdopen_2_1, fdopen@GLIBC_2.1)
-FILE*
-__collector_fdopen_2_1 (int fildes, const char *mode)
+gprofng_fdopen (FILE*(real_fdopen) (), int fildes, const char *mode)
 {
-  if (NULL_PTR (fdopen))
-    init_io_intf ();
-  TprintfT (DBG_LTT, "iotrace: __collector_fdopen_2_1@%p\n", CALL_REAL (fdopen_2_1));
-  return __collector_fdopen_symver (CALL_REAL (fdopen_2_1), fildes, mode);
-}
-
-SYMVER_ATTRIBUTE (__collector_fdopen_2_0, fdopen@GLIBC_2.0)
-FILE*
-__collector_fdopen_2_0 (int fildes, const char *mode)
-{
-  if (NULL_PTR (fdopen))
-    init_io_intf ();
-  TprintfT (DBG_LTT, "iotrace: __collector_fdopen_2_0@%p\n", CALL_REAL (fdopen_2_0));
-  return __collector_fdopen_symver (CALL_REAL (fdopen_2_0), fildes, mode);
-}
-
-#endif
-
-#if ARCH(Intel) && WSIZE(32)
-static FILE*
-__collector_fdopen_symver (FILE*(real_fdopen) (), int fildes, const char *mode)
-{
-#else
-FILE*
-fdopen (int fildes, const char *mode)
-{
-#endif
   int *guard;
   FILE *fp = NULL;
   IOTrace_packet iopkt;
   if (NULL_PTR (fdopen))
     init_io_intf ();
   if (CHCK_REENTRANCE (guard))
-    {
-#if ARCH(Intel) && WSIZE(32)
-      return (real_fdopen) (fildes, mode);
-#else
-      return CALL_REAL (fdopen)(fildes, mode);
-#endif
-    }
+    return real_fdopen (fildes, mode);
   PUSH_REENTRANCE (guard);
   hrtime_t reqt = gethrtime ();
-#if ARCH(Intel) && WSIZE(32)
-  fp = (real_fdopen) (fildes, mode);
-#else
-  fp = CALL_REAL (fdopen)(fildes, mode);
-#endif
+  fp = real_fdopen (fildes, mode);
   if (RECHCK_REENTRANCE (guard))
     {
       POP_REENTRANCE (guard);
@@ -1936,16 +1646,27 @@ fdopen (int fildes, const char *mode)
     iopkt.iotype = OPEN_TRACE_ERROR;
   iopkt.fd = fildes;
   iopkt.fstype = UNKNOWNFS_TYPE;
-#if ARCH(Intel) && WSIZE(32)
-  iopkt.comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt.comm.tstamp, FRINFO_FROM_STACK_ARG, &iopkt);
-#else
-  iopkt.comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt.comm.tstamp, FRINFO_FROM_STACK, &iopkt);
-#endif
+  iopkt.comm.frinfo = collector_interface->getFrameInfo (io_hndl,
+			iopkt.comm.tstamp, FRINFO_FROM_STACK_ARG, &iopkt);
   collector_interface->writeDataRecord (io_hndl, (Common_packet*) & iopkt);
   POP_REENTRANCE (guard);
   return fp;
 }
 
+#define DCL_FDOPEN(dcl_f, real_f) \
+  FILE *dcl_f (int fildes, const char *mode) \
+  { \
+    if ((real_f) == NULL) \
+      init_io_intf (); \
+    return gprofng_fdopen (real_f, fildes, mode); \
+  }
+
+DCL_FUNC_VER (DCL_FDOPEN, fdopen_2_17, fdopen@GLIBC_2.17)
+DCL_FUNC_VER (DCL_FDOPEN, fdopen_2_2_5, fdopen@GLIBC_2.2.5)
+DCL_FUNC_VER (DCL_FDOPEN, fdopen_2_1, fdopen@GLIBC_2.1)
+DCL_FUNC_VER (DCL_FDOPEN, fdopen_2_0, fdopen@GLIBC_2.0)
+DCL_FDOPEN (fdopen, CALL_REAL(fdopen))
+
 /*------------------------------------------------------------- dup */
 int
 dup (int fildes)
@@ -2332,62 +2053,18 @@ fwrite (const void *ptr, size_t size, size_t nitems, FILE *stream)
 }
 
 /*------------------------------------------------------------- pread */
-#if ARCH(Intel) && WSIZE(32)
-// map interposed symbol versions
-static int
-__collector_pread_symver (int(real_pread) (), int fildes, void *buf, size_t nbyte, off_t offset);
-
-SYMVER_ATTRIBUTE (__collector_pread_2_2, pread@GLIBC_2.2)
-int
-__collector_pread_2_2 (int fildes, void *buf, size_t nbyte, off_t offset)
+static ssize_t
+gprofng_pread (ssize_t(real_pread) (int, void *, size_t, off_t),
+	       int fildes, void *buf, size_t nbyte, off_t offset)
 {
-  TprintfT (DBG_LTT, "iotrace: __collector_pread_2_2@%p(fildes=%d, buf=%p, nbyte=%lld, offset=%lld)\n",
-	    CALL_REAL (pread_2_2), fildes, buf, (long long) nbyte, (long long) offset);
-  if (NULL_PTR (pread))
-    init_io_intf ();
-  return __collector_pread_symver (CALL_REAL (pread_2_2), fildes, buf, nbyte, offset);
-}
-
-SYMVER_ATTRIBUTE (__collector_pread_2_1, pread@GLIBC_2.1)
-int
-__collector_pread_2_1 (int fildes, void *buf, size_t nbyte, off_t offset)
-{
-  TprintfT (DBG_LTT, "iotrace: __collector_pread_2_1@%p(fildes=%d, buf=%p, nbyte=%lld, offset=%lld)\n",
-	    CALL_REAL (pread_2_1), fildes, buf, (long long) nbyte, (long long) offset);
-  if (NULL_PTR (pread))
-    init_io_intf ();
-  return __collector_pread_symver (CALL_REAL (pread_2_1), fildes, buf, nbyte, offset);
-}
-
-static int
-__collector_pread_symver (int(real_pread) (), int fildes, void *buf, size_t nbyte, off_t offset)
-{
-#else /* ^ARCH(Intel) && WSIZE(32) */
-
-ssize_t
-pread (int fildes, void *buf, size_t nbyte, off_t offset)
-{
-#endif
   int *guard;
   ssize_t ret;
   IOTrace_packet iopkt;
-  if (NULL_PTR (pread))
-    init_io_intf ();
   if (CHCK_REENTRANCE (guard))
-    {
-#if ARCH(Intel) && WSIZE(32)
-      return (real_pread) (fildes, buf, nbyte, offset);
-#else
-      return CALL_REAL (pread)(fildes, buf, nbyte, offset);
-#endif
-    }
+    return real_pread (fildes, buf, nbyte, offset);
   PUSH_REENTRANCE (guard);
   hrtime_t reqt = gethrtime ();
-#if ARCH(Intel) && WSIZE(32)
-  ret = (real_pread) (fildes, buf, nbyte, offset);
-#else
-  ret = CALL_REAL (pread)(fildes, buf, nbyte, offset);
-#endif
+  ret = real_pread (fildes, buf, nbyte, offset);
   if (RECHCK_REENTRANCE (guard))
     {
       POP_REENTRANCE (guard);
@@ -2404,15 +2081,27 @@ pread (int fildes, void *buf, size_t nbyte, off_t offset)
     iopkt.iotype = READ_TRACE_ERROR;
   iopkt.fd = fildes;
   iopkt.nbyte = ret;
-  iopkt.comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt.comm.tstamp, FRINFO_FROM_STACK, &iopkt);
-  collector_interface->writeDataRecord (io_hndl, (Common_packet*) & iopkt);
+  iopkt.comm.frinfo = collector_interface->getFrameInfo (io_hndl,
+			iopkt.comm.tstamp, FRINFO_FROM_STACK_ARG, &iopkt);
+  collector_interface->writeDataRecord (io_hndl, (Common_packet*) &iopkt);
   POP_REENTRANCE (guard);
   return ret;
 }
 
+#define DCL_PREAD(dcl_f, real_f) \
+  ssize_t dcl_f (int fildes, void *buf, size_t nbyte, off_t offset) \
+  { \
+    if ((real_f) == NULL) \
+      init_io_intf (); \
+    return gprofng_pread (real_f, fildes, buf, nbyte, offset); \
+  }
+
+DCL_FUNC_VER (DCL_PREAD, pread_2_2, pread@GLIBC_2.2)
+DCL_PREAD (pread, CALL_REAL(pread))
+
 /*------------------------------------------------------------- pwrite */
 
-#if !defined(__MUSL_LIBC) && ARCH(Intel) && WSIZE(32)
+#if !defined(__MUSL_LIBC)
 // map interposed symbol versions
 
 SYMVER_ATTRIBUTE (__collector_pwrite_2_2, pwrite@GLIBC_2.2)
@@ -2437,28 +2126,6 @@ __collector_pwrite_2_2 (int fildes, const void *buf, size_t nbyte, off_t offset)
   return ret;
 }
 
-SYMVER_ATTRIBUTE (__collector_pwrite_2_1, pwrite@GLIBC_2.1)
-int
-__collector_pwrite_2_1 (int fildes, const void *buf, size_t nbyte, off_t offset)
-{
-  int *guard;
-  if (NULL_PTR (pwrite_2_1))
-    init_io_intf ();
-  if (CHCK_REENTRANCE (guard))
-    return CALL_REAL (pwrite_2_1)(fildes, buf, nbyte, offset);
-  PUSH_REENTRANCE (guard);
-  hrtime_t reqt = gethrtime ();
-  ssize_t ret = CALL_REAL (pwrite_2_1)(fildes, buf, nbyte, offset);
-  if (RECHCK_REENTRANCE (guard))
-    {
-      POP_REENTRANCE (guard);
-      return ret;
-    }
-  write_io_packet (fildes, ret, reqt, ret >= 0 ? WRITE_TRACE : WRITE_TRACE_ERROR);
-  POP_REENTRANCE (guard);
-  return ret;
-}
-
 #endif
 ssize_t
 pwrite (int fildes, const void *buf, size_t nbyte, off_t offset)
@@ -2482,7 +2149,7 @@ pwrite (int fildes, const void *buf, size_t nbyte, off_t offset)
 }
 
 /*------------------------------------------------------------- pwrite64 */
-#if WSIZE(32) && ARCH(Intel)
+#if WSIZE(32) && !defined(__USE_FILE_OFFSET64)
 #if !defined(__MUSL_LIBC)
 // map interposed symbol versions
 
@@ -2507,31 +2174,8 @@ __collector_pwrite64_2_2 (int fildes, const void *buf, size_t nbyte, off64_t off
   POP_REENTRANCE (guard);
   return ret;
 }
-
-SYMVER_ATTRIBUTE (__collector_pwrite64_2_1, pwrite64@GLIBC_2.1)
-int
-__collector_pwrite64_2_1 (int fildes, const void *buf, size_t nbyte, off64_t offset)
-{
-  int *guard;
-  if (NULL_PTR (pwrite64_2_1))
-    init_io_intf ();
-  if (CHCK_REENTRANCE (guard))
-    return CALL_REAL (pwrite64_2_1)(fildes, buf, nbyte, offset);
-  PUSH_REENTRANCE (guard);
-  hrtime_t reqt = gethrtime ();
-  ssize_t ret = CALL_REAL (pwrite64_2_1)(fildes, buf, nbyte, offset);
-  if (RECHCK_REENTRANCE (guard))
-    {
-      POP_REENTRANCE (guard);
-      return ret;
-    }
-  write_io_packet (fildes, ret, reqt, ret >= 0 ? WRITE_TRACE : WRITE_TRACE_ERROR);
-  POP_REENTRANCE (guard);
-  return ret;
-}
 #endif
 
-#if !defined(__USE_FILE_OFFSET64)
 ssize_t
 pwrite64 (int fildes, const void *buf, size_t nbyte, off64_t offset)
 {
@@ -2554,8 +2198,6 @@ pwrite64 (int fildes, const void *buf, size_t nbyte, off64_t offset)
 }
 #endif
 
-#endif /* SIZE(32)  && ARCH(Intel) */
-
 /*------------------------------------------------------------- fgets */
 char*
 fgets (char *s, int n, FILE *stream)
@@ -3238,62 +2880,18 @@ ftell (FILE *stream)
 }
 
 /*------------------------------------------------------------- fgetpos */
-// map interposed symbol versions
-#if ARCH(Intel) && WSIZE(32)
 static int
-__collector_fgetpos_symver (int(real_fgetpos) (), FILE *stream, fpos_t *pos);
-
-SYMVER_ATTRIBUTE (__collector_fgetpos_2_2, fgetpos@GLIBC_2.2)
-int
-__collector_fgetpos_2_2 (FILE *stream, fpos_t *pos)
+gprofng_fgetpos (int(real_fgetpos) (FILE *stream, fpos_t *pos),
+		 FILE *stream, fpos_t *pos)
 {
-  if (NULL_PTR (fgetpos))
-    init_io_intf ();
-  TprintfT (DBG_LTT, "iotrace: __collector_fgetpos_2_2@%p\n", CALL_REAL (fgetpos_2_2));
-  return __collector_fgetpos_symver (CALL_REAL (fgetpos_2_2), stream, pos);
-}
-
-SYMVER_ATTRIBUTE (__collector_fgetpos_2_0, fgetpos@GLIBC_2.0)
-int
-__collector_fgetpos_2_0 (FILE *stream, fpos_t *pos)
-{
-  if (NULL_PTR (fgetpos))
-    init_io_intf ();
-  TprintfT (DBG_LTT, "iotrace: __collector_fgetpos_2_0@%p\n", CALL_REAL (fgetpos_2_0));
-  return __collector_fgetpos_symver (CALL_REAL (fgetpos_2_0), stream, pos);
-}
-#endif
-
-#if ARCH(Intel) && WSIZE(32)
-
-static int
-__collector_fgetpos_symver (int(real_fgetpos) (), FILE *stream, fpos_t *pos)
-{
-#else
-int
-fgetpos (FILE *stream, fpos_t *pos)
-{
-#endif
   int *guard;
   int ret;
   IOTrace_packet iopkt;
-  if (NULL_PTR (fgetpos))
-    init_io_intf ();
   if (CHCK_REENTRANCE (guard) || stream == NULL)
-    {
-#if ARCH(Intel) && WSIZE(32)
-      return (real_fgetpos) (stream, pos);
-#else
-      return CALL_REAL (fgetpos)(stream, pos);
-#endif
-    }
+    return real_fgetpos (stream, pos);
   PUSH_REENTRANCE (guard);
   hrtime_t reqt = gethrtime ();
-#if ARCH(Intel) && WSIZE(32)
-  ret = (real_fgetpos) (stream, pos);
-#else
-  ret = CALL_REAL (fgetpos)(stream, pos);
-#endif
+  ret = real_fgetpos (stream, pos);
   if (RECHCK_REENTRANCE (guard))
     {
       POP_REENTRANCE (guard);
@@ -3309,75 +2907,39 @@ fgetpos (FILE *stream, fpos_t *pos)
   else
     iopkt.iotype = OTHERIO_TRACE_ERROR;
   iopkt.fd = fileno (stream);
-
-#if ARCH(Intel) && WSIZE(32)
-  iopkt.comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt.comm.tstamp, FRINFO_FROM_STACK_ARG, &iopkt);
-#else
-  iopkt.comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt.comm.tstamp, FRINFO_FROM_STACK, &iopkt);
-#endif
-  collector_interface->writeDataRecord (io_hndl, (Common_packet*) & iopkt);
+  iopkt.comm.frinfo = collector_interface->getFrameInfo (io_hndl,
+			iopkt.comm.tstamp, FRINFO_FROM_STACK_ARG, &iopkt);
+  collector_interface->writeDataRecord (io_hndl, (Common_packet*) &iopkt);
   POP_REENTRANCE (guard);
   return ret;
 }
 
-#if WSIZE(32)
-/*------------------------------------------------------------- fgetpos64 */
-#if ARCH(Intel)
-// map interposed symbol versions
+#define DCL_FGETPOS(dcl_f, real_f) \
+  int dcl_f (FILE *stream, fpos_t *pos) \
+  { \
+    if ((real_f) == NULL) \
+      init_io_intf (); \
+    return gprofng_fgetpos (real_f, stream, pos); \
+  }
 
-static int
-__collector_fgetpos64_symver (int(real_fgetpos64) (), FILE *stream, fpos64_t *pos);
-
-SYMVER_ATTRIBUTE (__collector_fgetpos64_2_2, fgetpos64@GLIBC_2.2)
-int
-__collector_fgetpos64_2_2 (FILE *stream, fpos64_t *pos)
-{
-  TprintfT (DBG_LTT, "iotrace: __collector_fgetpos64_2_2@%p(stream=%p, pos=%p)\n",
-	    CALL_REAL (fgetpos64_2_2), stream, pos);
-  if (NULL_PTR (fgetpos64))
-    init_io_intf ();
-  return __collector_fgetpos64_symver (CALL_REAL (fgetpos64_2_2), stream, pos);
-}
-
-SYMVER_ATTRIBUTE (__collector_fgetpos64_2_1, fgetpos64@GLIBC_2.1)
-int
-__collector_fgetpos64_2_1 (FILE *stream, fpos64_t *pos)
-{
-  TprintfT (DBG_LTT, "iotrace: __collector_fgetpos64_2_1@%p(stream=%p, pos=%p)\n",
-	    CALL_REAL (fgetpos64_2_1), stream, pos);
-  if (NULL_PTR (fgetpos64))
-    init_io_intf ();
-  return __collector_fgetpos64_symver (CALL_REAL (fgetpos64_2_1), stream, pos);
-}
+DCL_FUNC_VER (DCL_FGETPOS, fgetpos_2_17, fgetpos@GLIBC_2.17)
+DCL_FUNC_VER (DCL_FGETPOS, fgetpos_2_2_5, fgetpos@GLIBC_2.2.5)
+DCL_FUNC_VER (DCL_FGETPOS, fgetpos_2_2, fgetpos@GLIBC_2.2)
+DCL_FUNC_VER (DCL_FGETPOS, fgetpos_2_0, fgetpos@GLIBC_2.0)
+DCL_FGETPOS (fgetpos, CALL_REAL(fgetpos))
 
+/*------------------------------------------------------------- fgetpos64 */
 static int
-__collector_fgetpos64_symver (int(real_fgetpos64) (), FILE *stream, fpos64_t *pos)
+gprofng_fgetpos64 (int(real_fgetpos64) (), FILE *stream, fpos64_t *pos)
 {
-#else
-int
-fgetpos64 (FILE *stream, fpos64_t *pos)
-{
-#endif
   int *guard;
   int ret;
   IOTrace_packet iopkt;
-  if (NULL_PTR (fgetpos64))
-    init_io_intf ();
   if (CHCK_REENTRANCE (guard) || stream == NULL)
-    {
-#if ARCH(Intel)
-      return (real_fgetpos64) (stream, pos);
-#else
-      return CALL_REAL (fgetpos64)(stream, pos);
-#endif
-    }
+    return real_fgetpos64 (stream, pos);
   PUSH_REENTRANCE (guard);
   hrtime_t reqt = gethrtime ();
-#if ARCH(Intel)
-  ret = (real_fgetpos64) (stream, pos);
-#else
-  ret = CALL_REAL (fgetpos64)(stream, pos);
-#endif
+  ret = real_fgetpos64 (stream, pos);
   if (RECHCK_REENTRANCE (guard))
     {
       POP_REENTRANCE (guard);
@@ -3393,74 +2955,40 @@ fgetpos64 (FILE *stream, fpos64_t *pos)
   else
     iopkt.iotype = OTHERIO_TRACE_ERROR;
   iopkt.fd = fileno (stream);
-#if ARCH(Intel)
-  iopkt.comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt.comm.tstamp, FRINFO_FROM_STACK_ARG, &iopkt);
-#else
-  iopkt.comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt.comm.tstamp, FRINFO_FROM_STACK, &iopkt);
-#endif
-  collector_interface->writeDataRecord (io_hndl, (Common_packet*) & iopkt);
+  iopkt.comm.frinfo = collector_interface->getFrameInfo (io_hndl,
+			iopkt.comm.tstamp, FRINFO_FROM_STACK_ARG, &iopkt);
+  collector_interface->writeDataRecord (io_hndl, (Common_packet*) &iopkt);
   POP_REENTRANCE (guard);
   return ret;
 }
-#endif
 
-/*------------------------------------------------------------- fsetpos */
-// map interposed symbol versions
-#if ARCH(Intel) && WSIZE(32)
-static int
-__collector_fsetpos_symver (int(real_fsetpos) (), FILE *stream, const fpos_t *pos);
+#define DCL_FGETPOS64(dcl_f, real_f) \
+  int dcl_f (FILE *stream, fpos64_t *pos) \
+  { \
+    if ((real_f) == NULL) \
+      init_io_intf (); \
+    return gprofng_fgetpos64 (real_f, stream, pos); \
+  }
 
-SYMVER_ATTRIBUTE (__collector_fsetpos_2_2, fsetpos@GLIBC_2.2)
-int
-__collector_fsetpos_2_2 (FILE *stream, const fpos_t *pos)
-{
-  if (NULL_PTR (fsetpos))
-    init_io_intf ();
-  TprintfT (DBG_LTT, "iotrace: __collector_fsetpos_2_2@%p\n", CALL_REAL (fsetpos_2_2));
-  return __collector_fsetpos_symver (CALL_REAL (fsetpos_2_2), stream, pos);
-}
-
-SYMVER_ATTRIBUTE (__collector_fsetpos_2_0, fsetpos@GLIBC_2.0)
-int
-__collector_fsetpos_2_0 (FILE *stream, const fpos_t *pos)
-{
-  if (NULL_PTR (fsetpos))
-    init_io_intf ();
-  TprintfT (DBG_LTT, "iotrace: __collector_fsetpos_2_0@%p\n", CALL_REAL (fsetpos_2_0));
-  return __collector_fsetpos_symver (CALL_REAL (fsetpos_2_0), stream, pos);
-}
-#endif
-
-#if ARCH(Intel) && WSIZE(32)
+DCL_FUNC_VER (DCL_FGETPOS64, fgetpos64_2_17, fgetpos64@GLIBC_2.17)
+DCL_FUNC_VER (DCL_FGETPOS64, fgetpos64_2_2_5, fgetpos64@GLIBC_2.2.5)
+DCL_FUNC_VER (DCL_FGETPOS64, fgetpos64_2_2, fgetpos64@GLIBC_2.2)
+DCL_FUNC_VER (DCL_FGETPOS64, fgetpos64_2_1, fgetpos64@GLIBC_2.1)
+DCL_FGETPOS64 (fgetpos64, CALL_REAL(fgetpos64))
 
+/*------------------------------------------------------------- fsetpos */
 static int
-__collector_fsetpos_symver (int(real_fsetpos) (), FILE *stream, const fpos_t *pos)
+gprofng_fsetpos (int(real_fsetpos) (FILE *, const fpos_t *),
+		 FILE *stream, const fpos_t *pos)
 {
-#else
-int
-fsetpos (FILE *stream, const fpos_t *pos)
-{
-#endif
   int *guard;
   int ret;
   IOTrace_packet iopkt;
-  if (NULL_PTR (fsetpos))
-    init_io_intf ();
   if (CHCK_REENTRANCE (guard) || stream == NULL)
-    {
-#if ARCH(Intel) && WSIZE(32)
-      return (real_fsetpos) (stream, pos);
-#else
-      return CALL_REAL (fsetpos)(stream, pos);
-#endif
-    }
+    return real_fsetpos (stream, pos);
   PUSH_REENTRANCE (guard);
   hrtime_t reqt = gethrtime ();
-#if ARCH(Intel) && WSIZE(32)
-  ret = (real_fsetpos) (stream, pos);
-#else
-  ret = CALL_REAL (fsetpos)(stream, pos);
-#endif
+  ret = real_fsetpos (stream, pos);
   if (RECHCK_REENTRANCE (guard))
     {
       POP_REENTRANCE (guard);
@@ -3476,73 +3004,40 @@ fsetpos (FILE *stream, const fpos_t *pos)
   else
     iopkt.iotype = OTHERIO_TRACE_ERROR;
   iopkt.fd = fileno (stream);
-#if ARCH(Intel) && WSIZE(32)
-  iopkt.comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt.comm.tstamp, FRINFO_FROM_STACK_ARG, &iopkt);
-#else
-  iopkt.comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt.comm.tstamp, FRINFO_FROM_STACK, &iopkt);
-#endif
-  collector_interface->writeDataRecord (io_hndl, (Common_packet*) & iopkt);
+  iopkt.comm.frinfo = collector_interface->getFrameInfo (io_hndl,
+			iopkt.comm.tstamp, FRINFO_FROM_STACK_ARG, &iopkt);
+  collector_interface->writeDataRecord (io_hndl, (Common_packet*) &iopkt);
   POP_REENTRANCE (guard);
   return ret;
 }
 
-#if WSIZE(32)
-/*------------------------------------------------------------- fsetpos64 */
-#if ARCH(Intel)
-// map interposed symbol versions
-static int
-__collector_fsetpos64_symver (int(real_fsetpos64) (), FILE *stream, const fpos64_t *pos);
-
-SYMVER_ATTRIBUTE (__collector_fsetpos64_2_2, fsetpos64@GLIBC_2.2)
-int
-__collector_fsetpos64_2_2 (FILE *stream, const fpos64_t *pos)
-{
-  TprintfT (DBG_LTT, "iotrace: __collector_fsetpos64_2_2@%p(stream=%p, pos=%p)\n",
-	    CALL_REAL (fsetpos64_2_2), stream, pos);
-  if (NULL_PTR (fsetpos64))
-    init_io_intf ();
-  return __collector_fsetpos64_symver (CALL_REAL (fsetpos64_2_2), stream, pos);
-}
+#define DCL_FSETPOS(dcl_f, real_f) \
+  int dcl_f (FILE *stream, const fpos_t *pos) \
+  { \
+    if ((real_f) == NULL) \
+      init_io_intf (); \
+    return gprofng_fsetpos (real_f, stream, pos); \
+  }
 
-SYMVER_ATTRIBUTE (__collector_fsetpos64_2_1, fsetpos64@GLIBC_2.1)
-int
-__collector_fsetpos64_2_1 (FILE *stream, const fpos64_t *pos)
-{
-  TprintfT (DBG_LTT, "iotrace: __collector_fsetpos64_2_1@%p(stream=%p, pos=%p)\n",
-	    CALL_REAL (fsetpos64_2_1), stream, pos);
-  if (NULL_PTR (fsetpos64))
-    init_io_intf ();
-  return __collector_fsetpos64_symver (CALL_REAL (fsetpos64_2_1), stream, pos);
-}
+DCL_FUNC_VER (DCL_FSETPOS, fsetpos_2_17, fsetpos@GLIBC_2.17)
+DCL_FUNC_VER (DCL_FSETPOS, fsetpos_2_2_5, fsetpos@GLIBC_2.2.5)
+DCL_FUNC_VER (DCL_FSETPOS, fsetpos_2_2, fsetpos@GLIBC_2.2)
+DCL_FUNC_VER (DCL_FSETPOS, fsetpos_2_0, fsetpos@GLIBC_2.0)
+DCL_FSETPOS (fsetpos, CALL_REAL(fsetpos))
 
+/*------------------------------------------------------------- fsetpos64 */
 static int
-__collector_fsetpos64_symver (int(real_fsetpos64) (), FILE *stream, const fpos64_t *pos)
+gprofng_fsetpos64 (int(real_fsetpos64) (FILE *, const fpos64_t *),
+		   FILE *stream, const fpos64_t *pos)
 {
-#else
-int
-fsetpos64 (FILE *stream, const fpos64_t *pos)
-{
-#endif
   int *guard;
   int ret;
   IOTrace_packet iopkt;
-  if (NULL_PTR (fsetpos64))
-    init_io_intf ();
   if (CHCK_REENTRANCE (guard) || stream == NULL)
-    {
-#if ARCH(Intel) && WSIZE(32)
-      return (real_fsetpos64) (stream, pos);
-#else
-      return CALL_REAL (fsetpos64)(stream, pos);
-#endif
-    }
+    return real_fsetpos64 (stream, pos);
   PUSH_REENTRANCE (guard);
   hrtime_t reqt = gethrtime ();
-#if ARCH(Intel) && WSIZE(32)
-  ret = (real_fsetpos64) (stream, pos);
-#else
-  ret = CALL_REAL (fsetpos64)(stream, pos);
-#endif
+  ret = real_fsetpos64 (stream, pos);
   if (RECHCK_REENTRANCE (guard))
     {
       POP_REENTRANCE (guard);
@@ -3558,16 +3053,26 @@ fsetpos64 (FILE *stream, const fpos64_t *pos)
   else
     iopkt.iotype = OTHERIO_TRACE_ERROR;
   iopkt.fd = fileno (stream);
-#if ARCH(Intel)
-  iopkt.comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt.comm.tstamp, FRINFO_FROM_STACK_ARG, &iopkt);
-#else
-  iopkt.comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt.comm.tstamp, FRINFO_FROM_STACK, &iopkt);
-#endif
+  iopkt.comm.frinfo = collector_interface->getFrameInfo (io_hndl,
+			iopkt.comm.tstamp, FRINFO_FROM_STACK_ARG, &iopkt);
   collector_interface->writeDataRecord (io_hndl, (Common_packet*) & iopkt);
   POP_REENTRANCE (guard);
   return ret;
 }
-#endif
+
+#define DCL_FSETPOS64(dcl_f, real_f) \
+  int dcl_f (FILE *stream, const fpos64_t *pos) \
+  { \
+    if ((real_f) == NULL) \
+      init_io_intf (); \
+    return gprofng_fsetpos64 (real_f, stream, pos); \
+  }
+
+DCL_FUNC_VER (DCL_FSETPOS64, fsetpos64_2_17, fsetpos64@GLIBC_2.17)
+DCL_FUNC_VER (DCL_FSETPOS64, fsetpos64_2_2_5, fsetpos64@GLIBC_2.2.5)
+DCL_FUNC_VER (DCL_FSETPOS64, fsetpos64_2_2, fsetpos64@GLIBC_2.2)
+DCL_FUNC_VER (DCL_FSETPOS64, fsetpos64_2_1, fsetpos64@GLIBC_2.1)
+DCL_FSETPOS64 (fsetpos64, CALL_REAL(fsetpos64))
 
 /*------------------------------------------------------------- fsync */
 int
diff --git a/gprofng/libcollector/libcol_util.c b/gprofng/libcollector/libcol_util.c
index b1607333df1..a8802d4a9b0 100644
--- a/gprofng/libcollector/libcol_util.c
+++ b/gprofng/libcollector/libcol_util.c
@@ -40,12 +40,6 @@
 #include "memmgr.h"  // __collector_allocCSize, __collector_freeCSize
 #include "tsd.h"
 
-/* TprintfT(<level>,...) definitions.  Adjust per module as needed */
-#define DBG_LT0 0 // for high-level configuration, unexpected errors/warnings
-#define DBG_LT1 1 // for configuration details, warnings
-#define DBG_LT2 2
-#define DBG_LT3 3
-
 /*
  *    This file is intended for collector's own implementation of
  *    various routines to avoid interaction with libc and other
@@ -1456,54 +1450,53 @@ __collector_util_init ()
       /* don't treat this as fatal, so that S10 could work */
     }
 
-#if ARCH(Intel) && WSIZE(32)
-  ptr = dlvsym (libc, "fopen", "GLIBC_2.1");
-  if (ptr)
-    __collector_util_funcs.fopen = (FILE * (*)())ptr;
+  if ((ptr = dlvsym (libc, "fopen", "GLIBC_2.17")) != NULL)
+    __collector_util_funcs.fopen = ptr;
+  else if ((ptr = dlvsym (libc, "fopen", "GLIBC_2.2.5")) != NULL)
+    __collector_util_funcs.fopen = ptr;
+  else if ((ptr = dlvsym (libc, "fopen", "GLIBC_2.1")) != NULL)
+    __collector_util_funcs.fopen = ptr;
+  else if ((ptr = dlvsym (libc, "fopen", "GLIBC_2.0")) != NULL)
+    __collector_util_funcs.fopen = ptr;
   else
+    ptr = dlsym (libc, "fopen");
+  if (__collector_util_funcs.fopen == NULL)
     {
-      Tprintf (DBG_LT0, "libcol_util: WARNING: dlvsym for %s@%s failed. Using dlsym() instead.", "fopen", "GLIBC_2.1");
-#endif /* ARCH(Intel) && WSIZE(32) */
-      ptr = dlsym (libc, "fopen");
-      if (ptr)
-	__collector_util_funcs.fopen = (FILE * (*)())ptr;
-      else
-	{
-	  CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT fopen: %s\n", dlerror ());
-	  err = COL_ERROR_UTIL_INIT;
-	}
-#if ARCH(Intel) && WSIZE(32)
+      CALL_UTIL (fprintf)(stderr, "COL_ERROR_UTIL_INIT fopen: %s\n", dlerror ());
+      err = COL_ERROR_UTIL_INIT;
     }
-#endif
 
-  ptr = dlsym (libc, "popen");
-  if (ptr)
-    __collector_util_funcs.popen = (FILE * (*)())ptr;
+  if ((ptr = dlvsym (libc, "popen", "GLIBC_2.17")) != NULL)
+    __collector_util_funcs.popen = ptr;
+  else if ((ptr = dlvsym (libc, "popen", "GLIBC_2.2.5")) != NULL)
+    __collector_util_funcs.popen = ptr;
+  else if ((ptr = dlvsym (libc, "popen", "GLIBC_2.1")) != NULL)
+    __collector_util_funcs.popen = ptr;
+  else if ((ptr = dlvsym (libc, "popen", "GLIBC_2.0")) != NULL)
+    __collector_util_funcs.popen = ptr;
   else
+    ptr = dlsym (libc, "popen");
+  if (__collector_util_funcs.popen == NULL)
     {
-      CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT popen: %s\n", dlerror ());
+      CALL_UTIL (fprintf)(stderr, "COL_ERROR_UTIL_INIT popen: %s\n", dlerror ());
       err = COL_ERROR_UTIL_INIT;
     }
 
-#if ARCH(Intel) && WSIZE(32)
-  ptr = dlvsym (libc, "fclose", "GLIBC_2.1");
-  if (ptr)
-    __collector_util_funcs.fclose = (int(*)())ptr;
+  if ((ptr = dlvsym (libc, "fclose", "GLIBC_2.17")) != NULL)
+    __collector_util_funcs.fclose = ptr;
+  else if ((ptr = dlvsym (libc, "fclose", "GLIBC_2.2.5")) != NULL)
+    __collector_util_funcs.fclose = ptr;
+  else if ((ptr = dlvsym (libc, "fclose", "GLIBC_2.1")) != NULL)
+    __collector_util_funcs.fclose = ptr;
+  else if ((ptr = dlvsym (libc, "fclose", "GLIBC_2.0")) != NULL)
+    __collector_util_funcs.fclose = ptr;
   else
+    ptr = dlsym (libc, "fclose");
+  if (__collector_util_funcs.fclose == NULL)
     {
-      Tprintf (DBG_LT0, "libcol_util: WARNING: dlvsym for %s@%s failed. Using dlsym() instead.", "fclose", "GLIBC_2.1");
-#endif /* ARCH(Intel) && WSIZE(32) */
-      ptr = dlsym (libc, "fclose");
-      if (ptr)
-	__collector_util_funcs.fclose = (int(*)())ptr;
-      else
-	{
-	  CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT fclose: %s\n", dlerror ());
-	  err = COL_ERROR_UTIL_INIT;
-	}
-#if ARCH(Intel) && WSIZE(32)
+      CALL_UTIL (fprintf)(stderr, "COL_ERROR_UTIL_INIT fclose: %s\n", dlerror ());
+      err = COL_ERROR_UTIL_INIT;
     }
-#endif
 
   ptr = dlsym (libc, "pclose");
   if (ptr)
diff --git a/gprofng/libcollector/libgprofng.ver b/gprofng/libcollector/libgprofng.ver
new file mode 100644
index 00000000000..dbb3212aa1e
--- /dev/null
+++ b/gprofng/libcollector/libgprofng.ver
@@ -0,0 +1,125 @@
+/* Copyright (C) 2021-2023 Free Software Foundation, Inc.
+   Contributed by Oracle.
+
+   This file is part of GNU Binutils.
+
+   This program 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, or (at your option)
+   any later version.
+
+   This program 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, write to the Free Software
+   Foundation, 51 Franklin Street - Fifth Floor, Boston,
+   MA 02110-1301, USA.  */
+
+GLIBC_2.0 {
+  global:
+    pthread_create;
+    pthread_mutex_lock;
+    pthread_mutex_unlock;
+    pthread_sigmask;
+    popen;
+};
+
+GLIBC_2.1 {
+  global:
+    pthread_create;
+    popen;
+} GLIBC_2.0;
+
+GLIBC_2.2 {
+  global:
+    open64;
+    posix_spawn;
+    posix_spawnp;
+    pread;
+    pwrite;
+    pwrite64;
+    timer_create;
+    fgetpos;
+    fsetpos;
+    fgetpos64;
+    fsetpos64;
+} GLIBC_2.1;
+
+GLIBC_2.2.5 {
+  global:
+    posix_spawn;
+    posix_spawnp;
+    pthread_mutex_lock;
+    pthread_mutex_unlock;
+    pthread_sigmask;
+    pthread_join;			
+    sem_wait;		
+    pthread_create;
+    dlopen;
+    popen;
+    timer_create;
+    pthread_cond_wait;		
+    pthread_cond_timedwait;
+    fopen;
+    fclose;
+    fdopen;
+    fgetpos;
+    fsetpos;
+} GLIBC_2.2 ;
+
+GLIBC_2.3.2 {
+  global:
+    pthread_cond_wait;		
+    pthread_cond_timedwait;
+} GLIBC_2.2.5;
+
+GLIBC_2.3.3 {
+  global:
+    timer_create;
+} GLIBC_2.3.2;
+
+GLIBC_2.15 {
+  global:
+    posix_spawn;
+    posix_spawnp;
+} GLIBC_2.3.3;
+
+GLIBC_2.17 {
+  global:
+    posix_spawn;
+    posix_spawnp;
+    pthread_mutex_lock;
+    pthread_mutex_unlock;
+    pthread_sigmask;
+    pthread_join;			
+    sem_wait;		
+    pthread_create;
+    dlopen;
+    popen;
+    timer_create;
+    pthread_cond_wait;		
+    pthread_cond_timedwait;
+    fopen;
+    fclose;
+    fdopen;
+    fgetpos;
+    fsetpos;
+} GLIBC_2.15;
+
+GLIBC_2.32 {
+  global:
+    pthread_sigmask;
+} GLIBC_2.17;
+
+GLIBC_2.34 {
+  global:
+    pthread_join;	
+    sem_wait;
+    pthread_create;
+    dlopen;
+    timer_create;
+} GLIBC_2.32;
+
diff --git a/gprofng/libcollector/linetrace.c b/gprofng/libcollector/linetrace.c
index fd8e54a7973..b29e0b93591 100644
--- a/gprofng/libcollector/linetrace.c
+++ b/gprofng/libcollector/linetrace.c
@@ -73,27 +73,15 @@ static int (*__real_grantpt) (int fd) = NULL;
 static char *(*__real_ptsname) (int fd) = NULL;
 static FILE *(*__real_popen) (const char *command, const char *type) = NULL;
 static int clone_linenum = 0;
-#if ARCH(Intel)
-#if WSIZE(32)
+static FILE *(*__real_popen_2_17) (const char *command, const char *type) = NULL;
+static FILE *(*__real_popen_2_2_5) (const char *command, const char *type) = NULL;
 static FILE *(*__real_popen_2_1) (const char *command, const char *type) = NULL;
 static FILE *(*__real_popen_2_0) (const char *command, const char *type) = NULL;
-static int (*__real_posix_spawn_2_15) (pid_t *pid, const char *path,
-			       const posix_spawn_file_actions_t *file_actions,
-			       const posix_spawnattr_t *attrp,
-			       char *const argv[], char *const envp[]) = NULL;
-static int (*__real_posix_spawn_2_2) (pid_t *pid, const char *path,
-			      const posix_spawn_file_actions_t *file_actions,
-			      const posix_spawnattr_t *attrp,
-			      char *const argv[], char *const envp[]) = NULL;
-static int (*__real_posix_spawnp_2_15) (pid_t *pid, const char *file,
-				const posix_spawn_file_actions_t *file_actions,
-				const posix_spawnattr_t *attrp,
-				char *const argv[], char *const envp[]) = NULL;
-static int (*__real_posix_spawnp_2_2) (pid_t *pid, const char *file,
+
+static int (*__real_posix_spawn_2_17) (pid_t *pid, const char *path,
 			       const posix_spawn_file_actions_t *file_actions,
 			       const posix_spawnattr_t *attrp,
 			       char *const argv[], char *const envp[]) = NULL;
-#elif WSIZE(64)
 static int (*__real_posix_spawn_2_15) (pid_t *pid, const char *path,
 			       const posix_spawn_file_actions_t *file_actions,
 			       const posix_spawnattr_t *attrp,
@@ -102,6 +90,15 @@ static int (*__real_posix_spawn_2_2_5) (pid_t *pid, const char *path,
 				const posix_spawn_file_actions_t *file_actions,
 				const posix_spawnattr_t *attrp,
 				char *const argv[], char *const envp[]) = NULL;
+static int (*__real_posix_spawn_2_2) (pid_t *pid, const char *path,
+			      const posix_spawn_file_actions_t *file_actions,
+			      const posix_spawnattr_t *attrp,
+			      char *const argv[], char *const envp[]) = NULL;
+
+static int (*__real_posix_spawnp_2_17) (pid_t *pid, const char *file,
+				const posix_spawn_file_actions_t *file_actions,
+				const posix_spawnattr_t *attrp,
+				char *const argv[], char *const envp[]) = NULL;
 static int (*__real_posix_spawnp_2_15) (pid_t *pid, const char *file,
 				const posix_spawn_file_actions_t *file_actions,
 				const posix_spawnattr_t *attrp,
@@ -110,8 +107,10 @@ static int (*__real_posix_spawnp_2_2_5) (pid_t *pid, const char *file,
 				 const posix_spawn_file_actions_t *file_actions,
 				 const posix_spawnattr_t *attrp,
 				 char *const argv[], char *const envp[]) = NULL;
-#endif /* WSIZE() */
-#endif /* ARCH(Intel) */
+static int (*__real_posix_spawnp_2_2) (pid_t *pid, const char *file,
+			       const posix_spawn_file_actions_t *file_actions,
+			       const posix_spawnattr_t *attrp,
+			       char *const argv[], char *const envp[]) = NULL;
 static int (*__real_system) (const char *command) = NULL;
 static int (*__real_posix_spawn) (pid_t *pid, const char *path,
 				const posix_spawn_file_actions_t *file_actions,
@@ -675,63 +674,87 @@ init_lineage_intf ()
     dlflag = RTLD_NEXT;
   TprintfT (DBG_LT2, "init_lineage_intf() using RTLD_%s\n",
 	    dlflag == RTLD_DEFAULT ? "DEFAULT" : "NEXT");
-  TprintfT (DBG_LT2, "init_lineage_intf() @0x%p __real_fork\n", __real_fork);
   __real_vfork = dlsym (dlflag, "vfork");
-  TprintfT (DBG_LT2, "init_lineage_intf() @0x%p __real_vfork\n", __real_vfork);
   __real_execve = dlsym (dlflag, "execve");
-  TprintfT (DBG_LT2, "init_lineage_intf() @0x%p __real_execve\n", __real_execve);
   __real_execvp = dlsym (dlflag, "execvp");
-  TprintfT (DBG_LT2, "init_lineage_intf() @0x%p __real_execvp\n", __real_execvp);
   __real_execv = dlsym (dlflag, "execv");
-  TprintfT (DBG_LT2, "init_lineage_intf() @0x%p __real_execv\n", __real_execv);
   __real_execle = dlsym (dlflag, "execle");
-  TprintfT (DBG_LT2, "init_lineage_intf() @0x%p __real_execle\n", __real_execle);
   __real_execlp = dlsym (dlflag, "execlp");
-  TprintfT (DBG_LT2, "init_lineage_intf() @0x%p __real_execlp\n", __real_execlp);
   __real_execl = dlsym (dlflag, "execl");
-  TprintfT (DBG_LT2, "init_lineage_intf() @0x%p __real_execl\n", __real_execl);
   __real_clone = dlsym (dlflag, "clone");
-  TprintfT (DBG_LT2, "init_lineage_intf() @0x%p __real_clone\n", __real_clone);
   __real_posix_spawn = dlsym (dlflag, "posix_spawn");
-  TprintfT (DBG_LT2, "init_lineage_intf() @0x%p __real_posix_spawn\n",
-	    __real_posix_spawn);
   __real_posix_spawnp = dlsym (dlflag, "posix_spawnp");
-  TprintfT (DBG_LT2, "init_lineage_intf() @0x%p __real_posix_spawnp\n",
-	    __real_posix_spawnp);
-  __real_popen = dlvsym (dlflag, "popen", SYS_POPEN_VERSION);
-  TprintfT (DBG_LT2, "init_lineage_intf()[%s] @0x%p __real_popen\n",
-	    SYS_POPEN_VERSION, __real_popen);
-#if ARCH(Intel)
-  __real_posix_spawn_2_15 = dlvsym (dlflag, "posix_spawn", SYS_POSIX_SPAWN_VERSION);
-  __real_posix_spawnp_2_15 = dlvsym (dlflag, "posix_spawnp", SYS_POSIX_SPAWN_VERSION);
-#if WSIZE(32)
-  __real_popen_2_1 = __real_popen;
+
+  __real_popen_2_17 = dlvsym (dlflag, "popen", "GLIBC_2.17");
+  __real_popen_2_2_5 = dlvsym (dlflag, "popen", "GLIBC_2.2.5");
+  __real_popen_2_1 = dlvsym (dlflag, "popen", "GLIBC_2.1");
   __real_popen_2_0 = dlvsym (dlflag, "popen", "GLIBC_2.0");
-  __real_posix_spawn_2_2 = dlvsym (dlflag, "posix_spawn", "GLIBC_2.2");
-  __real_posix_spawnp_2_2 = dlvsym (dlflag, "posix_spawnp", "GLIBC_2.2");
-#elif WSIZE(64)
+  if (__real_popen_2_17)
+    __real_popen = __real_popen_2_17;
+  else if (__real_popen_2_2_5)
+    __real_popen = __real_popen_2_2_5;
+  else if (__real_popen_2_1)
+    __real_popen = __real_popen_2_1;
+  else if (__real_popen_2_0)
+    __real_popen = __real_popen_2_0;
+  else
+    __real_popen = dlsym (dlflag, "popen");
+
+  __real_posix_spawn_2_17 = dlvsym (dlflag, "posix_spawn", "GLIBC_2.17");
+  __real_posix_spawn_2_15 = dlvsym (dlflag, "posix_spawn", "GLIBC_2.15");
   __real_posix_spawn_2_2_5 = dlvsym (dlflag, "posix_spawn", "GLIBC_2.2.5");
+  __real_posix_spawn_2_2 = dlvsym (dlflag, "posix_spawn", "GLIBC_2.2");
+
+  __real_posix_spawnp_2_17 = dlvsym (dlflag, "posix_spawnp", "GLIBC_2.17");
+  __real_posix_spawnp_2_15 = dlvsym (dlflag, "posix_spawnp", "GLIBC_2.15");
   __real_posix_spawnp_2_2_5 = dlvsym (dlflag, "posix_spawnp", "GLIBC_2.2.5");
-#endif /* WSIZE() */
-#endif /* ARCH(Intel) */
+  __real_posix_spawnp_2_2 = dlvsym (dlflag, "posix_spawnp", "GLIBC_2.2");
+
   __real_grantpt = dlsym (dlflag, "grantpt");
-  TprintfT (DBG_LT2, "init_lineage_intf() @0x%p __real_grantpt\n", __real_grantpt);
   __real_ptsname = dlsym (dlflag, "ptsname");
-  TprintfT (DBG_LT2, "init_lineage_intf() @0x%p __real_ptsname\n", __real_ptsname);
   __real_system = dlsym (dlflag, "system");
-  TprintfT (DBG_LT2, "init_lineage_intf() @0x%p __real_system\n", __real_system);
   __real_setuid = dlsym (dlflag, "setuid");
-  TprintfT (DBG_LT2, "init_lineage_intf() @0x%p __real_setuid\n", __real_setuid);
   __real_seteuid = dlsym (dlflag, "seteuid");
-  TprintfT (DBG_LT2, "init_lineage_intf() @0x%p __real_seteuid\n", __real_seteuid);
   __real_setreuid = dlsym (dlflag, "setreuid");
-  TprintfT (DBG_LT2, "init_lineage_intf() @0x%p __real_setreuid\n", __real_setreuid);
   __real_setgid = dlsym (dlflag, "setgid");
-  TprintfT (DBG_LT2, "init_lineage_intf() @0x%p __real_setgid\n", __real_setgid);
   __real_setegid = dlsym (dlflag, "setegid");
-  TprintfT (DBG_LT2, "init_lineage_intf() @0x%p __real_setegid\n", __real[...]

[diff truncated at 100000 bytes]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-03-27 18:53 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-27 18:53 [binutils-gdb] gprofng: 30089 [display text] Invalid number of threads Vladimir Mezentsev

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).