Re: [DynInst_API:] [PATCH] dyninstAPI_RT: export more symbols to be found by dyninstAPI


Date: Wed, 21 May 2014 14:20:22 -0500
From: Bill Williams <bill@xxxxxxxxxxx>
Subject: Re: [DynInst_API:] [PATCH] dyninstAPI_RT: export more symbols to be found by dyninstAPI
A virtuous patch, though I admit some confusion: I believe that the trap table variables should already be exported on the v8.2 branch...

On 05/21/2014 02:16 PM, Josh Stone wrote:
With -fvisibility=hidden and rpm stripping, some of the symbols in
dyninstAPI_RT can't be found.  This patch adds DLLEXPORT to every name
in the unstripped symbol table which is referenced by string "name" in
libdyninstAPI.so, hopefully allowing all necessary dynamic lookups.
---
  dyninstAPI_RT/h/dyninstAPI_RT.h   |  2 +-
  dyninstAPI_RT/h/dyninstRTExport.h |  1 +
  dyninstAPI_RT/src/RTcommon.c      | 40 +++++++++++++++++++--------------------
  dyninstAPI_RT/src/RTthread.h      |  2 +-
  4 files changed, 23 insertions(+), 22 deletions(-)

diff --git a/dyninstAPI_RT/h/dyninstAPI_RT.h b/dyninstAPI_RT/h/dyninstAPI_RT.h
index be3e0ba902c1..efa0a2404088 100644
--- a/dyninstAPI_RT/h/dyninstAPI_RT.h
+++ b/dyninstAPI_RT/h/dyninstAPI_RT.h
@@ -233,7 +233,7 @@ struct MemoryMapper64 {
     MemoryMapperElement64 elements[MAX_MEMORY_MAPPER_ELEMENTS];
  };

-extern struct MemoryMapper RTmemoryMapper;
+DLLEXPORT extern struct MemoryMapper RTmemoryMapper;

  extern int RTuntranslatedEntryCounter;

diff --git a/dyninstAPI_RT/h/dyninstRTExport.h b/dyninstAPI_RT/h/dyninstRTExport.h
index d070b6670807..26f97ab4c7b3 100644
--- a/dyninstAPI_RT/h/dyninstRTExport.h
+++ b/dyninstAPI_RT/h/dyninstRTExport.h
@@ -103,6 +103,7 @@ DLLEXPORT unsigned dyninst_threadIndex();
   * Internal functions that we export to ensure they show up.
   **/

+DLLEXPORT void DYNINSTsafeBreakPoint();
  DLLEXPORT void DYNINSTinit();
  DLLEXPORT void DYNINST_snippetBreakpoint();
  DLLEXPORT void DYNINST_stopThread(void *, void *, void *, void *);
diff --git a/dyninstAPI_RT/src/RTcommon.c b/dyninstAPI_RT/src/RTcommon.c
index ddf2bf6b9915..9167321de781 100644
--- a/dyninstAPI_RT/src/RTcommon.c
+++ b/dyninstAPI_RT/src/RTcommon.c
@@ -85,15 +85,15 @@ const unsigned long sizeOfAnyHeap1 = sizeof( DYNINSTstaticHeap_32K_anyHeap_1 );
   * system-provided events. On others we do it ourselves.  Enumerated type
   * defined in header file
   **/
-DYNINST_synch_event_t DYNINST_synch_event_id = DSE_undefined;
-void *DYNINST_synch_event_arg1;
+DLLEXPORT DYNINST_synch_event_t DYNINST_synch_event_id = DSE_undefined;
+DLLEXPORT void *DYNINST_synch_event_arg1;
  /* Code to read args 2,3 would have to be moved from dyninstAPI's*/
  /* process::handleStopThread to signalgenerator::decodeRTSignal in*/
  /* order for other signals to make use of them, as currently only the*/
  /* stopThread event needs makes use of them.  */
-void *DYNINST_synch_event_arg2 = NULL; /* not read in dyninst's decodeRTSignal*/
-void *DYNINST_synch_event_arg3 = NULL; /* not read in dyninst's decodeRTSignal*/
-int DYNINST_break_point_event = 0;
+DLLEXPORT void *DYNINST_synch_event_arg2 = NULL; /* not read in dyninst's decodeRTSignal*/
+DLLEXPORT void *DYNINST_synch_event_arg3 = NULL; /* not read in dyninst's decodeRTSignal*/
+DLLEXPORT int DYNINST_break_point_event = 0;

  /**
   * These variables are used to pass arguments into DYNINSTinit
@@ -110,7 +110,7 @@ int isMutatedExec = 0;

  // stopThread cache variables
  char cacheLRUflags[TARGET_CACHE_WIDTH];
-void *DYNINST_target_cache[TARGET_CACHE_WIDTH][TARGET_CACHE_WAYS];
+DLLEXPORT void *DYNINST_target_cache[TARGET_CACHE_WIDTH][TARGET_CACHE_WAYS];
  FILE *stOut;
  int fakeTickCount;

@@ -247,7 +247,7 @@ void DYNINST_snippetBreakpoint() {
  }

  /* Used to instrument (and report) the entry of fork */
-void DYNINST_instForkEntry() {
+DLLEXPORT void DYNINST_instForkEntry() {
     tc_lock_lock(&DYNINST_trace_lock);

     /* Set the state so the mutator knows what's up */
@@ -267,7 +267,7 @@ void DYNINST_instForkEntry() {
  /* We use the safe breakpoint on the child side of fork
     as we may not be attached at that point. The parent
     side uses the normal version. */
-void DYNINST_instForkExit(void *arg1) {
+DLLEXPORT void DYNINST_instForkExit(void *arg1) {
     tc_lock_lock(&DYNINST_trace_lock);

     /* Set the state so the mutator knows what's up */
@@ -290,7 +290,7 @@ void DYNINST_instForkExit(void *arg1) {


  /* Used to instrument (and report) the entry of exec */
-void DYNINST_instExecEntry(void *arg1) {
+DLLEXPORT void DYNINST_instExecEntry(void *arg1) {
     tc_lock_lock(&DYNINST_trace_lock);

     /* Set the state so the mutator knows what's up */
@@ -311,7 +311,7 @@ void DYNINST_instExecEntry(void *arg1) {


  /* Used to instrument (and report) the exit of exec */
-void DYNINST_instExecExit(void *arg1) {
+DLLEXPORT void DYNINST_instExecExit(void *arg1) {
     tc_lock_lock(&DYNINST_trace_lock);

     /* Set the state so the mutator knows what's up */
@@ -328,7 +328,7 @@ void DYNINST_instExecExit(void *arg1) {


  /* Used to instrument (and report) the entry of exit */
-void DYNINST_instExitEntry(void *arg1) {
+DLLEXPORT void DYNINST_instExitEntry(void *arg1) {
     tc_lock_lock(&DYNINST_trace_lock);

     /* Set the state so the mutator knows what's up */
@@ -344,7 +344,7 @@ void DYNINST_instExitEntry(void *arg1) {
  }

  /* Used to instrument (and report) the entry of exit */
-void DYNINST_instLoadLibrary(void *arg1) {
+DLLEXPORT void DYNINST_instLoadLibrary(void *arg1) {
     tc_lock_lock(&DYNINST_trace_lock);

     /* Set the state so the mutator knows what's up */
@@ -360,7 +360,7 @@ void DYNINST_instLoadLibrary(void *arg1) {
  }

  /* Used to instrument (and report) the entry of exit */
-void DYNINST_instLwpExit(void) {
+DLLEXPORT void DYNINST_instLwpExit(void) {
     tc_lock_lock(&DYNINST_trace_lock);

     /* Set the state so the mutator knows what's up */
@@ -516,8 +516,8 @@ void DYNINST_stopInterProc(void * pointAddr, void *callBackID,
  }

  // boundsArray is a sequence of (blockStart,blockEnd) pairs
-RT_Boolean DYNINST_boundsCheck(void **boundsArray_, void *arrayLen_,
-                               void *writeTarget_)
+DLLEXPORT RT_Boolean DYNINST_boundsCheck(void **boundsArray_, void *arrayLen_,
+                                         void *writeTarget_)
  {
      RT_Boolean callStopThread = RT_FALSE;
      const unsigned long writeTarget = (unsigned long)writeTarget_;
@@ -562,7 +562,7 @@ RT_Boolean DYNINST_boundsCheck(void **boundsArray_, void *arrayLen_,
  /**
   * Used to report addresses of functions called at dynamic call sites
   **/
-int DYNINSTasyncDynFuncCall (void * call_target, void *call_addr) {
+DLLEXPORT int DYNINSTasyncDynFuncCall (void * call_target, void *call_addr) {
      if (DYNINSTstaticMode) return 0;

      tc_lock_lock(&DYNINST_trace_lock);
@@ -697,10 +697,10 @@ char *asyncEventType2str(rtBPatch_asyncEventType t)
    }
  }

-volatile unsigned long dyninstTrapTableUsed;
-volatile unsigned long dyninstTrapTableVersion;
-volatile trapMapping_t *dyninstTrapTable;
-volatile unsigned long dyninstTrapTableIsSorted;
+DLLEXPORT volatile unsigned long dyninstTrapTableUsed;
+DLLEXPORT volatile unsigned long dyninstTrapTableVersion;
+DLLEXPORT volatile trapMapping_t *dyninstTrapTable;
+DLLEXPORT volatile unsigned long dyninstTrapTableIsSorted;

  void* dyninstTrapTranslate(void *source,
                             volatile unsigned long *table_used,
diff --git a/dyninstAPI_RT/src/RTthread.h b/dyninstAPI_RT/src/RTthread.h
index a3904326f07d..5d0380fe6d28 100644
--- a/dyninstAPI_RT/src/RTthread.h
+++ b/dyninstAPI_RT/src/RTthread.h
@@ -34,7 +34,7 @@
  #include "dyninstAPI_RT/h/dyninstAPI_RT.h"
  #include "dyninstAPI_RT/h/dyninstRTExport.h"

-dyntid_t dyn_pthread_self();    /*Thread library identifier*/
+DLLEXPORT dyntid_t dyn_pthread_self();    /*Thread library identifier*/
  int dyn_lwp_self();        /*LWP used by the kernel identifier*/
  int dyn_pid_self();        /*PID identifier representing the containing process*/




--
--bw

Bill Williams
Paradyn Project
bill@xxxxxxxxxxx
[← Prev in Thread] Current Thread [Next in Thread→]