| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2014 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 #ifndef NACL_SPAWN_ELF_READER_ | |
| 6 #define NACL_SPAWN_ELF_READER_ | |
| 7 | |
| 8 #include <elf.h> | |
| 9 #include <stdio.h> | |
| 10 | |
| 11 #include <string> | |
| 12 #include <vector> | |
| 13 | |
| 14 // An ELF reader which extracts shared objects which are necessary to | |
| 15 // run the specified binary (DT_NEEDED). As no NaCl binary in the NaCl | |
| 16 // SDK does not have DT_RPATH and DT_RUNPATH (as of Jan. 2014), we do | |
| 17 // not support them. | |
| 18 class ElfReader { | |
| 19 public: | |
| 20 explicit ElfReader(const char* filename); | |
| 21 | |
| 22 bool is_valid() const { return is_valid_; } | |
| 23 bool is_static() const { return is_static_; } | |
| 24 Elf64_Half machine() const { return machine_; } | |
| 25 const std::vector<std::string>& neededs() const { return neededs_; } | |
| 26 | |
| 27 private: | |
| 28 bool ReadHeaders(FILE* fp, std::vector<Elf64_Phdr>* phdrs); | |
| 29 bool ReadDynamic(FILE* fp, const std::vector<Elf64_Phdr>& phdrs, | |
| 30 Elf64_Addr* straddr, size_t* strsize, | |
| 31 std::vector<int>* neededs); | |
| 32 bool ReadStrtab(FILE* fp, const std::vector<Elf64_Phdr>& phdrs, | |
| 33 Elf64_Addr straddr, size_t strsize, | |
| 34 std::string* strtab); | |
| 35 void PrintError(const char* fmt, ...); | |
| 36 | |
| 37 const char* filename_; | |
| 38 bool is_valid_; | |
| 39 bool is_static_; | |
| 40 Elf64_Half machine_; | |
| 41 unsigned char elf_class_; | |
| 42 std::vector<std::string> neededs_; | |
| 43 }; | |
| 44 | |
| 45 #endif // NACL_SPAWN_ELF_READER_ | |
| OLD | NEW |