summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Klebinger <klebinger.andreas@gmx.at>2019-09-04 15:34:09 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-09-24 21:08:42 -0400
commited520678404ade3b5886be3f3c41a4bf41cf231d (patch)
tree4f84592663380016464cda78b7995bc1b2069075
parentb2d475362b0a3d4bc8411835494a6899a8b40f4c (diff)
downloadhaskell-ed520678404ade3b5886be3f3c41a4bf41cf231d.tar.gz
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.
-rw-r--r--rts/linker/PEi386.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/rts/linker/PEi386.c b/rts/linker/PEi386.c
index 6cf0d52d39..f2c49f6513 100644
--- a/rts/linker/PEi386.c
+++ b/rts/linker/PEi386.c
@@ -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);
}