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

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

Issue 310483003: Add a host tool to pack R_ARM_RELATIVE relocations in libchrome.<ver>.so. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove binary test data files, dcommit separately. Created 6 years, 6 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
(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 TOOLS_RELOCATION_PACKER_SRC_PACKER_H_
22 #define TOOLS_RELOCATION_PACKER_SRC_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 // 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