Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(472)

Unified Diff: src/untrusted/pll_loader/pll_loader.cc

Issue 1832623002: PNaCl Dynamic Linking: Using unordered_set to disallow duplicate modules. (Closed) Base URL: https://chromium.googlesource.com/native_client/src/native_client.git@master
Patch Set: Code review Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/untrusted/pll_loader/pll_loader.h ('k') | tests/pnacl_dynamic_loading/nacl.scons » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..46e496aa30eb780882bf1123f2ab79739a7c1311 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::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.
+ 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.
+ for (auto path : search_path_) {
+ // Appending "/" might be unnecessary, but "foo/bar" and "foo//bar" should
+ // point to the same file.
+ path.append("/");
+ path.append(soname);
+ struct stat buf;
+ 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);
« no previous file with comments | « src/untrusted/pll_loader/pll_loader.h ('k') | tests/pnacl_dynamic_loading/nacl.scons » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698