Only PC-relative relocations get range checked.

This commit is contained in:
John Reiser 2006-08-21 14:26:08 -07:00
parent 0ac2971fc1
commit c8d54b324b

View File

@ -634,17 +634,18 @@ void ElfLinkerX86::relocate1(const Relocation *rel, upx_byte *location,
return super::relocate1(rel, location, value, type); return super::relocate1(rel, location, value, type);
type += 6; type += 6;
int range_check = 0;
if (strncmp(type, "PC", 2) == 0) if (strncmp(type, "PC", 2) == 0)
{ {
value -= rel->section->offset + rel->offset; value -= rel->section->offset + rel->offset;
type += 2; type += 2;
range_check = 1;
} }
if (strcmp(type, "8") == 0) if (strcmp(type, "8") == 0)
{ {
int displ = (signed char) *location + (int) value; int displ = (signed char) *location + (int) value;
if (displ < -127 || displ > 128) if (range_check && (displ < -127 || displ > 128)) {
{
printf("target out of range (%d) in reloc %s:%x\n", printf("target out of range (%d) in reloc %s:%x\n",
displ, rel->section->name, rel->offset); displ, rel->section->name, rel->offset);
abort(); abort();