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

Side by Side Diff: src/untrusted/pll_loader/pll_loader.h

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: Added AddBySoname/SetSonameSearchPaths, tested in pll_loader_test 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Native Client Authors. All rights reserved. 1 // Copyright 2016 The Native Client Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef NATIVE_CLIENT_SRC_UNTRUSTED_PLL_LOADER_PLL_LOADER_H_ 5 #ifndef NATIVE_CLIENT_SRC_UNTRUSTED_PLL_LOADER_PLL_LOADER_H_
6 #define NATIVE_CLIENT_SRC_UNTRUSTED_PLL_LOADER_PLL_LOADER_H_ 1 6 #define NATIVE_CLIENT_SRC_UNTRUSTED_PLL_LOADER_PLL_LOADER_H_ 1
7 7
8 #include <string>
9 #include <unordered_set>
8 #include <vector> 10 #include <vector>
9 11
10 #include "native_client/src/untrusted/pll_loader/pll_root.h" 12 #include "native_client/src/untrusted/pll_loader/pll_root.h"
11 13
12 // This helper class wraps the PLLRoot data structure and provides methods 14 // This helper class wraps the PLLRoot data structure and provides methods
13 // for accessing parts of PLLRoot. 15 // for accessing parts of PLLRoot.
14 class PLLModule { 16 class PLLModule {
15 public: 17 public:
16 explicit PLLModule(const PLLRoot *root) : root_(root) {} 18 explicit PLLModule(const PLLRoot *root) : root_(root) {}
17 19
(...skipping 17 matching lines...) Expand all
35 void *GetExportedSym(const char *name); 37 void *GetExportedSym(const char *name);
36 void *InstantiateTLSBlock(); 38 void *InstantiateTLSBlock();
37 39
38 private: 40 private:
39 const PLLRoot *root_; 41 const PLLRoot *root_;
40 }; 42 };
41 43
42 // ModuleSet represents a set of loaded PLLs. 44 // ModuleSet represents a set of loaded PLLs.
43 class ModuleSet { 45 class ModuleSet {
44 public: 46 public:
45 // Load a PLL and add it to the set. 47 // Load a PLL by filename. Does not add the filename to a known set of loaded
48 // modules.
49 // TODO(smklein): At the moment, "AddByFilename" has no mechanism to
Mark Seaborn 2016/03/26 00:30:10 As I have been saying, I think this current behavi
Sean Klein 2016/03/26 00:47:25 Okay, I understand now! I was under the impression
50 // de-duplicate libraries. If "libfoo.so" is passed multiple times, it will be
51 // loaded multiple times. Proper de-duplication should be added.
46 void AddByFilename(const char *filename); 52 void AddByFilename(const char *filename);
47 53
54 // Change the search paths used by the linker when looking for PLLs by soname.
Mark Seaborn 2016/03/26 00:30:11 Terminology nit: A "search path" normally refers t
Sean Klein 2016/03/26 00:47:25 Done.
55 void SetSonameSearchPaths(const std::vector<std::string> &dir_list);
56
57 // Load a PLL by soname and add the soname to the set of loaded modules.
58 void AddBySoname(const char *soname);
59
48 // Looks up a symbol in the set of modules. This does a linear search of 60 // Looks up a symbol in the set of modules. This does a linear search of
49 // the modules, in the order that they were added using AddByFilename(). 61 // the modules, in the order that they were added using AddByFilename().
50 void *GetSym(const char *name); 62 void *GetSym(const char *name);
51 63
52 // Applies relocations to the modules, resolving references between them. 64 // Applies relocations to the modules, resolving references between them.
53 void ResolveRefs(); 65 void ResolveRefs();
54 66
55 private: 67 private:
68 // The search paths used to look for "sonames".
69 std::vector<std::string> search_paths_;
70 // An unordered set of "sonames" (to see if a module has been loaded) and the
Mark Seaborn 2016/03/26 00:30:10 Nit: remove "and the modules themselves"
Sean Klein 2016/03/26 00:47:25 Done.
71 // modules themselves.
72 std::unordered_set<std::string> sonames_;
56 std::vector<PLLModule> modules_; 73 std::vector<PLLModule> modules_;
57 }; 74 };
58 75
59 #endif 76 #endif
OLDNEW
« no previous file with comments | « no previous file | src/untrusted/pll_loader/pll_loader.cc » ('j') | src/untrusted/pll_loader/pll_loader.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698