Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2013 The Chromium 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 #ifndef COMPONENTS_NACL_LOADER_NONSFI_ELF_LOADER_H_ | |
| 6 #define COMPONENTS_NACL_LOADER_NONSFI_ELF_LOADER_H_ | |
| 7 | |
| 8 #include <elf.h> | |
|
Mark Seaborn
2013/12/10 19:56:44
It would be better if these didn't appear in the h
hidehiko
2013/12/11 07:56:14
Removed the include directive.
Instead of having s
| |
| 9 #include <link.h> | |
| 10 | |
| 11 #include "base/basictypes.h" | |
| 12 #include "components/nacl/loader/nonsfi/nonsfi_error_code.h" | |
| 13 #include "native_client/src/include/portability.h" | |
| 14 | |
| 15 #if !defined(OS_LINUX) | |
| 16 #error Non SFI mode is currently supported only on linux. | |
| 17 #endif | |
| 18 | |
| 19 struct NaClDesc; | |
| 20 | |
| 21 namespace nacl { | |
| 22 namespace nonsfi { | |
| 23 | |
| 24 class ElfImage { | |
| 25 public: | |
| 26 // Limit of elf program headers allowed. | |
| 27 enum { | |
| 28 MAX_PROGRAM_HEADERS = 128 | |
| 29 }; | |
| 30 | |
| 31 ElfImage(); | |
| 32 ~ElfImage(); | |
| 33 | |
| 34 // Available only after Load() is called. | |
| 35 uintptr_t entry_point() const { | |
| 36 return ehdr_.e_entry + load_bias_; | |
| 37 } | |
| 38 | |
| 39 // Reads the ELF file from the descriptor and stores the header information | |
| 40 // into this instance. | |
| 41 NonSfiErrorCode Read(struct NaClDesc* descriptor); | |
| 42 | |
| 43 // Loads the ELF executable to the memory. | |
| 44 NonSfiErrorCode Load(struct NaClDesc* descriptor); | |
| 45 | |
| 46 private: | |
| 47 ElfW(Ehdr) ehdr_; | |
| 48 ElfW(Phdr) phdrs_[MAX_PROGRAM_HEADERS]; | |
| 49 ElfW(Addr) load_bias_; | |
| 50 | |
| 51 DISALLOW_COPY_AND_ASSIGN(ElfImage); | |
| 52 }; | |
| 53 | |
| 54 } // namespace nonsfi | |
| 55 } // namespace nacl | |
| 56 | |
| 57 #endif // COMPONENTS_NACL_LOADER_NONSFI_ELF_LOADER_H_ | |
| OLD | NEW |