| Index: tools/relocation_packer/src/sleb128.h
|
| diff --git a/tools/relocation_packer/src/leb128.h b/tools/relocation_packer/src/sleb128.h
|
| similarity index 60%
|
| copy from tools/relocation_packer/src/leb128.h
|
| copy to tools/relocation_packer/src/sleb128.h
|
| index 500845e09c1ee4b5a6f74e27f1066467a03dd7f5..3544543c0d6f6d6bf2ff5f6ec0acddd253f3de29 100644
|
| --- a/tools/relocation_packer/src/leb128.h
|
| +++ b/tools/relocation_packer/src/sleb128.h
|
| @@ -2,38 +2,39 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -// LEB128 encoder and decoder for packed ARM relative relocations.
|
| +// SLEB128 encoder and decoder for packed relative relocations.
|
| //
|
| -// Run-length encoded ARM relative relocations consist of a large number
|
| -// of pairs of relatively small positive integer values. Encoding these as
|
| -// LEB128 saves space.
|
| +// Delta encoded relative relocations consist of a large number
|
| +// of pairs signed integer values, many with small values. Encoding these
|
| +// as signed LEB128 saves space.
|
| //
|
| // For more on LEB128 see http://en.wikipedia.org/wiki/LEB128.
|
|
|
| -#ifndef TOOLS_RELOCATION_PACKER_SRC_LEB128_H_
|
| -#define TOOLS_RELOCATION_PACKER_SRC_LEB128_H_
|
| +#ifndef TOOLS_RELOCATION_PACKER_SRC_SLEB128_H_
|
| +#define TOOLS_RELOCATION_PACKER_SRC_SLEB128_H_
|
|
|
| #include <stdint.h>
|
| +#include <unistd.h>
|
| #include <vector>
|
|
|
| #include "elf_traits.h"
|
|
|
| namespace relocation_packer {
|
|
|
| -// Encode packed words as a LEB128 byte stream.
|
| -class Leb128Encoder {
|
| +// Encode packed words as a signed LEB128 byte stream.
|
| +class Sleb128Encoder {
|
| public:
|
| // Explicit (but empty) constructor and destructor, for chromium-style.
|
| - Leb128Encoder();
|
| - ~Leb128Encoder();
|
| + Sleb128Encoder();
|
| + ~Sleb128Encoder();
|
|
|
| // Add a value to the encoding stream.
|
| - // |value| is the unsigned int to add.
|
| - void Enqueue(ELF::Xword value);
|
| + // |value| is the signed int to add.
|
| + void Enqueue(ELF::Sxword value);
|
|
|
| // Add a vector of values to the encoding stream.
|
| - // |values| is the vector of unsigned ints to add.
|
| - void EnqueueAll(const std::vector<ELF::Xword>& values);
|
| + // |values| is the vector of signed ints to add.
|
| + void EnqueueAll(const std::vector<ELF::Sxword>& values);
|
|
|
| // Retrieve the encoded representation of the values.
|
| // |encoding| is the returned vector of encoded data.
|
| @@ -45,21 +46,21 @@ class Leb128Encoder {
|
| };
|
|
|
| // Decode a LEB128 byte stream to produce packed words.
|
| -class Leb128Decoder {
|
| +class Sleb128Decoder {
|
| public:
|
| // Create a new decoder for the given encoded stream.
|
| // |encoding| is the vector of encoded data.
|
| - explicit Leb128Decoder(const std::vector<uint8_t>& encoding);
|
| + explicit Sleb128Decoder(const std::vector<uint8_t>& encoding);
|
|
|
| // Explicit (but empty) destructor, for chromium-style.
|
| - ~Leb128Decoder();
|
| + ~Sleb128Decoder();
|
|
|
| // Retrieve the next value from the encoded stream.
|
| - ELF::Xword Dequeue();
|
| + ELF::Sxword Dequeue();
|
|
|
| // Retrieve all remaining values from the encoded stream.
|
| // |values| is the vector of decoded data.
|
| - void DequeueAll(std::vector<ELF::Xword>* values);
|
| + void DequeueAll(std::vector<ELF::Sxword>* values);
|
|
|
| private:
|
| // Encoded LEB128 stream.
|
| @@ -71,4 +72,4 @@ class Leb128Decoder {
|
|
|
| } // namespace relocation_packer
|
|
|
| -#endif // TOOLS_RELOCATION_PACKER_SRC_LEB128_H_
|
| +#endif // TOOLS_RELOCATION_PACKER_SRC_SLEB128_H_
|
|
|