ElfLinker: rela support added
This commit is contained in:
parent
b7bbd81dda
commit
d35211328e
@ -426,9 +426,16 @@ void ElfLinker::preprocessRelocations(char *start, const char *end)
|
|||||||
char *t = strstr(start, type);
|
char *t = strstr(start, type);
|
||||||
t[strlen(type)] = 0;
|
t[strlen(type)] = 0;
|
||||||
|
|
||||||
|
unsigned add = 0;
|
||||||
|
if (char *p = strstr(symbol, "+0x"))
|
||||||
|
{
|
||||||
|
*p = 0;
|
||||||
|
sscanf(p + 3, "%x", &add);
|
||||||
|
}
|
||||||
|
|
||||||
assert(nrelocations < TABLESIZE(relocations));
|
assert(nrelocations < TABLESIZE(relocations));
|
||||||
relocations[nrelocations++] = Relocation(section, offset, t,
|
relocations[nrelocations++] = Relocation(section, offset, t,
|
||||||
findSymbol(symbol));
|
findSymbol(symbol), add);
|
||||||
|
|
||||||
//printf("relocation %s %x preprocessed\n", section->name, offset);
|
//printf("relocation %s %x preprocessed\n", section->name, offset);
|
||||||
}
|
}
|
||||||
@ -607,7 +614,8 @@ void ElfLinker::relocate()
|
|||||||
printf("undefined symbol '%s' referenced\n", rel->value->name);
|
printf("undefined symbol '%s' referenced\n", rel->value->name);
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
unsigned value = rel->value->section->offset + rel->value->offset;
|
unsigned value = rel->value->section->offset +
|
||||||
|
rel->value->offset + rel->add;
|
||||||
upx_byte *location = rel->section->output + rel->offset;
|
upx_byte *location = rel->section->output + rel->offset;
|
||||||
|
|
||||||
relocate1(rel, location, value, rel->type);
|
relocate1(rel, location, value, rel->type);
|
||||||
|
|||||||
@ -189,10 +189,12 @@ protected:
|
|||||||
unsigned offset;
|
unsigned offset;
|
||||||
const char *type;
|
const char *type;
|
||||||
Symbol *value;
|
Symbol *value;
|
||||||
|
unsigned add; // used in .rela relocations
|
||||||
|
|
||||||
Relocation(){}
|
Relocation(){}
|
||||||
Relocation(Section *s, unsigned o, const char *t, Symbol *v) :
|
Relocation(Section *s, unsigned o, const char *t,
|
||||||
section(s), offset(o), type(t), value(v)
|
Symbol *v, unsigned a) :
|
||||||
|
section(s), offset(o), type(t), value(v), add(a)
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user