[Darshan-commits] [Git][darshan/darshan][carns/dev-wrapper-map-alias] use alias attribute rather than redirect macro

Philip Carns xgitlab at cels.anl.gov
Wed Mar 18 12:58:06 CDT 2020



Philip Carns pushed to branch carns/dev-wrapper-map-alias at darshan / darshan


Commits:
28797bf6 by Phil Carns at 2020-03-18T13:57:38-04:00
use alias attribute rather than redirect macro

- redirect macro didn't preserve original symbol name as expected

- - - - -


1 changed file:

- darshan-runtime/darshan.h


Changes:

=====================================
darshan-runtime/darshan.h
=====================================
@@ -34,16 +34,12 @@
 /* creates P* variant of MPI symbols for LD_PRELOAD so that we can handle
  * language bindings that map to MPI or PMPI symbols under the covers.
  *
- * See the following for an explanation of glibc __REDIRECT macro that's being
- * used here.  It creates an alias that points to the same function
- * definition.  If we generated a wrapper to call the alias, then we risk
- * accidentally invoking the wrong symbol if multiple libraries are
- * attempting to intercept the same function.
- *
- * https://sourceware.org/git/?p=glibc.git;a=blob;f=misc/sys/cdefs.h;h=dd5f69f83385153899b7d8308f5732903d0a5999;hb=HEAD#l162
- */
+ * We use an alias attribute rather than generating a function shim in order
+ * to prevent accidental function call loop if there a conventional PMPI
+ * profiler is attempting to intercept the same function name.
+  */
 #define DARSHAN_WRAPPER_MAP(__func,__ret,__args,__fcall) \
-    __ret __REDIRECT(__fcall, __args, __func);
+    __ret __func __args __attribute__ ((alias (#__fcall)));
 
 /* Map the desired function call to a pointer called __real_NAME at run
  * time.  Note that we fall back to looking for the same symbol with a P
@@ -69,16 +65,12 @@
 /* creates P* variant of MPI symbols for static linking so that we can handle
  * language bindings that map to MPI or PMPI symbols under the covers.
  *
- * See the following for an explanation of glibc __REDIRECT macro that's being
- * used here.  It creates an alias that points to the same function
- * definition.  If we generated a wrapper to call the alias, then we risk
- * accidentally invoking the wrong symbol if multiple libraries are
- * attempting to intercept the same function.
- *
- * https://sourceware.org/git/?p=glibc.git;a=blob;f=misc/sys/cdefs.h;h=dd5f69f83385153899b7d8308f5732903d0a5999;hb=HEAD#l162
+ * We use an alias attribute rather than generating a function shim in order
+ * to prevent accidental function call loop if there a conventional PMPI
+ * profiler is attempting to intercept the same function name.
  */
 #define DARSHAN_WRAPPER_MAP(__func,__ret,__args,__fcall) \
-    __ret __REDIRECT(__fcall, __args, __func);
+    __ret __func __args __attribute__ ((alias ("__wrap_" #__fcall)));
 
 #define MAP_OR_FAIL(__func)
 



View it on GitLab: https://xgitlab.cels.anl.gov/darshan/darshan/commit/28797bf615aab8e18604e468429c4a9f6d8424fa

-- 
View it on GitLab: https://xgitlab.cels.anl.gov/darshan/darshan/commit/28797bf615aab8e18604e468429c4a9f6d8424fa
You're receiving this email because of your account on xgitlab.cels.anl.gov.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/darshan-commits/attachments/20200318/eea27eea/attachment-0001.html>


More information about the Darshan-commits mailing list