[GHC] #13617: GHCI Linker incorrectly handles the R_X86_64_PC32 relocation
GHC
ghc-devs at haskell.org
Sun Jul 9 11:52:18 UTC 2017
#13617: GHCI Linker incorrectly handles the R_X86_64_PC32 relocation
--------------------------------+----------------------------------------
Reporter: RyanGlScott | Owner: Phyx-
Type: bug | Status: new
Priority: normal | Milestone:
Component: GHCi | Version: 8.0.2
Resolution: | Keywords:
Operating System: Windows | Architecture: Unknown/Multiple
Type of failure: GHCi crash | Test Case:
Blocked By: | Blocking:
Related Tickets: #7134 | Differential Rev(s):
Wiki Page: |
--------------------------------+----------------------------------------
Comment (by Phyx-):
It seems the code for `R_X86_64_PC32` does already make a trampoline,
but only when the address is more than `32-bits` away:
{{{
case 4: /* R_X86_64_PC32 (ELF constant 2) -
IMAGE_REL_AMD64_REL32 (PE constant 4) */
{
intptr_t v;
v = ((intptr_t)S) + ((intptr_t)(int32_t)A) -
((intptr_t)pP) - 4;
if ((v >> 32) && ((-v) >> 32)) {
/* Make the trampoline then */
copyName ( getSymShortName (info, sym), strtab,
symbol, 1000-1 );
S = makeSymbolExtra_PEi386(oc, symIndex, S, (char
*)symbol);
/* And retry */
v = ((intptr_t)S) + ((intptr_t)(int32_t)A) -
((intptr_t)pP) - 4;
if ((v >> 32) && ((-v) >> 32)) {
barf("IMAGE_REL_AMD64_REL32: High bits are set
in %zx for %s",
v, (char *)symbol);
}
}
*(uint32_t *)pP = (uint32_t)v;
break;
}
}}}
Which explains why it doesn't always segfault..
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13617#comment:3>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list