OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include <stdint.h> |
| 6 #include <stdio.h> |
| 7 |
| 8 #include "native_client/src/include/elf32.h" |
| 9 #include "native_client/src/include/elf_auxv.h" |
| 10 #include "native_client/src/untrusted/nacl/nacl_irt.h" |
| 11 #include "native_client/src/untrusted/pll_loader/pll_loader.h" |
| 12 |
| 13 |
| 14 typedef void (*start_func_t)(int argc, char **argv, char **envp, |
| 15 Elf32_auxv_t *auxv); |
| 16 |
| 17 int main(int argc, char **argv, char **envp) { |
| 18 // The PLL format does not include module dependencies yet, so all the |
| 19 // modules must be specified on the command line. |
| 20 if (argc <= 2) { |
| 21 fprintf(stderr, "Usage: pll_loader <ELF file>...\n"); |
| 22 return 1; |
| 23 } |
| 24 |
| 25 ModuleSet modset; |
| 26 for (int i = 1; i < argc; i++) { |
| 27 modset.AddByFilename(argv[i]); |
| 28 } |
| 29 modset.ResolveRefs(); |
| 30 |
| 31 Elf32_auxv_t auxv[2]; |
| 32 auxv[0].a_type = AT_SYSINFO; |
| 33 auxv[0].a_un.a_val = (uintptr_t) __nacl_irt_query; |
| 34 auxv[1].a_type = AT_NULL; |
| 35 auxv[1].a_un.a_val = 0; |
| 36 |
| 37 start_func_t start_func = |
| 38 (start_func_t) (uintptr_t) modset.GetSym("__libc_start"); |
| 39 if (start_func == NULL) { |
| 40 fprintf(stderr, "Entry point symbol \"__libc_start\" not defined\n"); |
| 41 return 1; |
| 42 } |
| 43 start_func(argc, argv, envp, auxv); |
| 44 |
| 45 return 0; |
| 46 } |
OLD | NEW |