From 7e3624baf92d261768db5575bfdbb89e9d2d92dd Mon Sep 17 00:00:00 2001 From: sewardj Date: Thu, 23 Mar 2000 12:19:22 +0000 Subject: [PATCH] [project @ 2000-03-23 12:19:22 by sewardj] Allow clients of the linker library (object.[ch]) to specify, portably, symbols they wish to ignore in calls to ocGetNames(). Use this modification to support ignoring the multiple occurrences of ghc_cc_ID. --- ghc/interpreter/interface.c | 11 +++++++++-- ghc/interpreter/object.c | 44 +++++++++++++++++++++++++------------------ ghc/interpreter/object.h | 11 ++++++++--- 3 files changed, 43 insertions(+), 23 deletions(-) diff --git a/ghc/interpreter/interface.c b/ghc/interpreter/interface.c index 6912109..a03c691 100644 --- a/ghc/interpreter/interface.c +++ b/ghc/interpreter/interface.c @@ -7,8 +7,8 @@ * 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" @@ -1085,11 +1085,18 @@ static void* startGHCModule_clientLookup ( char* sym ) 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) { diff --git a/ghc/interpreter/object.c b/ghc/interpreter/object.c index fd05a5e..4da4e06 100644 --- a/ghc/interpreter/object.c +++ b/ghc/interpreter/object.c @@ -39,12 +39,13 @@ static int sortSymbols ( ObjectCode* 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; @@ -60,25 +61,26 @@ ObjectCode* ocNew ( void (*errMsg)(char*), 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; } @@ -212,7 +214,12 @@ static void* genericExpand ( void* tab, /* 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, @@ -273,7 +280,8 @@ static int sortSymbols ( ObjectCode* oc ) 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; } } diff --git a/ghc/interpreter/object.h b/ghc/interpreter/object.h index 83bdf3c..10f8be8 100644 --- a/ghc/interpreter/object.h +++ b/ghc/interpreter/object.h @@ -69,9 +69,13 @@ typedef 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; @@ -94,8 +98,9 @@ typedef /* 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 ); -- 1.7.10.4