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

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: Using unordered_set, preserving vector. 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') | no next file » | 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..c447b9ae525497cfcc247ec900faa1e24804aa03 100644
--- a/src/untrusted/pll_loader/pll_loader.cc
+++ b/src/untrusted/pll_loader/pll_loader.cc
@@ -21,6 +21,18 @@ void *TLSBlockGetter(PLLTLSBlockGetter *closure) {
return closure->arg;
}
+// Given a pathname, return the filename it points to (or NULL if the path
+// ends with '/').
+const char *GetSoname(const char *path) {
Mark Seaborn 2016/03/25 17:57:28 I'm not sure it makes sense to add this because we
Sean Klein 2016/03/25 18:43:57 Yeah, it felt like a temporary solution anyway (I
+ const char *base = path;
+ while (*path) {
+ if (*path == '/')
+ base = path + 1;
+ path++;
+ }
+ return base;
+}
+
} // namespace
uint32_t PLLModule::HashString(const char *sp) {
@@ -85,6 +97,15 @@ void *PLLModule::InstantiateTLSBlock() {
}
void ModuleSet::AddByFilename(const char *filename) {
+ std::string soname(GetSoname(filename));
+ if (soname.empty()) {
+ NaClLog(LOG_FATAL, "Invalid PLL Path: %s\n", filename);
+ }
+ if (sonames_.count(soname) != 0) {
+ NaClLog(LOG_FATAL, "PLL Loader found duplicate PLL: %s\n", filename);
+ }
+ sonames_.insert(soname);
+
void *pso_root;
int err = pnacl_load_elf_file(filename, &pso_root);
if (err != 0) {
« no previous file with comments | « src/untrusted/pll_loader/pll_loader.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698