diff --git a/lld/ELF/Target.cpp b/lld/ELF/Target.cpp index 0e945bc4843c..247f48eb40f5 100644 --- a/lld/ELF/Target.cpp +++ b/lld/ELF/Target.cpp @@ -70,7 +70,7 @@ namespace { class X86TargetInfo final : public TargetInfo { public: X86TargetInfo(); - uint64_t getImplicitAddend(uint8_t *Buf, uint32_t Type) const override; + uint64_t getImplicitAddend(const uint8_t *Buf, uint32_t Type) const override; void writeGotPltHeader(uint8_t *Buf) const override; uint32_t getDynRel(uint32_t Type) const override; uint32_t getTlsGotRel(uint32_t Type) const override; @@ -192,7 +192,7 @@ public: template class MipsTargetInfo final : public TargetInfo { public: MipsTargetInfo(); - uint64_t getImplicitAddend(uint8_t *Buf, uint32_t Type) const override; + uint64_t getImplicitAddend(const uint8_t *Buf, uint32_t Type) const override; uint32_t getDynRel(uint32_t Type) const override; void writeGotPlt(uint8_t *Buf, uint64_t Plt) const override; void writePltZero(uint8_t *Buf) const override; @@ -242,7 +242,8 @@ TargetInfo *createTarget() { TargetInfo::~TargetInfo() {} -uint64_t TargetInfo::getImplicitAddend(uint8_t *Buf, uint32_t Type) const { +uint64_t TargetInfo::getImplicitAddend(const uint8_t *Buf, + uint32_t Type) const { return 0; } @@ -521,7 +522,8 @@ bool X86TargetInfo::refersToGotEntry(uint32_t Type) const { return Type == R_386_GOT32; } -uint64_t X86TargetInfo::getImplicitAddend(uint8_t *Buf, uint32_t Type) const { +uint64_t X86TargetInfo::getImplicitAddend(const uint8_t *Buf, + uint32_t Type) const { switch (Type) { default: return 0; @@ -1639,7 +1641,7 @@ void MipsTargetInfo::writeGotPlt(uint8_t *Buf, uint64_t Plt) const { static uint16_t mipsHigh(uint64_t V) { return (V + 0x8000) >> 16; } template -static int64_t getPcRelocAddend(uint8_t *Loc) { +static int64_t getPcRelocAddend(const uint8_t *Loc) { uint32_t Instr = read32(Loc); uint32_t Mask = 0xffffffff >> (32 - BSIZE); return SignExtend64((Instr & Mask) << SHIFT); @@ -1669,7 +1671,7 @@ static void writeMipsLo16(uint8_t *Loc, uint64_t V) { write32(Loc, (Instr & 0xffff0000) | (V & 0xffff)); } -template static int16_t readSignedLo16(uint8_t *Loc) { +template static int16_t readSignedLo16(const uint8_t *Loc) { return SignExtend32<16>(read32(Loc) & 0xffff); } @@ -1764,7 +1766,7 @@ bool MipsTargetInfo::needsThunk(uint32_t Type, const InputFile &File, } template -uint64_t MipsTargetInfo::getImplicitAddend(uint8_t *Buf, +uint64_t MipsTargetInfo::getImplicitAddend(const uint8_t *Buf, uint32_t Type) const { const endianness E = ELFT::TargetEndianness; switch (Type) { diff --git a/lld/ELF/Target.h b/lld/ELF/Target.h index a6295111c9e6..b81db7d37b8d 100644 --- a/lld/ELF/Target.h +++ b/lld/ELF/Target.h @@ -32,7 +32,7 @@ public: virtual void writeGotHeader(uint8_t *Buf) const {} virtual void writeGotPltHeader(uint8_t *Buf) const {} virtual void writeGotPlt(uint8_t *Buf, uint64_t Plt) const {}; - virtual uint64_t getImplicitAddend(uint8_t *Buf, uint32_t Type) const; + virtual uint64_t getImplicitAddend(const uint8_t *Buf, uint32_t Type) const; // If lazy binding is supported, the first entry of the PLT has code // to call the dynamic linker to resolve PLT entries the first time