diff options
author | Ben Gamari <ben@smart-cactus.org> | 2020-09-09 15:39:59 -0400 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2020-09-18 15:56:25 -0400 |
commit | c492134912e5270180881b7345ee86dc32756bdd (patch) | |
tree | 00e738e307bb6ad44b1c52d70374d29cebd86712 /includes | |
parent | 0799b3de3e3462224bddc0e4b6a3156d04a06361 (diff) | |
download | haskell-c492134912e5270180881b7345ee86dc32756bdd.tar.gz |
rts: Refactor foreign export tracking
This avoids calling `libc` in the initializers which are responsible for
registering foreign exports. We believe this should avoid the corruption
observed in #18548.
See Note [Tracking foreign exports] in rts/ForeignExports.c for an
overview of the new scheme.
Diffstat (limited to 'includes')
-rw-r--r-- | includes/Rts.h | 3 | ||||
-rw-r--r-- | includes/rts/ForeignExports.h | 36 |
2 files changed, 39 insertions, 0 deletions
diff --git a/includes/Rts.h b/includes/Rts.h index 989394b590..589ef8b82c 100644 --- a/includes/Rts.h +++ b/includes/Rts.h @@ -212,6 +212,9 @@ void _assertFail(const char *filename, unsigned int linenum) #include "rts/storage/GC.h" #include "rts/NonMoving.h" +/* Foreign exports */ +#include "rts/ForeignExports.h" + /* Other RTS external APIs */ #include "rts/Parallel.h" #include "rts/Signals.h" diff --git a/includes/rts/ForeignExports.h b/includes/rts/ForeignExports.h new file mode 100644 index 0000000000..f8828e59d4 --- /dev/null +++ b/includes/rts/ForeignExports.h @@ -0,0 +1,36 @@ +/* ----------------------------------------------------------------------------- + * + * (c) The GHC Team, 1995-2009 + * + * Interface to the RTS's foreign export tracking code. + * + * Do not #include this file directly: #include "Rts.h" instead. + * + * To understand the structure of the RTS headers, see the wiki: + * https://gitlab.haskell.org/ghc/ghc/wikis/commentary/source-tree/includes + * + * ---------------------------------------------------------------------------*/ + +#pragma once + +struct _ObjectCode; + +/* N.B. See Note [Tracking foreign exports] in + * rts/ForeignExports.c. */ +struct ForeignExportsList { + /* a link field for linking these together into lists. + */ + struct ForeignExportsList *next; + /* the length of ->exports */ + int n_entries; + /* if the RTS linker loaded the module, + * to which ObjectCode these exports belong. */ + struct _ObjectCode *oc; + /* if the RTS linker loaded the module, + * this points to an array of length ->n_entries + * recording the StablePtr for each export. */ + StgPtr exports[]; +}; + +void registerForeignExports(struct ForeignExportsList *exports); + |