# HG changeset patch # User Hajime Tazaki # Date 1433136267 -32400 # Node ID cb779a3844be40491701ecbebfcd2a90461c088a # Parent 06b23f4d262cb854ab13c23f43d1d616cfb17248 Bug 2101 - When loading binary not compiled with the correct options, dce crashes diff -r 06b23f4d262c -r cb779a3844be RELEASE_NOTES --- a/RELEASE_NOTES Sun May 31 21:50:17 2015 +0900 +++ b/RELEASE_NOTES Mon Jun 01 14:24:27 2015 +0900 @@ -30,6 +30,7 @@ - Bug 2085 - DCE build process crashes when using compiler flag for C++0x / C++11 - Bug 1980 - setting UnixSocketFd socket buffer size - Bug 2129 - DCE-Linux simulations with heterogeneous nodes crash (some DCE-Linux and some ns3) +- Bug 2101 - When loading binary not compiled with the correct options, dce crashes Release dce-1.6 diff -r 06b23f4d262c -r cb779a3844be model/dlm-loader-factory.cc --- a/model/dlm-loader-factory.cc Sun May 31 21:50:17 2015 +0900 +++ b/model/dlm-loader-factory.cc Mon Jun 01 14:24:27 2015 +0900 @@ -91,6 +91,13 @@ { NS_LOG_FUNCTION (this << filename << flag); void *module = dlmopen (m_lmid, filename.c_str (), flag); + if (!module) + { + NS_LOG_UNCOND ("*** unable to open non-shared object file=" << filename << " ***"); + NS_LOG_UNCOND ("dlerror() = " << dlerror ()); + NS_ASSERT_MSG (false, "make it sure that DCE binrary file " << filename + << " was built with correct options: (CFLAGS=-fPIC, LDFLAGS=-pie -rdynamic)"); + } m_loaded.push_back (module); return module; } diff -r 06b23f4d262c -r cb779a3844be model/elf-cache.cc --- a/model/elf-cache.cc Sun May 31 21:50:17 2015 +0900 +++ b/model/elf-cache.cc Mon Jun 01 14:24:27 2015 +0900 @@ -163,6 +163,13 @@ // find DYNAMIC and fill DataSection struct FileInfo fileInfo; + + if (header->e_type != ET_DYN) + { + fileInfo.p_vaddr = -1; + return fileInfo; + } + ElfW (Phdr) * pt_load_rw = 0; ElfW (Phdr) * pt_gnu_relro = 0; for (uint32_t i = 0; i < header->e_phnum; i++, phdr++) @@ -257,6 +264,12 @@ close (fd); struct FileInfo fileInfo = EditBuffer (buffer, selfId); + if (fileInfo.p_vaddr == -1) + { + NS_LOG_UNCOND ("*** unable to open non-shared object file=" << filename << " ***"); + NS_ASSERT_MSG (false, "make it sure that DCE binrary file " << filename + << " was built with correct options: (CFLAGS=-fPIC, LDFLAGS=-pie -rdynamic)"); + } // write back changes to hard disk retval = ::msync (buffer, size, MS_SYNC);