[commit: ghc] master: Shuffle declarations into LinkerInternals.h (c3446c6)

git at git.haskell.org git at git.haskell.org
Wed Nov 2 20:15:15 UTC 2016


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/c3446c63d64bdc5c2fa627f345c59e893ba0c176/ghc

>---------------------------------------------------------------

commit c3446c63d64bdc5c2fa627f345c59e893ba0c176
Author: Ben Gamari <bgamari.foss at gmail.com>
Date:   Wed Nov 2 15:01:27 2016 -0400

    Shuffle declarations into LinkerInternals.h
    
    Summary: These will be needed across source files shortly.
    
    Test Plan: Validate
    
    Reviewers: erikd, austin, simonmar
    
    Reviewed By: simonmar
    
    Subscribers: thomie
    
    Differential Revision: https://phabricator.haskell.org/D2647


>---------------------------------------------------------------

c3446c63d64bdc5c2fa627f345c59e893ba0c176
 rts/Linker.c          | 31 ++++---------------------------
 rts/LinkerInternals.h | 32 ++++++++++++++++++++++++++++++++
 rts/RtsSymbols.h      |  4 +---
 3 files changed, 37 insertions(+), 30 deletions(-)

diff --git a/rts/Linker.c b/rts/Linker.c
index 8147ed8..d735889 100644
--- a/rts/Linker.c
+++ b/rts/Linker.c
@@ -91,24 +91,6 @@
 #include <sys/tls.h>
 #endif
 
-/* SymbolInfo tracks a symbol's address, the object code from which
-   it originated, and whether or not it's weak.
-
-   RtsSymbolInfo is used to track the state of the symbols currently
-   loaded or to be loaded by the Linker.
-
-   Where the information in the `ObjectCode` is used to track the
-   original status of the symbol inside the `ObjectCode`.
-
-   A weak symbol that has been used will still be marked as weak
-   in the `ObjectCode` but in the `RtsSymbolInfo` it won't be.
-*/
-typedef struct _RtsSymbolInfo {
-    SymbolAddr* value;
-    ObjectCode *owner;
-    HsBool weak;
-} RtsSymbolInfo;
-
 /* `symhash` is a Hash table mapping symbol names to RtsSymbolInfo.
    This hashtable will contain information on all symbols
    that we know of, however the .o they are in may not be loaded.
@@ -206,9 +188,6 @@ Mutex linker_mutex;
 Mutex linker_unloaded_mutex;
 #endif
 
-/* Type of the initializer */
-typedef void (*init_t) (int argc, char **argv, char **env);
-
 static HsInt isAlreadyLoaded( pathchar *path );
 static HsInt loadOc( ObjectCode* oc );
 static ObjectCode* mkOc( pathchar *path, char *image, int imageSize,
@@ -307,8 +286,6 @@ typedef DLL_DIRECTORY_COOKIE(WINAPI *LPAddDLLDirectory)(PCWSTR NewDirectory);
 typedef WINBOOL(WINAPI *LPRemoveDLLDirectory)(DLL_DIRECTORY_COOKIE Cookie);
 #endif /* OBJFORMAT_PEi386 */
 
-static void freeProddableBlocks (ObjectCode *oc);
-
 /* on x86_64 we have a problem with relocating symbol references in
  * code that was compiled without -fPIC.  By default, the small memory
  * model is used, which assumes that symbol references can fit in a
@@ -2606,7 +2583,7 @@ HsInt purgeObj (pathchar *path)
  * which may be prodded during relocation, and abort if we try and write
  * outside any of these.
  */
-static void
+void
 addProddableBlock ( ObjectCode* oc, void* start, int size )
 {
    ProddableBlock* pb
@@ -2620,7 +2597,7 @@ addProddableBlock ( ObjectCode* oc, void* start, int size )
    oc->proddables = pb;
 }
 
-static void
+void
 checkProddableBlock (ObjectCode *oc, void *addr, size_t size )
 {
    ProddableBlock* pb;
@@ -2634,7 +2611,7 @@ checkProddableBlock (ObjectCode *oc, void *addr, size_t size )
    barf("checkProddableBlock: invalid fixup in runtime linker: %p", addr);
 }
 
-static void freeProddableBlocks (ObjectCode *oc)
+void freeProddableBlocks (ObjectCode *oc)
 {
     ProddableBlock *pb, *next;
 
@@ -2648,7 +2625,7 @@ static void freeProddableBlocks (ObjectCode *oc)
 /* -----------------------------------------------------------------------------
  * Section management.
  */
-static void
+void
 addSection (Section *s, SectionKind kind, SectionAlloc alloc,
             void* start, StgWord size, StgWord mapped_offset,
             void* mapped_start, StgWord mapped_size)
diff --git a/rts/LinkerInternals.h b/rts/LinkerInternals.h
index 2fe9ff9..1d5288b 100644
--- a/rts/LinkerInternals.h
+++ b/rts/LinkerInternals.h
@@ -14,6 +14,9 @@
 
 #include "BeginPrivate.h"
 
+typedef void SymbolAddr;
+typedef char SymbolName;
+
 /* See Linker.c Note [runtime-linker-phases] */
 typedef enum {
     OBJECT_LOADED,
@@ -182,12 +185,41 @@ extern Mutex linker_mutex;
 extern Mutex linker_unloaded_mutex;
 #endif
 
+/* Type of the initializer */
+typedef void (*init_t) (int argc, char **argv, char **env);
+
+/* SymbolInfo tracks a symbol's address, the object code from which
+   it originated, and whether or not it's weak.
+
+   RtsSymbolInfo is used to track the state of the symbols currently
+   loaded or to be loaded by the Linker.
+
+   Where the information in the `ObjectCode` is used to track the
+   original status of the symbol inside the `ObjectCode`.
+
+   A weak symbol that has been used will still be marked as weak
+   in the `ObjectCode` but in the `RtsSymbolInfo` it won't be.
+*/
+typedef struct _RtsSymbolInfo {
+    SymbolAddr* value;
+    ObjectCode *owner;
+    HsBool weak;
+} RtsSymbolInfo;
+
 void exitLinker( void );
 
 void freeObjectCode (ObjectCode *oc);
 
 void *mmapForLinker (size_t bytes, uint32_t flags, int fd, int offset);
 
+void addProddableBlock ( ObjectCode* oc, void* start, int size );
+void checkProddableBlock (ObjectCode *oc, void *addr, size_t size );
+void freeProddableBlocks (ObjectCode *oc);
+
+void addSection (Section *s, SectionKind kind, SectionAlloc alloc,
+                 void* start, StgWord size, StgWord mapped_offset,
+                 void* mapped_start, StgWord mapped_size);
+
 #if defined(mingw32_HOST_OS)
 
 typedef unsigned char          UChar;
diff --git a/rts/RtsSymbols.h b/rts/RtsSymbols.h
index b820163..dab2373 100644
--- a/rts/RtsSymbols.h
+++ b/rts/RtsSymbols.h
@@ -10,6 +10,7 @@
 #define RTS_SYMBOLS_H
 
 #include "ghcautoconf.h"
+#include "LinkerInternals.h"
 
 #ifdef LEADING_UNDERSCORE
 #define MAYBE_LEADING_UNDERSCORE_STR(s) ("_" s)
@@ -17,9 +18,6 @@
 #define MAYBE_LEADING_UNDERSCORE_STR(s) (s)
 #endif
 
-typedef char SymbolName;
-typedef void SymbolAddr;
-
 typedef struct _RtsSymbolVal {
     const SymbolName* lbl;
     SymbolAddr* addr;



More information about the ghc-commits mailing list