Commit abfbdff2 authored by Andreas Klebinger's avatar Andreas Klebinger Committed by Ben Gamari

Fix bounds check in ocResolve_PEi386 for relocation values.

The old test was wrong at least for gcc and the value -2287728808L.

It also relied on implementation defined behaviour (right shift
on a negative value), which might or might not be ok.
Either way it's now a simple comparison which will always work.
parent 7915afc6
......@@ -1961,14 +1961,14 @@ ocResolve_PEi386 ( ObjectCode* oc )
{
intptr_t v;
v = S + (int32_t)A - ((intptr_t)pP) - 4;
if ((v >> 32) && ((-v) >> 32)) {
if ((v > (intptr_t) INT32_MAX) || (v < (intptr_t) INT32_MIN)) {
/* Make the trampoline then */
copyName (getSymShortName (info, sym),
oc, symbol, sizeof(symbol)-1);
S = makeSymbolExtra_PEi386(oc, symIndex, S, (char *)symbol);
/* And retry */
v = S + (int32_t)A - ((intptr_t)pP) - 4;
if ((v >> 32) && ((-v) >> 32)) {
if ((v > (intptr_t) INT32_MAX) || (v < (intptr_t) INT32_MIN)) {
barf("IMAGE_REL_AMD64_REL32: High bits are set in %zx for %s",
v, (char *)symbol);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment