* Hugs version 1.4, December 1997
*
* $RCSfile: interface.c,v $
- * $Revision: 1.40 $
- * $Date: 2000/03/22 18:14:22 $
+ * $Revision: 1.41 $
+ * $Date: 2000/03/23 12:19:22 $
* ------------------------------------------------------------------------*/
#include "prelude.h"
return lookupObjName ( sym );
}
+static int /*Bool*/ startGHCModule_clientWantsSymbol ( char* sym )
+{
+ if (strcmp(sym,"ghc_cc_ID")==0) return 0;
+ return 1;
+}
+
static ObjectCode* startGHCModule_partial_load ( String objNm, Int objSz )
{
ObjectCode* oc
= ocNew ( startGHCModule_errMsg,
startGHCModule_clientLookup,
+ startGHCModule_clientWantsSymbol,
objNm, objSz );
if (!oc) {
* Arch-independent interface to the runtime linker
* ------------------------------------------------------------------------*/
-ObjectCode* ocNew ( void (*errMsg)(char*),
- void* (*clientLookup)(char*),
+ObjectCode* ocNew ( void (*errMsg)(char*),
+ void* (*clientLookup)(char*),
+ int (*clientWantsSymbol)(char*),
char* objFileName,
int objFileSize )
{
- ObjectCode* oc = malloc(sizeof(ObjectCode));
+ ObjectCode* oc = malloc(sizeof(ObjectCode));
if (!oc) {
errMsg("ocNew: can't allocate memory for object code record");
return NULL;
return NULL;
# endif
- oc->status = OBJECT_NOTINUSE;
- oc->objFileName = objFileName;
- oc->objFileSize = objFileSize;
- oc->errMsg = errMsg;
- oc->clientLookup = clientLookup;
+ oc->status = OBJECT_NOTINUSE;
+ oc->objFileName = objFileName;
+ oc->objFileSize = objFileSize;
+ oc->errMsg = errMsg;
+ oc->clientLookup = clientLookup;
+ oc->clientWantsSymbol = clientWantsSymbol;
- oc->oImage = malloc ( objFileSize );
+ oc->oImage = malloc ( objFileSize );
if (!oc->oImage) {
free(oc);
errMsg("ocNew: can't allocate memory for object code");
return NULL;
}
- oc->oTab = NULL;
- oc->sizeoTab = 0;
- oc->usedoTab = 0;
- oc->sectionTab = NULL;
- oc->sizesectionTab = 0;
- oc->usedsectionTab = 0;
- oc->next = NULL;
+ oc->oTab = NULL;
+ oc->sizeoTab = 0;
+ oc->usedoTab = 0;
+ oc->sectionTab = NULL;
+ oc->sizesectionTab = 0;
+ oc->usedsectionTab = 0;
+ oc->next = NULL;
return oc;
}
/* returns 1 if success, 0 if error */
static int addSymbol ( ObjectCode* oc, char* nm, void* ad )
{
- OSym* newTab
+ OSym* newTab;
+
+ if (oc->clientWantsSymbol && !oc->clientWantsSymbol(nm))
+ return 1;
+
+ newTab
= genericExpand ( oc->oTab,
&(oc->sizeoTab),
oc->usedoTab,
return 0;
}
if (j == 0) {
- oc->errMsg("sortSymbols: duplicate symbols in object file");
+ oc->errMsg("sortSymbols: duplicate symbols in object file:");
+ oc->errMsg(oc->oTab[i].nm);
return 0;
}
}
void (*errMsg)(char*);
/* proc to call to resolve symbols not defined in this module,
- when asked to resolve symbols in this module */
+ when asked to resolve symbols in this module (in ocResolve) */
void* (*clientLookup)(char*);
+ /* proc used during ocGetNames to ask client if it wants to
+ acquire a given symbol from the obj file. */
+ int (*clientWantsSymbol)(char*);
+
/* ptr to malloc'd lump of memory holding the obj file */
void* oImage;
/* The API */
-extern ObjectCode* ocNew ( void (*errMsg)(char*),
- void* (*clientLookup)(char*),
+extern ObjectCode* ocNew ( void (*errMsg)(char*),
+ void* (*clientLookup)(char*),
+ int (*clientWantsSymbol)(char*),
char* objFileName,
int objFileSize );