1
0
mirror of https://github.com/upx/upx synced 2025-10-05 19:20:23 +08:00

fixed 8 bit range checking in ElfLinkerAMD64::relocate1

This commit is contained in:
László Molnár 2013-08-28 22:31:40 +02:00
parent 9da09b51ed
commit bce7af4e11

View File

@ -625,10 +625,12 @@ void ElfLinkerAMD64::relocate1(const Relocation *rel, upx_byte *location,
return super::relocate1(rel, location, value, type);
type += 9;
bool range_check = false;
if (strncmp(type, "PC", 2) == 0)
{
value -= rel->section->offset + rel->offset;
type += 2;
range_check = true;
}
if (strcmp(type, "8") == 0)
@ -638,7 +640,7 @@ void ElfLinkerAMD64::relocate1(const Relocation *rel, upx_byte *location,
#else
int displ = (signed char) *location + (int) value;
#endif
if (displ < -128 || displ > 127)
if (range_check && (displ < -128 || displ > 127))
internal_error("target out of range (%d) in reloc %s:%x\n",
displ, rel->section->name, rel->offset);
*location += value;