OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // Pack R_ARM_RELATIVE relocations into a more compact form. |
| 6 // |
| 7 // Applies two packing strategies. The first is run-length encoding, which |
| 8 // turns a large set of R_ARM_RELATIVE relocations into a much smaller set |
| 9 // of delta-count pairs, prefixed with a two-word header comprising the |
| 10 // count of pairs and the initial relocation offset. The second is LEB128 |
| 11 // encoding, which compacts the result of run-length encoding. |
| 12 // |
| 13 // Once packed, data is prefixed by an identifier that allows for any later |
| 14 // versioning of packing strategies. |
| 15 // |
| 16 // A complete packed stream might look something like: |
| 17 // |
| 18 // "APR1" pairs init_offset count1 delta1 count2 delta2 ... |
| 19 // 41505231 f2b003 b08ac716 e001 04 01 10 ... |
| 20 |
| 21 #ifndef RELOCATION_PACKER_PACKER_H |
| 22 #define RELOCATION_PACKER_PACKER_H |
| 23 |
| 24 #include <stdint.h> |
| 25 #include <string.h> |
| 26 #include <vector> |
| 27 |
| 28 #include "elf.h" |
| 29 |
| 30 namespace relocation_packer { |
| 31 |
| 32 // A RelocationPacker packs vectors of R_ARM_RELATIVE relocations into more |
| 33 // compact forms, and unpacks them to reproduce the pre-packed data. |
| 34 class RelocationPacker { |
| 35 public: |
| 36 // Pack R_ARM_RELATIVE relocations into a more compact form. |
| 37 // |relocations| is a vector of R_ARM_RELATIVE relocation structs. |
| 38 // |packed| is the vector of packed bytes into which relocations are packed. |
| 39 static void PackRelativeRelocations(const std::vector<Elf32_Rel>& relocations, |
| 40 std::vector<uint8_t>* packed); |
| 41 |
| 42 // Unpack R_ARM_RELATIVE relocations from their more compact form. |
| 43 // |packed| is the vector of packed relocations. |
| 44 // |relocations| is a vector of unpacked R_ARM_RELATIVE relocation structs. |
| 45 static void UnpackRelativeRelocations(const std::vector<uint8_t>& packed, |
| 46 std::vector<Elf32_Rel>* relocations); |
| 47 }; |
| 48 |
| 49 } // namespace relocation_packer |
| 50 |
| 51 #endif // RELOCATION_PACKER_PACKER_H |
OLD | NEW |