| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // ELF shared object file updates handler. | 5 // ELF shared object file updates handler. |
| 6 // | 6 // |
| 7 // Provides functions to pack relocations in the .rel.dyn or .rela.dyn | 7 // Provides functions to pack relocations in the .rel.dyn or .rela.dyn |
| 8 // sections, and unpack to return the file to its pre-packed state. | 8 // sections, and unpack to return the file to its pre-packed state. |
| 9 // | 9 // |
| 10 // SetPadding() causes PackRelocations() to pad .rel.dyn or .rela.dyn with | 10 // SetPadding() causes PackRelocations() to pad .rel.dyn or .rela.dyn with |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 | 29 |
| 30 // An ElfFile reads shared objects, and shuttles relative relocations | 30 // An ElfFile reads shared objects, and shuttles relative relocations |
| 31 // between .rel.dyn or .rela.dyn and .android.rel.dyn or .android.rela.dyn | 31 // between .rel.dyn or .rela.dyn and .android.rel.dyn or .android.rela.dyn |
| 32 // sections. | 32 // sections. |
| 33 template <typename ELF> | 33 template <typename ELF> |
| 34 class ElfFile { | 34 class ElfFile { |
| 35 public: | 35 public: |
| 36 explicit ElfFile(int fd) | 36 explicit ElfFile(int fd) |
| 37 : fd_(fd), is_padding_relocations_(false), elf_(NULL), | 37 : fd_(fd), is_padding_relocations_(false), elf_(NULL), |
| 38 relocations_section_(NULL), dynamic_section_(NULL), | 38 relocations_section_(NULL), dynamic_section_(NULL), |
| 39 relocations_type_(NONE) {} | 39 relocations_type_(NONE), has_android_relocations_(false) {} |
| 40 ~ElfFile() {} | 40 ~ElfFile() {} |
| 41 | 41 |
| 42 // Set padding mode. When padding, PackRelocations() will not shrink | 42 // Set padding mode. When padding, PackRelocations() will not shrink |
| 43 // the .rel.dyn or .rela.dyn section, but instead replace relative with | 43 // the .rel.dyn or .rela.dyn section, but instead replace relative with |
| 44 // NONE-type entries. | 44 // NONE-type entries. |
| 45 // |flag| is true to pad .rel.dyn or .rela.dyn, false to shrink it. | 45 // |flag| is true to pad .rel.dyn or .rela.dyn, false to shrink it. |
| 46 inline void SetPadding(bool flag) { is_padding_relocations_ = flag; } | 46 inline void SetPadding(bool flag) { is_padding_relocations_ = flag; } |
| 47 | 47 |
| 48 // Transfer relative relocations from .rel.dyn or .rela.dyn to a packed | 48 // Transfer relative relocations from .rel.dyn or .rela.dyn to a packed |
| 49 // representation in .android.rel.dyn or .android.rela.dyn. Returns true | 49 // representation in .android.rel.dyn or .android.rela.dyn. Returns true |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 | 104 |
| 105 // Libelf handle, assigned by Load(). | 105 // Libelf handle, assigned by Load(). |
| 106 Elf* elf_; | 106 Elf* elf_; |
| 107 | 107 |
| 108 // Sections that we manipulate, assigned by Load(). | 108 // Sections that we manipulate, assigned by Load(). |
| 109 Elf_Scn* relocations_section_; | 109 Elf_Scn* relocations_section_; |
| 110 Elf_Scn* dynamic_section_; | 110 Elf_Scn* dynamic_section_; |
| 111 | 111 |
| 112 // Relocation type found, assigned by Load(). | 112 // Relocation type found, assigned by Load(). |
| 113 relocations_type_t relocations_type_; | 113 relocations_type_t relocations_type_; |
| 114 |
| 115 // Elf-file has android relocations section |
| 116 bool has_android_relocations_; |
| 114 }; | 117 }; |
| 115 | 118 |
| 116 } // namespace relocation_packer | 119 } // namespace relocation_packer |
| 117 | 120 |
| 118 #endif // TOOLS_RELOCATION_PACKER_SRC_ELF_FILE_H_ | 121 #endif // TOOLS_RELOCATION_PACKER_SRC_ELF_FILE_H_ |
| OLD | NEW |