[lld] r252518 - Use llvm provided read and write functions.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 9 13:43:00 PST 2015
Author: rafael
Date: Mon Nov 9 15:43:00 2015
New Revision: 252518
URL: http://llvm.org/viewvc/llvm-project?rev=252518&view=rev
Log:
Use llvm provided read and write functions.
Modified:
lld/trunk/ELF/Target.cpp
Modified: lld/trunk/ELF/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=252518&r1=252517&r2=252518&view=diff
==============================================================================
--- lld/trunk/ELF/Target.cpp (original)
+++ lld/trunk/ELF/Target.cpp Mon Nov 9 15:43:00 2015
@@ -35,21 +35,12 @@ namespace elf2 {
std::unique_ptr<TargetInfo> Target;
-template <bool IsLE> static uint32_t read32(const uint8_t *L);
-template <> uint32_t read32<true>(const uint8_t *L) { return read32le(L); }
-template <> uint32_t read32<false>(const uint8_t *L) { return read32be(L); }
-
-template <bool IsLE> static void write32(uint8_t *L, uint32_t V);
-template <> void write32<true>(uint8_t *L, uint32_t V) { write32le(L, V); }
-template <> void write32<false>(uint8_t *L, uint32_t V) { write32be(L, V); }
-
-static void add32le(uint8_t *L, int32_t V) { write32le(L, read32le(L) + V); }
-static void add32be(uint8_t *L, int32_t V) { write32be(L, read32be(L) + V); }
-static void or32le(uint8_t *L, int32_t V) { write32le(L, read32le(L) | V); }
-
-template <bool IsLE> static void add32(uint8_t *L, int32_t V);
-template <> void add32<true>(uint8_t *L, int32_t V) { add32le(L, V); }
-template <> void add32<false>(uint8_t *L, int32_t V) { add32be(L, V); }
+template <endianness E> static void add32(void *P, int32_t V) {
+ write32<E>(P, read32<E>(P) + V);
+}
+
+static void add32le(uint8_t *P, int32_t V) { add32<support::little>(P, V); }
+static void or32le(uint8_t *P, int32_t V) { write32le(P, read32le(P) | V); }
namespace {
class X86TargetInfo final : public TargetInfo {
@@ -722,16 +713,16 @@ template <class ELFT>
void MipsTargetInfo<ELFT>::relocateOne(uint8_t *Loc, uint8_t *BufEnd,
uint32_t Type, uint64_t P,
uint64_t SA) const {
- const bool IsLE = ELFT::TargetEndianness == support::little;
+ const endianness E = ELFT::TargetEndianness;
switch (Type) {
case R_MIPS_32:
- add32<IsLE>(Loc, SA);
+ add32<E>(Loc, SA);
break;
case R_MIPS_GOT16: {
int64_t V = SA - getMipsGpAddr<ELFT>();
if (!isInt<16>(V))
error("Relocation R_MIPS_GOT16 out of range");
- write32<IsLE>(Loc, (read32<IsLE>(Loc) & 0xffff0000) | (V & 0xffff));
+ write32<E>(Loc, (read32<E>(Loc) & 0xffff0000) | (V & 0xffff));
break;
}
default:
More information about the llvm-commits
mailing list