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 aa7724e0c02ae42149d6f13dbdb39152ac9a2116..4c47665817c49043baffb9202af4f0e2c711dead 100644 |
| --- a/src/untrusted/pll_loader/pll_loader.cc |
| +++ b/src/untrusted/pll_loader/pll_loader.cc |
| @@ -6,6 +6,7 @@ |
| #include <stdlib.h> |
| #include <string.h> |
| +#include <sys/stat.h> |
| #include <algorithm> |
| @@ -84,6 +85,33 @@ void *PLLModule::InstantiateTLSBlock() { |
| return base; |
| } |
| +void ModuleSet::SetSonameSearchPaths(const std::vector<std::string> &dir_list) { |
| + search_paths_ = 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); |
| + } |
| + sonames_.insert(soname); |
| + |
| + // Actually load the module implied by the soname. |
| + struct stat buf; |
|
Mark Seaborn
2016/03/26 00:30:10
Nit: putting this immediately before the stat() ca
Sean Klein
2016/03/26 00:47:25
Done.
|
| + for (auto path : search_paths_) { |
| + // Appending "/" might be unnecessary, but "foo/bar" and "foo//bar" should |
| + // point to the same file. |
| + path.append("/"); |
| + path.append(soname); |
| + if (stat(path.c_str(), &buf) == 0) { |
| + AddByFilename(path.c_str()); |
| + return; |
| + } |
| + } |
| + |
| + NaClLog(LOG_FATAL, "PLL Loader cannot find shared object file: %s\n", soname); |
| +} |
| + |
| void ModuleSet::AddByFilename(const char *filename) { |
| void *pso_root; |
| int err = pnacl_load_elf_file(filename, &pso_root); |