Chromium Code Reviews| Index: components/nacl/loader/nonsfi/elf_loader.h |
| diff --git a/components/nacl/loader/nonsfi/elf_loader.h b/components/nacl/loader/nonsfi/elf_loader.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..cd2a91f03fee161de37f247700010ed4cd009e8a |
| --- /dev/null |
| +++ b/components/nacl/loader/nonsfi/elf_loader.h |
| @@ -0,0 +1,57 @@ |
| +// 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_LOADER_H_ |
| +#define COMPONENTS_NACL_LOADER_NONSFI_ELF_LOADER_H_ |
| + |
| +#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
|
| +#include <link.h> |
| + |
| +#include "base/basictypes.h" |
| +#include "components/nacl/loader/nonsfi/nonsfi_error_code.h" |
| +#include "native_client/src/include/portability.h" |
| + |
| +#if !defined(OS_LINUX) |
| +#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: |
| + ElfW(Ehdr) ehdr_; |
| + ElfW(Phdr) phdrs_[MAX_PROGRAM_HEADERS]; |
| + ElfW(Addr) load_bias_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ElfImage); |
| +}; |
| + |
| +} // namespace nonsfi |
| +} // namespace nacl |
| + |
| +#endif // COMPONENTS_NACL_LOADER_NONSFI_ELF_LOADER_H_ |