[Git][ghc/ghc][master] fix windows bootstrap due to linker changes

Marge Bot gitlab at gitlab.haskell.org
Fri Jun 19 03:07:15 UTC 2020



 Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC


Commits:
da18ff99 by Tamar Christina at 2020-06-18T23:07:03-04:00
fix windows bootstrap due to linker changes

- - - - -


5 changed files:

- rts/Linker.c
- rts/LinkerInternals.h
- rts/PathUtils.h
- rts/linker/LoadArchive.c
- rts/linker/PEi386.c


Changes:

=====================================
rts/Linker.c
=====================================
@@ -339,7 +339,6 @@ int ghciInsertSymbolTable(
         return 1;
     }
 
-   pathchar* archiveName = NULL;
    debugBelch(
       "GHC runtime linker: fatal error: I found a duplicate definition for symbol\n"
       "   %s\n"
@@ -355,15 +354,10 @@ int ghciInsertSymbolTable(
       (char*)key,
       obj_name,
       pinfo->owner == NULL ? WSTR("(GHCi built-in symbols)") :
-      pinfo->owner->archiveMemberName ? archiveName = mkPath(pinfo->owner->archiveMemberName)
+      pinfo->owner->archiveMemberName ? pinfo->owner->archiveMemberName
       : pinfo->owner->fileName
    );
 
-   if (archiveName)
-   {
-       stgFree(archiveName);
-       archiveName = NULL;
-   }
    return 0;
 }
 
@@ -873,9 +867,9 @@ SymbolAddr* lookupSymbol_ (SymbolName* lbl)
  * Symbol name only used for diagnostics output.
  */
 SymbolAddr* loadSymbol(SymbolName *lbl, RtsSymbolInfo *pinfo) {
-    IF_DEBUG(linker, debugBelch("lookupSymbol: value of %s is %p, owned by %s\n", lbl,
+    IF_DEBUG(linker, debugBelch("lookupSymbol: value of %s is %p, owned by %" PATH_FMT "\n", lbl,
                                 pinfo->value,
-                                pinfo->owner ? OC_INFORMATIVE_FILENAME(pinfo->owner) : "No owner, probably built-in."));
+                                pinfo->owner ? OC_INFORMATIVE_FILENAME(pinfo->owner) : WSTR("No owner, probably built-in.")));
     ObjectCode* oc = pinfo->owner;
 
     /* Symbol can be found during linking, but hasn't been relocated. Do so now.
@@ -905,7 +899,7 @@ printLoadedObjects() {
     for (oc = objects; oc; oc = oc->next) {
         if (oc->sections != NULL) {
             int i;
-            printf("%s\n", OC_INFORMATIVE_FILENAME(oc));
+            printf("%" PATH_FMT "\n", OC_INFORMATIVE_FILENAME(oc));
             for (i=0; i < oc->n_sections; i++) {
                 if(oc->sections[i].mapped_start != NULL || oc->sections[i].start != NULL) {
                     printf("\tsec %2d[alloc: %d; kind: %d]: %p - %p; mmaped: %p - %p\n",
@@ -1299,7 +1293,7 @@ void freeObjectCode (ObjectCode *oc)
 
 ObjectCode*
 mkOc( pathchar *path, char *image, int imageSize,
-      bool mapped, char *archiveMemberName, int misalignment ) {
+      bool mapped, pathchar *archiveMemberName, int misalignment ) {
    ObjectCode* oc;
 
    IF_DEBUG(linker, debugBelch("mkOc: start\n"));
@@ -1322,9 +1316,9 @@ mkOc( pathchar *path, char *image, int imageSize,
    oc->fileName = pathdup(path);
 
    if (archiveMemberName) {
-       oc->archiveMemberName = stgMallocBytes( strlen(archiveMemberName)+1,
+       oc->archiveMemberName = stgMallocBytes( (pathlen(archiveMemberName)+1) * pathsize,
                                                "loadObj" );
-       strcpy(oc->archiveMemberName, archiveMemberName);
+       pathcopy(oc->archiveMemberName, archiveMemberName);
    } else {
        oc->archiveMemberName = NULL;
    }
@@ -1739,7 +1733,7 @@ static HsInt resolveObjs_ (void)
         r = ocTryLoad(oc);
         if (!r)
         {
-            errorBelch("Could not load Object Code %s.\n", OC_INFORMATIVE_FILENAME(oc));
+            errorBelch("Could not load Object Code %" PATH_FMT ".\n", OC_INFORMATIVE_FILENAME(oc));
             IF_DEBUG(linker, printLoadedObjects());
             fflush(stderr);
             return r;


=====================================
rts/LinkerInternals.h
=====================================
@@ -181,7 +181,7 @@ typedef struct _ObjectCode {
     /* If this object is a member of an archive, archiveMemberName is
      * like "libarchive.a(object.o)". Otherwise it's NULL.
      */
-    char*      archiveMemberName;
+    pathchar*      archiveMemberName;
 
     /* An array containing ptrs to all the symbol names copied from
        this object into the global symbol hash table.  This is so that
@@ -348,7 +348,7 @@ resolveSymbolAddr (pathchar* buffer, int size,
 HsInt isAlreadyLoaded( pathchar *path );
 HsInt loadOc( ObjectCode* oc );
 ObjectCode* mkOc( pathchar *path, char *image, int imageSize,
-                  bool mapped, char *archiveMemberName,
+                  bool mapped, pathchar *archiveMemberName,
                   int misalignment
                   );
 


=====================================
rts/PathUtils.h
=====================================
@@ -20,6 +20,7 @@
 #define open wopen
 #define WSTR(s) L##s
 #define pathprintf swprintf
+#define pathcopy wcscpy
 #define pathsize sizeof(wchar_t)
 #else
 #define pathcmp strcmp
@@ -30,6 +31,7 @@
 #define WSTR(s) s
 #define pathprintf snprintf
 #define pathsize sizeof(char)
+#define pathcopy strcpy
 #endif
 
 pathchar* pathdup(pathchar *path);


=====================================
rts/linker/LoadArchive.c
=====================================
@@ -483,7 +483,7 @@ static HsInt loadArchive_ (pathchar *path)
         DEBUG_LOG("\tisObject = %d\n", isObject);
 
         if (isObject) {
-            char *archiveMemberName;
+            pathchar *archiveMemberName;
 
             DEBUG_LOG("Member is an object file...loading...\n");
 
@@ -515,10 +515,11 @@ static HsInt loadArchive_ (pathchar *path)
                 }
             }
 
-            archiveMemberName = stgMallocBytes(pathlen(path) + thisFileNameSize + 3,
+            int size = pathlen(path) + thisFileNameSize + 3;
+            archiveMemberName = stgMallocBytes(size * pathsize,
                                                "loadArchive(file)");
-            sprintf(archiveMemberName, "%" PATH_FMT "(%.*s)",
-                    path, (int)thisFileNameSize, fileName);
+            pathprintf(archiveMemberName, size, WSTR("%" PATH_FMT "(%.*s)"),
+                       path, (int)thisFileNameSize, fileName);
 
             oc = mkOc(path, image, memberSize, false, archiveMemberName
                      , misalignment);


=====================================
rts/linker/PEi386.c
=====================================
@@ -1810,8 +1810,8 @@ makeSymbolExtra_PEi386( ObjectCode* oc, uint64_t index, size_t s, char* symbol )
     SymbolExtra *extra;
     curr_thunk = oc->first_symbol_extra + index;
     if (index >= oc->n_symbol_extras) {
-      IF_DEBUG(linker, debugBelch("makeSymbolExtra first:%d, num:%lu, member:%s, index:%llu\n", curr_thunk, oc->n_symbol_extras, oc->archiveMemberName, index));
-      barf("Can't allocate thunk for `%s' in `%" PATH_FMT "' with member `%s'", symbol, oc->fileName, oc->archiveMemberName);
+      IF_DEBUG(linker, debugBelch("makeSymbolExtra first:%d, num:%lu, member:%" PATH_FMT ", index:%llu\n", curr_thunk, oc->n_symbol_extras, oc->archiveMemberName, index));
+      barf("Can't allocate thunk for `%s' in `%" PATH_FMT "' with member `%" PATH_FMT "'", symbol, oc->fileName, oc->archiveMemberName);
     }
 
     extra = oc->symbol_extras + curr_thunk;
@@ -2177,9 +2177,7 @@ resolveSymbolAddr_PEi386 (pathchar* buffer, int size,
                   wcscat (buffer, WSTR(" "));
                   if (oc->archiveMemberName)
                   {
-                      pathchar* name = mkPath (oc->archiveMemberName);
-                      wcscat (buffer, name);
-                      stgFree (name);
+                      wcscat (buffer, oc->archiveMemberName);
                   }
                   else
                   {



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/da18ff9935e72c7fe6127cb5d5d0c53654a204b0

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/da18ff9935e72c7fe6127cb5d5d0c53654a204b0
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/20200618/eec4382f/attachment-0001.html>


More information about the ghc-commits mailing list