summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTamar Christina <tamar@zhox.com>2020-06-17 11:00:49 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-06-18 23:07:03 -0400
commitda18ff9935e72c7fe6127cb5d5d0c53654a204b0 (patch)
tree5f6e9e49a5df9783c4c6c30aaa4372387325bfef
parent08c1cb0f30770acbf366423f085f8ef92f7f6a06 (diff)
downloadhaskell-da18ff9935e72c7fe6127cb5d5d0c53654a204b0.tar.gz
fix windows bootstrap due to linker changes
-rw-r--r--rts/Linker.c22
-rw-r--r--rts/LinkerInternals.h4
-rw-r--r--rts/PathUtils.h2
-rw-r--r--rts/linker/LoadArchive.c9
-rw-r--r--rts/linker/PEi386.c8
5 files changed, 20 insertions, 25 deletions
diff --git a/rts/Linker.c b/rts/Linker.c
index fc5d1cb462..3e8847d8fc 100644
--- a/rts/Linker.c
+++ b/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;
diff --git a/rts/LinkerInternals.h b/rts/LinkerInternals.h
index 8a2aaee354..e1846b7a39 100644
--- a/rts/LinkerInternals.h
+++ b/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
);
diff --git a/rts/PathUtils.h b/rts/PathUtils.h
index 0b35b214e0..b1746f8769 100644
--- a/rts/PathUtils.h
+++ b/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);
diff --git a/rts/linker/LoadArchive.c b/rts/linker/LoadArchive.c
index 709c2fb792..f77ff43ce3 100644
--- a/rts/linker/LoadArchive.c
+++ b/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);
diff --git a/rts/linker/PEi386.c b/rts/linker/PEi386.c
index 9392db93e1..f494eee567 100644
--- a/rts/linker/PEi386.c
+++ b/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
{