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

Unified Diff: components/nacl/loader/nonsfi/elf_util.h

Issue 100373005: Initial implementation of Bare Metal Mode for NaCl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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: components/nacl/loader/nonsfi/elf_util.h
diff --git a/components/nacl/loader/nonsfi/elf_util.h b/components/nacl/loader/nonsfi/elf_util.h
new file mode 100644
index 0000000000000000000000000000000000000000..0127f236230989524e1b50648c44c58668683cce
--- /dev/null
+++ b/components/nacl/loader/nonsfi/elf_util.h
@@ -0,0 +1,55 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_NACL_LOADER_NONSFI_ELF_UTIL_H_
+#define COMPONENTS_NACL_LOADER_NONSFI_ELF_UTIL_H_
+
+#include "base/basictypes.h"
+#include "components/nacl/loader/nonsfi/nonsfi_error_code.h"
+#include "native_client/src/include/elf32.h"
+#include "native_client/src/include/portability.h"
+
+#if !defined(OS_LINUX) || NACL_BUILD_SUBARCH != 32
+#error Non SFI mode is currently supported only on linux.
+#endif
+
+struct NaClDesc;
+
+namespace nacl {
+namespace nonsfi {
+
+class ElfImage {
+ public:
+ // Limit of elf program headers allowed.
+ enum {
+ MAX_PROGRAM_HEADERS = 128
+ };
+
+ ElfImage();
+ ~ElfImage();
+
+ // Available only after Load() is called.
+ uintptr_t entry_point() const {
+ return ehdr_.e_entry + load_bias_;
+ }
+
+ // Reads the ELF file from the descriptor and stores the header information
+ // into this instance.
+ NonSfiErrorCode Read(struct NaClDesc* descriptor);
+
+ // Loads the ELF executable to the memory.
+ NonSfiErrorCode Load(struct NaClDesc* descriptor);
+
+ private:
+ Elf32_Ehdr ehdr_;
+ Elf32_Phdr phdrs_[MAX_PROGRAM_HEADERS];
+ Elf32_Addr load_bias_;
+
+ DISALLOW_COPY_AND_ASSIGN(ElfImage);
+};
+
+} // namespace nonsfi
+} // namespace nacl
+
+#endif // COMPONENTS_NACL_LOADER_NONSFI_ELF_UTIL_H_

Powered by Google App Engine
This is Rietveld 408576698