forked from OSchip/llvm-project
ELF2: Define or{16,32,64}le that are analogous to add32le.
llvm-svn: 249435
This commit is contained in:
parent
d16d6c0046
commit
190beb3144
|
@ -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 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,
|
void X86TargetInfo::relocateOne(uint8_t *Buf, const void *RelP, uint32_t Type,
|
||||||
uint64_t BaseAddr, uint64_t SymVA,
|
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;
|
uint64_t X = S + A;
|
||||||
if (!isInt<16>(X)) // -2^15 <= X < 2^16
|
if (!isInt<16>(X)) // -2^15 <= X < 2^16
|
||||||
error("Relocation R_AARCH64_ABS16 out of range");
|
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) {
|
static void handle_ABS32(uint8_t *Location, uint64_t S, int64_t A) {
|
||||||
uint64_t X = S + A;
|
uint64_t X = S + A;
|
||||||
if (!isInt<32>(X)) // -2^31 <= X < 2^32
|
if (!isInt<32>(X)) // -2^31 <= X < 2^32
|
||||||
error("Relocation R_AARCH64_ABS32 out of range");
|
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) {
|
static void handle_ABS64(uint8_t *Location, uint64_t S, int64_t A) {
|
||||||
uint64_t X = S + A;
|
uint64_t X = S + A;
|
||||||
// No overflow check.
|
// 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) {
|
static void handle_ADD_ABS_LO12_NC(uint8_t *Location, uint64_t S, int64_t A) {
|
||||||
// No overflow check.
|
// No overflow check.
|
||||||
uint64_t X = ((S + A) & 0xFFF) << 10;
|
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,
|
static void handle_ADR_PREL_LO21(uint8_t *Location, uint64_t S, int64_t A,
|
||||||
|
|
Loading…
Reference in New Issue