Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Side by Side Diff: tools/relocation_packer/src/packer.h

Issue 410933004: Extend relocation packing to cover arm64. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase to master Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/relocation_packer/src/main.cc ('k') | tools/relocation_packer/src/packer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 ARM relative relocations into a more compact form. 5 // Pack relative relocations into a more compact form.
6 //
7 //
8 // For relative relocations without addends (32 bit platforms)
9 // -----------------------------------------------------------
6 // 10 //
7 // Applies two packing strategies. The first is run-length encoding, which 11 // Applies two packing strategies. The first is run-length encoding, which
8 // turns a large set of ARM relative relocations into a much smaller set 12 // turns a large set of relative relocations into a much smaller set
9 // of delta-count pairs, prefixed with a two-word header comprising the 13 // 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 14 // count of pairs and the initial relocation offset. The second is LEB128
11 // encoding, which compacts the result of run-length encoding. 15 // encoding, which compresses the result of run-length encoding.
16 //
17 // Once packed, data is prefixed by an identifier that allows for any later
18 // versioning of packing strategies.
19 //
20 // A complete packed stream of relocations without addends might look
21 // something like:
22 //
23 // "APR1" pairs init_offset count1 delta1 count2 delta2 ...
24 // 41505231 f2b003 b08ac716 e001 04 01 10 ...
25 //
26 //
27 // For relative relocations with addends (64 bit platforms)
28 // --------------------------------------------------------
29 //
30 // Applies two packing strategies. The first is delta encoding, which
31 // turns a large set of relative relocations into a smaller set
32 // of offset and addend delta pairs, prefixed with a header indicating the
33 // count of pairs. The second is signed LEB128 encoding, which compacts
34 // the result of delta encoding.
12 // 35 //
13 // Once packed, data is prefixed by an identifier that allows for any later 36 // Once packed, data is prefixed by an identifier that allows for any later
14 // versioning of packing strategies. 37 // versioning of packing strategies.
15 // 38 //
16 // A complete packed stream might look something like: 39 // A complete packed stream might look something like:
17 // 40 //
18 // "APR1" pairs init_offset count1 delta1 count2 delta2 ... 41 // "APA1" pairs offset_d1 addend_d1 offset_d2 addend_d2 ...
19 // 41505231 f2b003 b08ac716 e001 04 01 10 ... 42 // 41505232 f2b018 04 28 08 9f01 ...
20 43
21 #ifndef TOOLS_RELOCATION_PACKER_SRC_PACKER_H_ 44 #ifndef TOOLS_RELOCATION_PACKER_SRC_PACKER_H_
22 #define TOOLS_RELOCATION_PACKER_SRC_PACKER_H_ 45 #define TOOLS_RELOCATION_PACKER_SRC_PACKER_H_
23 46
24 #include <stdint.h> 47 #include <stdint.h>
25 #include <vector> 48 #include <vector>
26 49
27 #include "elf.h" 50 #include "elf.h"
28 #include "elf_traits.h" 51 #include "elf_traits.h"
29 52
30 namespace relocation_packer { 53 namespace relocation_packer {
31 54
32 // A RelocationPacker packs vectors of ARM relative relocations into more 55 // A RelocationPacker packs vectors of relative relocations into more
33 // compact forms, and unpacks them to reproduce the pre-packed data. 56 // compact forms, and unpacks them to reproduce the pre-packed data.
34 class RelocationPacker { 57 class RelocationPacker {
35 public: 58 public:
36 // Pack ARM relative relocations into a more compact form. 59 // Pack relative relocations into a more compact form.
37 // |relocations| is a vector of ARM relative relocation structs. 60 // |relocations| is a vector of relative relocation structs.
38 // |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.
39 static void PackRelativeRelocations(const std::vector<ELF::Rel>& relocations, 62 static void PackRelativeRelocations(const std::vector<ELF::Rel>& relocations,
40 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);
41 66
42 // Unpack ARM relative relocations from their more compact form. 67 // Unpack relative relocations from their more compact form.
43 // |packed| is the vector of packed relocations. 68 // |packed| is the vector of packed relocations.
44 // |relocations| is a vector of unpacked ARM relative relocation structs. 69 // |relocations| is a vector of unpacked relative relocation structs.
45 static void UnpackRelativeRelocations(const std::vector<uint8_t>& packed, 70 static void UnpackRelativeRelocations(const std::vector<uint8_t>& packed,
46 std::vector<ELF::Rel>* relocations); 71 std::vector<ELF::Rel>* relocations);
72 static void UnpackRelativeRelocations(const std::vector<uint8_t>& packed,
73 std::vector<ELF::Rela>* relocations);
47 }; 74 };
48 75
49 } // namespace relocation_packer 76 } // namespace relocation_packer
50 77
51 #endif // TOOLS_RELOCATION_PACKER_SRC_PACKER_H_ 78 #endif // TOOLS_RELOCATION_PACKER_SRC_PACKER_H_
OLDNEW
« no previous file with comments | « tools/relocation_packer/src/main.cc ('k') | tools/relocation_packer/src/packer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698