(temporal) Bug 1773 - DCE doesn't run on Fedora 19, Ubuntu 13.10 (64bits)
authorHajime Tazaki <tazaki@sfc.wide.ad.jp>
Tue, 04 Mar 2014 11:01:04 +0900
changeset 578 71461e470024
parent 577 a2261714cda1
child 579 ce6b3650adfd
(temporal) Bug 1773 - DCE doesn't run on Fedora 19, Ubuntu 13.10 (64bits) by adding -rdynamic to LDFLAGS, the issue is fixed. for the time being, DCE-ed userspace applications require an additional flag (-rdynamic) so that DCE can resolve defined symbols.
doc/source/dce-thttpd.rst
doc/source/dce-user-newapps.rst
doc/source/dce-user-test.rst
model/cooja-loader-factory.cc
model/dce-manager.cc
model/dlm-loader-factory.cc
model/libc-ns3.h
model/libc.cc
wscript
wutils.py
--- a/doc/source/dce-thttpd.rst	Fri Feb 28 11:31:46 2014 +0100
+++ b/doc/source/dce-thttpd.rst	Tue Mar 04 11:01:04 2014 +0900
@@ -20,7 +20,7 @@
 cd thttpd-2.25b
 ./configure
 patch -p1 < dce-thttpd.patch
-CFLAGS=-fPIC LDFLAGS=-pie make
+CFLAGS=-fPIC LDFLAGS="-pie -rdynamic" make
 cp thttpd $BASEDCE/build/bin_dce
 
 WGET ----------------------------------------------------------------------------------------------------
@@ -31,7 +31,7 @@
 wget http://ftp.gnu.org/gnu/wget/wget-1.14.tar.gz
 tar xf wget-1.14.tar.gz
 cd wget-1.14/
-CFLAGS=-fPIC LDFLAGS=-pie ./configure --disable-opie  --disable-digest --disable-ntlm  --disable-largefile --disable-threads --disable-nls  --disable-rpath  --disable-iri --without-ssl --without-zlib  --without-libiconv-prefix --without-libintl-prefix --without-libpth-prefix  --without-included-regex
+CFLAGS=-fPIC LDFLAGS="-pie -rdynamic" ./configure --disable-opie  --disable-digest --disable-ntlm  --disable-largefile --disable-threads --disable-nls  --disable-rpath  --disable-iri --without-ssl --without-zlib  --without-libiconv-prefix --without-libintl-prefix --without-libpth-prefix  --without-included-regex
 make
 cp src/wget $BASEDCE/build/bin_dce
 
@@ -47,4 +47,4 @@
 
 ---
 
- 
\ No newline at end of file
+ 
--- a/doc/source/dce-user-newapps.rst	Fri Feb 28 11:31:46 2014 +0100
+++ b/doc/source/dce-user-newapps.rst	Tue Mar 04 11:01:04 2014 +0900
@@ -11,7 +11,7 @@
 
  1. (option) Some application needs to be compile with **-U_FORTIFY_SOURCE** so that the application doesn't use alternative symbols including **__chk** (like memcpy_chk).
 
-2. Link your executable using this gcc flag: **-pie**  for exemple:   ``gcc -o foo -pie foo.o``
+2. Link your executable using this gcc flag: **-pie** and **-rdynamic** for exemple:   ``gcc -o foo -pie foo.o``
 3. Verify the produced executable using readelf utility in order to display the ELF file header and to verify that your exe is of type **DYN** indicating that DCE should be able to relocate and virtualize it under |ns3| virtual world and network. For exemple: ``readelf -h foo|grep Type:`` ==> ``Type: DYN (Shared object file)``
 4. Check also that your executable runs as expected outside of |ns3| and DCE.
 
--- a/doc/source/dce-user-test.rst	Fri Feb 28 11:31:46 2014 +0100
+++ b/doc/source/dce-user-test.rst	Tue Mar 04 11:01:04 2014 +0900
@@ -25,7 +25,7 @@
 ::
 
   gcc -fprofile-arcs -ftest-coverage -fPIC -c foo.c
-  gcc -fprofile-arcs -pie foo.o -o newapp
+  gcc -fprofile-arcs -pie -rdynamic foo.o -o newapp
 
 Write Test Program
 ^^^^^^^^^^^^^^^^^^
--- a/model/cooja-loader-factory.cc	Fri Feb 28 11:31:46 2014 +0100
+++ b/model/cooja-loader-factory.cc	Tue Mar 04 11:01:04 2014 +0900
@@ -374,6 +374,10 @@
 {
   NS_LOG_FUNCTION (this << module << symbol);
   void *p = dlsym (module, symbol.c_str ());
+  if (!p)
+    {
+      NS_LOG_WARN (dlerror());
+    }
   return p;
 }
 
--- a/model/dce-manager.cc	Fri Feb 28 11:31:46 2014 +0100
+++ b/model/dce-manager.cc	Tue Mar 04 11:01:04 2014 +0900
@@ -258,7 +258,7 @@
       line += exeFullPath;
       line += "'.";
       AppendStatusFile (current->process->pid, current->process->nodeId, line);
-      NS_ASSERT_MSG (!main, line.c_str ());
+      NS_ASSERT_MSG (main, line.c_str ());
     }
   else
     {
--- a/model/dlm-loader-factory.cc	Fri Feb 28 11:31:46 2014 +0100
+++ b/model/dlm-loader-factory.cc	Tue Mar 04 11:01:04 2014 +0900
@@ -106,6 +106,10 @@
 {
   NS_LOG_FUNCTION (this << module << symbol);
   void *p = dlsym (module, symbol.c_str ());
+  if (!p)
+    {
+      NS_LOG_WARN (dlerror());
+    }
   return p;
 }
 
--- a/model/libc-ns3.h	Fri Feb 28 11:31:46 2014 +0100
+++ b/model/libc-ns3.h	Tue Mar 04 11:01:04 2014 +0900
@@ -396,7 +396,7 @@
 DCE_WITH_ALIAS (pthread_once)
 DCE (pthread_getspecific)
 DCE (pthread_setspecific)
-DCE (pthread_key_create)
+DCE_WITH_ALIAS (pthread_key_create)
 DCE (pthread_key_delete)
 DCE (pthread_mutex_destroy)
 DCE (pthread_mutex_init)
--- a/model/libc.cc	Fri Feb 28 11:31:46 2014 +0100
+++ b/model/libc.cc	Tue Mar 04 11:01:04 2014 +0900
@@ -19,17 +19,19 @@
 #define NATIVE_WITH_ALIAS DCE_WITH_ALIAS
 #define NATIVE_WITH_ALIAS2 DCE_WITH_ALIAS2
 
+#define GCC_BT_NUM_ARGS 128
+
 #define GCC_BUILTIN_APPLY(export_symbol, func_to_call) \
   void export_symbol (...) { \
     void *args =  __builtin_apply_args (); \
-    void *result = __builtin_apply (g_libc.func_to_call ## _fn, args, 128); \
+    void *result = __builtin_apply (g_libc.func_to_call ## _fn, args, GCC_BT_NUM_ARGS); \
     __builtin_return (result); \
   }
 
 #define GCC_BUILTIN_APPLYT(rtype, export_symbol, func_to_call) \
   rtype export_symbol (...) { \
     void *args =  __builtin_apply_args (); \
-    void *result = __builtin_apply ((void (*) (...)) g_libc.func_to_call ## _fn, args, 128); \
+    void *result = __builtin_apply ((void (*) (...)) g_libc.func_to_call ## _fn, args, GCC_BT_NUM_ARGS); \
     __builtin_return (result); \
   }
 
--- a/wscript	Fri Feb 28 11:31:46 2014 +0100
+++ b/wscript	Tue Mar 04 11:01:04 2014 +0900
@@ -217,7 +217,7 @@
     debug_dl = []
     d['cxxflags'] = d.get('cxxflags', []) + ['-fpie'] + mcmodel + nofortify
     d['cflags'] = d.get('cflags', []) + ['-fpie'] + mcmodel + nofortify
-    d['linkflags'] = d.get('linkflags', []) + ['-pie'] + ['-lrt'] + debug_dl
+    d['linkflags'] = d.get('linkflags', []) + ['-pie'] + ['-lrt'] + ['-rdynamic'] + debug_dl
     return d
 
 def build_dce_tests(module, bld):
--- a/wutils.py	Fri Feb 28 11:31:46 2014 +0100
+++ b/wutils.py	Tue Mar 04 11:01:04 2014 +0900
@@ -120,9 +120,9 @@
     else:
         pymoddir = ""
     import glob
-    pyns3dir = glob.glob(bld.env.NS3_DIR + '/lib/python*/site-packages')
+    pyns3dir = glob.glob(bld.env.NS3_DIR + '/lib*/python*/site-packages')
     if len(pyns3dir) is not 0:
-        pyvizdir = pyns3dir[0]
+        pyvizdir = pyns3dir[1]
     else:
         pyvizdir = ''
     if 'PYTHONPATH' in proc_env: