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

Side by Side Diff: src/untrusted/pll_loader/pll_loader_main.cc

Issue 1825893002: PNaCl Dynamic Linking: Added portable dependencies to shared objects. (Closed) Base URL: https://chromium.googlesource.com/native_client/src/native_client.git@master
Patch Set: Use file basename as dependency, not absolute / relative path. Created 4 years, 8 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 (c) 2016 The Native Client Authors. All rights reserved. 1 // Copyright (c) 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 #include <stdint.h> 5 #include <stdint.h>
6 #include <stdio.h> 6 #include <stdio.h>
7 7
8 #include "native_client/src/include/elf32.h" 8 #include "native_client/src/include/elf32.h"
9 #include "native_client/src/include/elf_auxv.h" 9 #include "native_client/src/include/elf_auxv.h"
10 #include "native_client/src/untrusted/nacl/nacl_irt.h" 10 #include "native_client/src/untrusted/nacl/nacl_irt.h"
11 #include "native_client/src/untrusted/pll_loader/pll_loader.h" 11 #include "native_client/src/untrusted/pll_loader/pll_loader.h"
12 12
13 13
14 typedef void (*start_func_t)(int argc, char **argv, char **envp, 14 typedef void (*start_func_t)(int argc, char **argv, char **envp,
15 Elf32_auxv_t *auxv); 15 Elf32_auxv_t *auxv);
16 16
17 int main(int argc, char **argv, char **envp) { 17 int main(int argc, char **argv, char **envp) {
18 // The PLL format does not include module dependencies yet, so all the 18 if (argc != 3) {
19 // modules must be specified on the command line. 19 fprintf(stderr, "Usage: pll_loader <Directory path> <ELF file>\n");
20 if (argc <= 2) {
21 fprintf(stderr, "Usage: pll_loader <ELF file>...\n");
22 return 1; 20 return 1;
23 } 21 }
24 22
25 ModuleSet modset; 23 ModuleSet modset;
26 for (int i = 1; i < argc; i++) { 24 std::vector<std::string> search_path;
27 modset.AddByFilename(argv[i]); 25 search_path.push_back(argv[1]);
28 } 26 modset.SetSonameSearchPath(search_path);
27
28 modset.AddBySoname(argv[2]);
Mark Seaborn 2016/03/30 23:24:57 Can you make this one AddByFilename() rather than
Sean Klein 2016/04/01 23:12:24 Done.
29 modset.ResolveRefs(); 29 modset.ResolveRefs();
30 30
31 Elf32_auxv_t auxv[2]; 31 Elf32_auxv_t auxv[2];
32 auxv[0].a_type = AT_SYSINFO; 32 auxv[0].a_type = AT_SYSINFO;
33 auxv[0].a_un.a_val = (uintptr_t) __nacl_irt_query; 33 auxv[0].a_un.a_val = (uintptr_t) __nacl_irt_query;
34 auxv[1].a_type = AT_NULL; 34 auxv[1].a_type = AT_NULL;
35 auxv[1].a_un.a_val = 0; 35 auxv[1].a_un.a_val = 0;
36 36
37 start_func_t start_func = 37 start_func_t start_func =
38 (start_func_t) (uintptr_t) modset.GetSym("__libc_start"); 38 (start_func_t) (uintptr_t) modset.GetSym("__libc_start");
39 if (start_func == NULL) { 39 if (start_func == NULL) {
40 fprintf(stderr, "Entry point symbol \"__libc_start\" not defined\n"); 40 fprintf(stderr, "Entry point symbol \"__libc_start\" not defined\n");
41 return 1; 41 return 1;
42 } 42 }
43 start_func(argc, argv, envp, auxv); 43 start_func(argc, argv, envp, auxv);
44 44
45 return 0; 45 return 0;
46 } 46 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698