From 2df6419913b7f70ffbfa3004cb025520befe20d4 Mon Sep 17 00:00:00 2001 From: Ben Gamari Date: Sat, 22 Jan 2022 16:38:48 -0500 Subject: rts: Refuse to create jump islands for symbols with info tables When tables-next-to-code is enabled we must not relocate references to info-table symbols using jump islands. Fixes #20983. --- rts/LinkerInternals.h | 3 +++ rts/linker/PEi386.c | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/rts/LinkerInternals.h b/rts/LinkerInternals.h index 7058ad355b..cf78bd5e11 100644 --- a/rts/LinkerInternals.h +++ b/rts/LinkerInternals.h @@ -16,6 +16,9 @@ #include #endif +/* See Note [Refuse to generate jump islands for _info symbols] */ +void isTntcSymbol(const char *); + void printLoadedObjects(void); #include "BeginPrivate.h" diff --git a/rts/linker/PEi386.c b/rts/linker/PEi386.c index f186da0af8..8eb046a38e 100644 --- a/rts/linker/PEi386.c +++ b/rts/linker/PEi386.c @@ -1947,6 +1947,9 @@ ocResolve_PEi386 ( ObjectCode* oc ) // N.B. in the case of the sign-extended relocations we must ensure that v // fits in a signed 32-bit value. See #15808. if (((int64_t) v > (int64_t) INT32_MAX) || ((int64_t) v < (int64_t) INT32_MIN)) { + if (isTntcSymbol(symbol)) { + barf("Unable relocate symbol '%s' with info table as we would need to produce a jump island", symbol); + } copyName (getSymShortName (info, sym), oc, symbol, sizeof(symbol)-1); S = makeSymbolExtra_PEi386(oc, symIndex, S, (char *)symbol); @@ -1965,6 +1968,10 @@ ocResolve_PEi386 ( ObjectCode* oc ) intptr_t v; v = S + (int32_t)A - ((intptr_t)pP) - 4; if ((v > (int64_t) INT32_MAX) || (v < (int64_t) INT32_MIN)) { + if (isTntcSymbol(symbol)) { + barf("Unable relocate symbol '%s' with info table as we would need to produce a jump island", symbol); + } + /* Make the trampoline then */ copyName (getSymShortName (info, sym), oc, symbol, sizeof(symbol)-1); -- cgit v1.2.1