[Git][ghc/ghc][wip/haskell-nix-patches/musl64/ghc-9.6-missing-symbols-deadbeef] 2 commits: wrk: add guards for deadbeef
doyougnu (@doyougnu)
gitlab at gitlab.haskell.org
Wed Sep 11 17:10:51 UTC 2024
doyougnu pushed to branch wip/haskell-nix-patches/musl64/ghc-9.6-missing-symbols-deadbeef at Glasgow Haskell Compiler / GHC
Commits:
34807a34 by doyougnu at 2024-09-11T08:32:47-04:00
wrk: add guards for deadbeef
- - - - -
a0e8db32 by doyougnu at 2024-09-11T09:26:13-04:00
wrk: add rts option -link-unknown-symbol
- - - - -
5 changed files:
- libraries/ghc-internal/src/GHC/Internal/RTS/Flags.hsc
- rts/Linker.c
- rts/RtsFlags.c
- rts/include/rts/Flags.h
- rts/linker/elf_got.c
Changes:
=====================================
libraries/ghc-internal/src/GHC/Internal/RTS/Flags.hsc
=====================================
@@ -162,6 +162,7 @@ data MiscFlags = MiscFlags
, disableDelayedOsMemoryReturn :: Bool
, internalCounters :: Bool
, linkerAlwaysPic :: Bool
+ , linkUnknownSymbols :: Bool
, linkerMemBase :: Word
-- ^ address to ask the OS for memory for the linker, 0 ==> off
, ioManager :: IoManagerFlag
@@ -536,6 +537,8 @@ getMiscFlags = do
(#{peek MISC_FLAGS, internalCounters} ptr :: IO CBool))
<*> (toBool <$>
(#{peek MISC_FLAGS, linkerAlwaysPic} ptr :: IO CBool))
+ <*> (toBool <$>
+ (#{peek MISC_FLAGS, linkUnknownSymbols} ptr :: IO CBool))
<*> #{peek MISC_FLAGS, linkerMemBase} ptr
<*> (toEnum . fromIntegral
<$> (#{peek MISC_FLAGS, ioManager} ptr :: IO Word32))
=====================================
rts/Linker.c
=====================================
@@ -950,7 +950,13 @@ SymbolAddr* lookupSymbol( SymbolName* lbl )
"See top entry above.\n", lbl);
IF_DEBUG(linker, printLoadedObjects());
fflush(stderr);
- r = 0xDEADBEEF;
+
+ // if -link-unknown-symbols is passed into the RTS we allow the linker
+ // to optimistically continue
+ if (RtsFlags.MiscFlags.linkUnknownSymbols){
+ r = 0xDEADBEEF;
+ }
+
}
if (!runPendingInitializers()) {
=====================================
rts/RtsFlags.c
=====================================
@@ -269,6 +269,7 @@ void initRtsFlagsDefaults(void)
RtsFlags.MiscFlags.disableDelayedOsMemoryReturn = false;
RtsFlags.MiscFlags.internalCounters = false;
RtsFlags.MiscFlags.linkerAlwaysPic = DEFAULT_LINKER_ALWAYS_PIC;
+ RtsFlags.MiscFlags.linkUnknownSymbols = false;
RtsFlags.MiscFlags.linkerMemBase = 0;
RtsFlags.MiscFlags.ioManager = IO_MNGR_FLAG_AUTO;
#if defined(THREADED_RTS) && defined(mingw32_HOST_OS)
@@ -998,6 +999,11 @@ error = true;
OPTION_UNSAFE;
RtsFlags.MiscFlags.generate_dump_file = true;
}
+ else if (strequal("link-unknown-symbols",
+ &rts_argv[arg][2])) {
+ OPTION_UNSAFE;
+ RtsFlags.MiscFlags.linkUnknownSymbols = true;
+ }
else if (strequal("null-eventlog-writer",
&rts_argv[arg][2])) {
OPTION_UNSAFE;
=====================================
rts/include/rts/Flags.h
=====================================
@@ -267,6 +267,7 @@ typedef struct _MISC_FLAGS {
there as well. */
bool internalCounters; /* See Note [Internal Counters Stats] */
bool linkerAlwaysPic; /* Assume the object code is always PIC */
+ bool linkUnknownSymbols; /* Should the runtime linker optimistically continue */
StgWord linkerMemBase; /* address to ask the OS for memory
* for the linker, NULL ==> off */
IO_MANAGER_FLAG ioManager; /* The I/O manager to use. */
=====================================
rts/linker/elf_got.c
=====================================
@@ -99,8 +99,16 @@ fillGot(ObjectCode * oc) {
} else {
errorBelch("Failed to lookup symbol: %s\n",
symbol->name);
- // return EXIT_FAILURE;
- symbol->addr = 0xDEADBEEF;
+
+ // if -link-unknown-symbols is passed into the
+ // RTS we allow the linker to optimistically
+ // continue
+ if (RtsFlags.MiscFlags.linkUnknownSymbols) {
+ symbol->addr = 0xDEADBEEF;
+ } else {
+ return EXIT_FAILURE;
+ }
+
}
}
} else {
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ae64a31e00d266934b1656ffc39353cc1f78bbe7...a0e8db32f4e565b5336ec226b853fe3c68845779
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ae64a31e00d266934b1656ffc39353cc1f78bbe7...a0e8db32f4e565b5336ec226b853fe3c68845779
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20240911/8dd683e4/attachment-0001.html>
More information about the ghc-commits
mailing list