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

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

Issue 1743893002: PNaCl dynamic linking: Build an initial dynamically-linked newlib-based libc (Closed) Base URL: https://chromium.googlesource.com/native_client/src/native_client.git@master
Patch Set: Created 4 years, 10 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
Index: src/untrusted/pll_loader/pll_loader_main.cc
diff --git a/src/untrusted/pll_loader/pll_loader_main.cc b/src/untrusted/pll_loader/pll_loader_main.cc
new file mode 100644
index 0000000000000000000000000000000000000000..2a489bd8e6c7263d7d53bfe2a0340f8e4fd37570
--- /dev/null
+++ b/src/untrusted/pll_loader/pll_loader_main.cc
@@ -0,0 +1,46 @@
+// Copyright (c) 2016 The Native Client Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <stdint.h>
+#include <stdio.h>
+
+#include "native_client/src/include/elf32.h"
+#include "native_client/src/include/elf_auxv.h"
+#include "native_client/src/untrusted/nacl/nacl_irt.h"
+#include "native_client/src/untrusted/pll_loader/pll_loader.h"
+
+
+typedef void (*start_func_t)(int argc, char **argv, char **envp,
+ Elf32_auxv_t *auxv);
+
+int main(int argc, char **argv, char **envp) {
+ // The PLL format does not include module dependencies yet, so all the
+ // modules must be specified on the command line.
+ if (argc <= 2) {
+ fprintf(stderr, "Usage: pll_loader <ELF file>...\n");
+ return 1;
+ }
+
+ ModuleSet modset;
+ for (int i = 1; i < argc; i++) {
+ modset.AddByFilename(argv[i]);
+ }
+ modset.ResolveRefs();
+
+ Elf32_auxv_t auxv[2];
+ auxv[0].a_type = AT_SYSINFO;
+ auxv[0].a_un.a_val = (uintptr_t) __nacl_irt_query;
+ auxv[1].a_type = AT_NULL;
+ auxv[1].a_un.a_val = 0;
+
+ start_func_t start_func =
+ (start_func_t) (uintptr_t) modset.GetSym("__libc_start");
+ if (start_func == NULL) {
+ fprintf(stderr, "Entry point symbol \"__libc_start\" not defined\n");
+ return 1;
+ }
+ start_func(argc, argv, envp, auxv);
+
+ return 0;
+}

Powered by Google App Engine
This is Rietveld 408576698