[lld] r248844 - ELF2: Do not create ArrayRefs and use const arrays instead. NFC.
Rafael EspĂndola via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 30 09:57:08 PDT 2015
Thanks!
On Sep 29, 2015 7:02 PM, "Rui Ueyama via llvm-commits" <
llvm-commits at lists.llvm.org> wrote:
> Author: ruiu
> Date: Tue Sep 29 18:00:47 2015
> New Revision: 248844
>
> URL: http://llvm.org/viewvc/llvm-project?rev=248844&view=rev
> Log:
> ELF2: Do not create ArrayRefs and use const arrays instead. NFC.
>
> 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=248844&r1=248843&r2=248844&view=diff
>
> ==============================================================================
> --- lld/trunk/ELF/Target.cpp (original)
> +++ lld/trunk/ELF/Target.cpp Tue Sep 29 18:00:47 2015
> @@ -37,16 +37,11 @@ X86TargetInfo::X86TargetInfo() {
>
> void X86TargetInfo::writePltEntry(uint8_t *Buf, uint64_t GotEntryAddr,
> uint64_t PltEntryAddr) const {
> - ArrayRef<uint8_t> Jmp = {0xff, 0x25}; // jmpl *val
> - memcpy(Buf, Jmp.data(), Jmp.size());
> - Buf += Jmp.size();
> -
> + // jmpl *val; nop; nop
> + const uint8_t Inst[] = {0xff, 0x25, 0, 0, 0, 0, 0x90, 0x90};
> + memcpy(Buf, Inst, sizeof(Inst));
> assert(isUInt<32>(GotEntryAddr));
> - write32le(Buf, GotEntryAddr);
> - Buf += 4;
> -
> - ArrayRef<uint8_t> Nops = {0x90, 0x90};
> - memcpy(Buf, Nops.data(), Nops.size());
> + write32le(Buf + 2, GotEntryAddr);
> }
>
> bool X86TargetInfo::relocNeedsGot(uint32_t Type) const {
> @@ -107,18 +102,14 @@ X86_64TargetInfo::X86_64TargetInfo() {
>
> void X86_64TargetInfo::writePltEntry(uint8_t *Buf, uint64_t GotEntryAddr,
> uint64_t PltEntryAddr) const {
> - ArrayRef<uint8_t> Jmp = {0xff, 0x25}; // jmpq *val(%rip)
> - memcpy(Buf, Jmp.data(), Jmp.size());
> - Buf += Jmp.size();
> + // jmpq *val(%rip); nop; nop
> + const uint8_t Inst[] = {0xff, 0x25, 0, 0, 0, 0, 0x90, 0x90};
> + memcpy(Buf, Inst, sizeof(Inst));
>
> uintptr_t NextPC = PltEntryAddr + 6;
> intptr_t Delta = GotEntryAddr - NextPC;
> assert(isInt<32>(Delta));
> - write32le(Buf, Delta);
> - Buf += 4;
> -
> - ArrayRef<uint8_t> Nops = {0x90, 0x90};
> - memcpy(Buf, Nops.data(), Nops.size());
> + write32le(Buf + 2, Delta);
> }
>
> bool X86_64TargetInfo::relocNeedsGot(uint32_t Type) const {
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150930/e3ee3d6f/attachment.html>
More information about the llvm-commits
mailing list