Index: src/untrusted/pll_loader/pll_loader.cc |
diff --git a/src/untrusted/pll_loader/pll_loader.cc b/src/untrusted/pll_loader/pll_loader.cc |
index 46e496aa30eb780882bf1123f2ab79739a7c1311..87dcc1d1644b42cae3ee53c66a68510f2e0f0e60 100644 |
--- a/src/untrusted/pll_loader/pll_loader.cc |
+++ b/src/untrusted/pll_loader/pll_loader.cc |
@@ -9,6 +9,7 @@ |
#include <sys/stat.h> |
#include <algorithm> |
+#include <string> |
#include "native_client/src/shared/platform/nacl_log.h" |
#include "native_client/src/untrusted/pnacl_dynloader/dynloader.h" |
@@ -92,7 +93,8 @@ void ModuleSet::SetSonameSearchPath(const std::vector<std::string> &dir_list) { |
void ModuleSet::AddBySoname(const char *soname) { |
// TODO(smklein): Deduplicate rather than failing once dependencies are added. |
if (sonames_.count(soname) != 0) { |
- NaClLog(LOG_FATAL, "PLL Loader found duplicate soname: %s\n", soname); |
+ // This module has already been added to the ModuleSet. |
Mark Seaborn
2016/03/30 23:24:57
I think your current test case doesn't actually ve
Sean Klein
2016/04/01 23:12:24
This is behavior I'm adding in this CL; I'll test
|
+ return; |
} |
sonames_.insert(soname); |
@@ -102,6 +104,7 @@ void ModuleSet::AddBySoname(const char *soname) { |
// point to the same file. |
path.append("/"); |
path.append(soname); |
+ path.append(".translated"); |
struct stat buf; |
if (stat(path.c_str(), &buf) == 0) { |
AddByFilename(path.c_str()); |
@@ -109,16 +112,26 @@ void ModuleSet::AddBySoname(const char *soname) { |
} |
} |
- NaClLog(LOG_FATAL, "PLL Loader cannot find shared object file: %s\n", soname); |
+ NaClLog(LOG_FATAL, "PLL Loader cannot find shared object: %s\n", soname); |
} |
void ModuleSet::AddByFilename(const char *filename) { |
void *pso_root; |
int err = pnacl_load_elf_file(filename, &pso_root); |
if (err != 0) { |
- NaClLog(LOG_FATAL, "pnacl_load_elf_file() failed: errno=%d\n", err); |
+ NaClLog(LOG_FATAL, |
+ "pll_loader could not open %s: errno=%d\n", filename, err); |
+ } |
+ const PLLModule module = PLLModule((const PLLRoot *) pso_root); |
+ modules_.push_back(module); |
+ const char *dependencies_list = module.GetDependenciesList(); |
+ size_t dependencies_count = module.GetDependenciesCount(); |
+ size_t string_index = 0; |
+ for (size_t i = 0; i < dependencies_count; i++) { |
+ std::string dependency_filename(dependencies_list + string_index); |
+ string_index += dependency_filename.length() + 1; |
+ AddBySoname(dependency_filename.c_str()); |
} |
- modules_.push_back(PLLModule((const PLLRoot *) pso_root)); |
} |
void *ModuleSet::GetSym(const char *name) { |