Date: Monday, April 16, 2007 @ 14:37:09
  Author: marc
    Path: /cvsroot/carob/libmysequoia/ldtest

Modified: Makefile (1.4 -> 1.5) main.cpp (1.6 -> 1.7) runtest.sh (1.2 ->
          1.3)

Major re-org.


------------+
 Makefile   |    7 +------
 main.cpp   |   39 ++++++++++++++++-----------------------
 runtest.sh |   15 ++++++++++++---
 3 files changed, 29 insertions(+), 32 deletions(-)


Index: libmysequoia/ldtest/Makefile
diff -u libmysequoia/ldtest/Makefile:1.4 libmysequoia/ldtest/Makefile:1.5
--- libmysequoia/ldtest/Makefile:1.4    Fri Apr 13 20:44:54 2007
+++ libmysequoia/ldtest/Makefile        Mon Apr 16 14:37:08 2007
@@ -6,7 +6,7 @@
 SOLIBS=liborig.so liboverride.so
 ALL=${SOLIBS} plugin.so main
 
-all: ${ALL} run
+all: ${ALL}
 
 liborig.so: orig.c
        ${CC} ${DOLIB} $? -o $@
@@ -22,10 +22,5 @@
 main: main.cpp
        ${CXX} ${MAINFLAGS} $? -o $@
 
-
-run:
-       LD_LIBRARY_PATH=. ./main
-       LD_LIBRARY_PATH=. LD_PRELOAD=./liboverride.so ./main
-
 clean:
        rm -f ${ALL}
Index: libmysequoia/ldtest/main.cpp
diff -u libmysequoia/ldtest/main.cpp:1.6 libmysequoia/ldtest/main.cpp:1.7
--- libmysequoia/ldtest/main.cpp:1.6    Fri Apr 13 20:23:19 2007
+++ libmysequoia/ldtest/main.cpp        Mon Apr 16 14:37:09 2007
@@ -34,20 +34,22 @@
 // http://sourceware.org/ml/libc-hacker/2004-09/msg00083.html
 
 
-#ifdef NOGLOBAL
-#warning now nullifying RTLD_GLOBAL
-#define RTLD_GLOGAL 0
-#endif
-
 int
-test(int flags)
+test(bool global, bool deepbind = false)
 {
 
+  int flags =
+#ifdef RTLD_DEEPBIND
+    (deepbind ? RTLD_DEEPBIND : 0) |
+#endif
+    RTLD_NOW |
+    (global? RTLD_GLOBAL : RTLD_LOCAL);
+
   void *plugin = dlopen("./plugin.so", flags);
 
   if (!plugin) {
     std::cerr << "failed to open plugin: " << dlerror() << std::endl;
-    return 1;
+    exit (1);
   }
 
   char * (*plugin_function)() = ( char* (*)() ) dlsym(plugin, 
"plugin_function");
@@ -55,17 +57,13 @@
   const char *error = dlerror();
   if (error) {
     std::cerr << "failed to find plugin function: " << error << std::endl;
-    return 2;
+    exit(2);
   }
 
-  std::cout << "RTLD_DEEPBIND=" << (flags
 #ifdef RTLD_DEEPBIND
-    & RTLD_DEEPBIND)
-#else
-    & 0)
+  std::cout << "RTLD_DEEPBIND=" << deepbind << ", " ;
 #endif
-    ;
-  std::cout << ", RTLD_GLOBAL=" << (flags & RTLD_GLOBAL);
+  std::cout << "RTLD_GLOBAL=" << global ;
 
   std::cout << "   --->        " << (*plugin_function) () << std::endl;
 
@@ -78,17 +76,12 @@
 int
 main()
 {
-  if (test(RTLD_NOW | RTLD_GLOBAL))
-    return 1;
-  if (test(RTLD_NOW) | RTLD_LOCAL)
-    return 1;
+  test(false);
+  test(true);
 
 #ifdef RTLD_DEEPBIND
-  if (test(RTLD_NOW | RTLD_LOCAL | RTLD_DEEPBIND))
-    return 1;
-
-  if (test(RTLD_NOW | RTLD_GLOBAL | RTLD_DEEPBIND))
-    return 1;
+  test(false, true);
+  test(true, true);
 #endif
 
 }
Index: libmysequoia/ldtest/runtest.sh
diff -u libmysequoia/ldtest/runtest.sh:1.2 libmysequoia/ldtest/runtest.sh:1.3
--- libmysequoia/ldtest/runtest.sh:1.2  Fri Apr 13 20:44:54 2007
+++ libmysequoia/ldtest/runtest.sh      Mon Apr 16 14:37:09 2007
@@ -4,13 +4,22 @@
 
 case `uname -s`
  in Linux)
-    SYSFLAGS="-ldl"
+    mainlinkflags="-ldl"
   ;;
 esac
 
 
-for linkflags in " " "-lorig"
-do make clean all MAINFLAGS="${SYSFLAGS}" OVERLIBFLAGS="$linkflags"
+
+for overridelinkflags in "     " "-lorig"; do
+for preload in "" "./liboverride.so"; do
+
+    1>/dev/null make clean all MAINFLAGS="${mainlinkflags}" \
+    OVERLIBFLAGS="${overridelinkflags}"
+
+    printf "\n $overridelinkflags -o liboverride.so       
LD_PRELOAD=$preload\n"
+    LD_LIBRARY_PATH=. LD_PRELOAD=${preload} ./main
+
+done
 done
 
 

_______________________________________________
Carob-commits mailing list
[email protected]
https://forge.continuent.org/mailman/listinfo/carob-commits

Reply via email to