[lld] r293683 - Check R_386_{PC,}{8,16} for overflow.
Rafael Avila de Espindola via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 31 12:47:06 PST 2017
Thanks!
Rui Ueyama via llvm-commits <llvm-commits at lists.llvm.org> writes:
> Author: ruiu
> Date: Tue Jan 31 14:28:32 2017
> New Revision: 293683
>
> URL: http://llvm.org/viewvc/llvm-project?rev=293683&view=rev
> Log:
> Check R_386_{PC,}{8,16} for overflow.
>
> It is not clear what we should do when overflow occurs for these
> relocations because the relocations are not an official part of
> the i386 psABI. But checking for overflow is generally a good to do
> and is consistent with other relocations such as R_X86_64_8.
>
> 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=293683&r1=293682&r2=293683&view=diff
> ==============================================================================
> --- lld/trunk/ELF/Target.cpp (original)
> +++ lld/trunk/ELF/Target.cpp Tue Jan 31 14:28:32 2017
> @@ -512,17 +512,24 @@ uint64_t X86TargetInfo::getImplicitAdden
>
> void X86TargetInfo::relocateOne(uint8_t *Loc, uint32_t Type,
> uint64_t Val) const {
> - checkInt<32>(Loc, Val, Type);
> -
> // R_386_{PC,}{8,16} are not part of the i386 psABI, but they are
> // being used for some 16-bit programs such as boot loaders, so
> // we want to support them.
> - if (Type == R_386_8 || Type == R_386_PC8)
> + switch (Type) {
> + case R_386_8:
> + case R_386_PC8:
> + checkInt<8>(Loc, Val, Type);
> *Loc = Val;
> - else if (Type == R_386_16 || Type == R_386_PC16)
> + break;
> + case R_386_16:
> + case R_386_PC16:
> + checkInt<16>(Loc, Val, Type);
> write16le(Loc, Val);
> - else
> + break;
> + default:
> + checkInt<32>(Loc, Val, Type);
> write32le(Loc, Val);
> + }
> }
>
> void X86TargetInfo::relaxTlsGdToLe(uint8_t *Loc, uint32_t Type,
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list