Chromium Code Reviews| 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..577ca0b2d14c718735ad388980267b0ee797b0ca 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" |
| @@ -89,10 +90,10 @@ void ModuleSet::SetSonameSearchPath(const std::vector<std::string> &dir_list) { |
| search_path_ = dir_list; |
| } |
| -void ModuleSet::AddBySoname(const char *soname) { |
| - // TODO(smklein): Deduplicate rather than failing once dependencies are added. |
| +void *ModuleSet::AddBySoname(const char *soname) { |
| 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. |
| + return NULL; |
| } |
| sonames_.insert(soname); |
| @@ -102,23 +103,35 @@ 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()); |
| - return; |
| + return AddByFilename(path.c_str()); |
| } |
| } |
| - 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); |
| + return NULL; |
| } |
| -void ModuleSet::AddByFilename(const char *filename) { |
| +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((const PLLRoot *) pso_root); |
|
Mark Seaborn
2016/04/01 23:42:19
See other comment: you don't really need the first
Sean Klein
2016/04/02 00:50:33
Done.
|
| + modules_.push_back(module); |
| + const char *dependencies_list = module.root()->dependencies_list; |
| + size_t dependencies_count = module.root()->dependencies_count; |
| + size_t string_offset = 0; |
| + for (size_t i = 0; i < dependencies_count; i++) { |
| + std::string dependency_filename(dependencies_list + string_offset); |
| + string_offset += dependency_filename.length() + 1; |
| + AddBySoname(dependency_filename.c_str()); |
| } |
| - modules_.push_back(PLLModule((const PLLRoot *) pso_root)); |
| + return pso_root; |
| } |
| void *ModuleSet::GetSym(const char *name) { |