summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lld/ELF/Target.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/lld/ELF/Target.cpp b/lld/ELF/Target.cpp
index 81d51492af4..dabdea78ce5 100644
--- a/lld/ELF/Target.cpp
+++ b/lld/ELF/Target.cpp
@@ -60,6 +60,9 @@ bool X86TargetInfo::relocNeedsPlt(uint32_t Type, const SymbolBody &S) const {
}
static void add32le(uint8_t *P, int32_t V) { write32le(P, read32le(P) + V); }
+static void or16le(uint8_t *P, int16_t V) { write16le(P, read16le(P) + V); }
+static void or32le(uint8_t *P, int32_t V) { write32le(P, read32le(P) + V); }
+static void or64le(uint8_t *P, int64_t V) { write64le(P, read64le(P) + V); }
void X86TargetInfo::relocateOne(uint8_t *Buf, const void *RelP, uint32_t Type,
uint64_t BaseAddr, uint64_t SymVA,
@@ -286,26 +289,26 @@ static void handle_ABS16(uint8_t *Location, uint64_t S, int64_t A) {
uint64_t X = S + A;
if (!isInt<16>(X)) // -2^15 <= X < 2^16
error("Relocation R_AARCH64_ABS16 out of range");
- write16le(Location, read16le(Location) | X);
+ or16le(Location, X);
}
static void handle_ABS32(uint8_t *Location, uint64_t S, int64_t A) {
uint64_t X = S + A;
if (!isInt<32>(X)) // -2^31 <= X < 2^32
error("Relocation R_AARCH64_ABS32 out of range");
- write32le(Location, read32le(Location) | X);
+ or32le(Location, X);
}
static void handle_ABS64(uint8_t *Location, uint64_t S, int64_t A) {
uint64_t X = S + A;
// No overflow check.
- write64le(Location, read64le(Location) | X);
+ or64le(Location, X);
}
static void handle_ADD_ABS_LO12_NC(uint8_t *Location, uint64_t S, int64_t A) {
// No overflow check.
uint64_t X = ((S + A) & 0xFFF) << 10;
- write32le(Location, read32le(Location) | X);
+ or32le(Location, X);
}
static void handle_ADR_PREL_LO21(uint8_t *Location, uint64_t S, int64_t A,
OpenPOWER on IntegriCloud