pe: ignore duplicated relocation records
This commit is contained in:
+21
-2
@@ -505,12 +505,31 @@ void PackArmPe::processRelocs() // pass1
|
||||
{
|
||||
if (pos >= ih.imagesize)
|
||||
continue; // skip out-of-bounds record
|
||||
if (type == 3)
|
||||
set_le32(ibuf + pos,get_le32(ibuf + pos) - ih.imagebase - rvamin);
|
||||
if (type < 4)
|
||||
fix[type][xcounts[type]++] = pos - rvamin;
|
||||
}
|
||||
|
||||
// remove duplicated records
|
||||
for (ic = 1; ic <= 3; ic++)
|
||||
{
|
||||
qsort(fix[ic], xcounts[ic], 4, le32_compare);
|
||||
unsigned prev = ~0;
|
||||
unsigned jc = 0;
|
||||
for (unsigned kc = 0; kc < xcounts[ic]; kc++)
|
||||
if (fix[ic][kc] != prev)
|
||||
prev = fix[ic][jc++] = fix[ic][kc];
|
||||
|
||||
//printf("xcounts[%u] %u->%u\n", ic, xcounts[ic], jc);
|
||||
xcounts[ic] = jc;
|
||||
}
|
||||
|
||||
// preprocess "type 3" relocation records
|
||||
for (ic = 0; ic < xcounts[3]; ic++)
|
||||
{
|
||||
pos = fix[3][ic] + rvamin;
|
||||
set_le32(ibuf + pos, get_le32(ibuf + pos) - ih.imagebase - rvamin);
|
||||
}
|
||||
|
||||
ibuf.fill(IDADDR(PEDIR_RELOC), IDSIZE(PEDIR_RELOC), FILLVAL);
|
||||
orelocs = new upx_byte [rnum * 4 + 1024]; // 1024 - safety
|
||||
sorelocs = ptr_diff(optimizeReloc32((upx_byte*) fix[3], xcounts[3],
|
||||
|
||||
Reference in New Issue
Block a user