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 // Pack relative relocations into a more compact form. | 5 // Pack relative relocations into a more compact form. |
6 // | 6 // |
7 // | 7 // |
8 // For relative relocations without addends (32 bit platforms) | 8 // For relative relocations without addends (32 bit platforms) |
9 // ----------------------------------------------------------- | 9 // ----------------------------------------------------------- |
10 // | 10 // |
(...skipping 30 matching lines...) Expand all Loading... |
41 // "APA1" pairs offset_d1 addend_d1 offset_d2 addend_d2 ... | 41 // "APA1" pairs offset_d1 addend_d1 offset_d2 addend_d2 ... |
42 // 41505232 f2b018 04 28 08 9f01 ... | 42 // 41505232 f2b018 04 28 08 9f01 ... |
43 | 43 |
44 #ifndef TOOLS_RELOCATION_PACKER_SRC_PACKER_H_ | 44 #ifndef TOOLS_RELOCATION_PACKER_SRC_PACKER_H_ |
45 #define TOOLS_RELOCATION_PACKER_SRC_PACKER_H_ | 45 #define TOOLS_RELOCATION_PACKER_SRC_PACKER_H_ |
46 | 46 |
47 #include <stdint.h> | 47 #include <stdint.h> |
48 #include <vector> | 48 #include <vector> |
49 | 49 |
50 #include "elf.h" | 50 #include "elf.h" |
51 #include "elf_traits.h" | |
52 | 51 |
53 namespace relocation_packer { | 52 namespace relocation_packer { |
54 | 53 |
55 // A RelocationPacker packs vectors of relative relocations into more | 54 // A RelocationPacker packs vectors of relocations into more |
56 // compact forms, and unpacks them to reproduce the pre-packed data. | 55 // compact forms, and unpacks them to reproduce the pre-packed data. |
| 56 template <typename ELF> |
57 class RelocationPacker { | 57 class RelocationPacker { |
58 public: | 58 public: |
59 // Pack relative relocations into a more compact form. | 59 // Pack relocations into a more compact form. |
60 // |relocations| is a vector of relative relocation structs. | 60 // |relocations| is a vector of relocation structs. |
61 // |packed| is the vector of packed bytes into which relocations are packed. | 61 // |packed| is the vector of packed bytes into which relocations are packed. |
62 static void PackRelativeRelocations(const std::vector<ELF::Rel>& relocations, | 62 static void PackRelocations(const std::vector<typename ELF::Rela>& relocations
, |
63 std::vector<uint8_t>* packed); | 63 std::vector<uint8_t>* packed); |
64 static void PackRelativeRelocations(const std::vector<ELF::Rela>& relocations, | |
65 std::vector<uint8_t>* packed); | |
66 | 64 |
67 // Unpack relative relocations from their more compact form. | 65 // Unpack relocations from their more compact form. |
68 // |packed| is the vector of packed relocations. | 66 // |packed| is the vector of packed relocations. |
69 // |relocations| is a vector of unpacked relative relocation structs. | 67 // |relocations| is a vector of unpacked relocation structs. |
70 static void UnpackRelativeRelocations(const std::vector<uint8_t>& packed, | 68 static void UnpackRelocations(const std::vector<uint8_t>& packed, |
71 std::vector<ELF::Rel>* relocations); | 69 std::vector<typename ELF::Rela>* relocations); |
72 static void UnpackRelativeRelocations(const std::vector<uint8_t>& packed, | |
73 std::vector<ELF::Rela>* relocations); | |
74 }; | 70 }; |
75 | 71 |
76 } // namespace relocation_packer | 72 } // namespace relocation_packer |
77 | 73 |
78 #endif // TOOLS_RELOCATION_PACKER_SRC_PACKER_H_ | 74 #endif // TOOLS_RELOCATION_PACKER_SRC_PACKER_H_ |
OLD | NEW |