Use so_names to prevent loading wrong abi (#56)
authorMatthieu Coudron <matthieu.coudron@upmc.fr>
Wed, 09 Nov 2016 16:11:47 +0100
changeset 767 91b95d65af36
parent 766 42bb38801bb1
child 768 02fcf1ead7f1
child 771 4ab31ef25d4a
Use so_names to prevent loading wrong abi (#56) As stated in https://bugzilla.redhat.com/show_bug.cgi?id=1361037, "This is an application defect. If you're using a path it's expected you know what you're loading. One _should_ be using '#include <gnu/lib-names.h>' to get LIBC_SO and then dlopen that, it's the only supported solution, particularly consider distributions that might have /usr/lib64, or multi-arched lib dirs. You could be loading libc.so.6 from an incompatible ABI. Loding by SONAME is the only safe option."
model/elf-cache.cc
--- a/model/elf-cache.cc	Wed Nov 09 14:59:26 2016 +0100
+++ b/model/elf-cache.cc	Wed Nov 09 16:11:47 2016 +0100
@@ -10,6 +10,7 @@
 #include <sstream>
 #include <string.h>
 #include <sys/mman.h>
+#include <gnu/lib-names.h>
 
 namespace ns3 {
 
@@ -20,19 +21,19 @@
     m_uid (uid)
 {
   struct Overriden overriden;
-  overriden.from = "libc.so.6";
+  overriden.from = LIBC_SO;
   overriden.to = "libc-ns3.so";
   m_overriden.push_back (overriden);
-  overriden.from = "libpthread.so.0";
+  overriden.from = LIBPTHREAD_SO;
   overriden.to = "libpthread-ns3.so";
   m_overriden.push_back (overriden);
-  overriden.from = "librt.so.1";
+  overriden.from = LIBRT_SO;
   overriden.to = "librt-ns3.so";
   m_overriden.push_back (overriden);
-  overriden.from = "libm.so.6";
+  overriden.from = LIBM_SO;
   overriden.to = "libm-ns3.so";
   m_overriden.push_back (overriden);
-  overriden.from = "libdl.so.2";
+  overriden.from = LIBDL_SO;
   overriden.to = "libdl-ns3.so";
   m_overriden.push_back (overriden);
 }