2 /* --------------------------------------------------------------------------
3 * Machinery for dynamic loading and linking of object code. Should be
4 * completely independent from the rest of Hugs so we can use it in
5 * other applications if desired.
7 * The Hugs 98 system is Copyright (c) Mark P Jones, Alastair Reid, the
8 * Yale Haskell Group, and the Oregon Graduate Institute of Science and
9 * Technology, 1994-1999, All rights reserved. It is distributed as
10 * free software under the license in the file "License", which is
11 * included in the distribution.
13 * ------------------------------------------------------------------------*/
15 #ifndef __HUGS_OBJECT_H
16 #define __HUGS_OBJECT_H
18 /* An entry in a very crude object symbol table */
19 typedef struct { char* nm; void* ad; }
23 /* Indication of section kinds for loaded objects. Needed by
24 the GC for deciding whether or not a pointer on the stack
27 typedef enum { HUGS_SECTIONKIND_CODE_OR_RODATA,
28 HUGS_SECTIONKIND_RWDATA,
29 HUGS_SECTIONKIND_OTHER,
30 HUGS_SECTIONKIND_NOINFOAVAIL }
33 typedef struct { void* start; void* end; OSectionKind kind; }
37 /* Indication of the status of an ObjectCode structure.
38 NOTINUSE -- currently unused.
39 OIMAGE -- object image is in memory, but that's all.
40 VERIFIED -- OIMAGE + the loaded image has been verified as
42 HAVENAMES -- VERIFIED + names *defined* in this image have been
43 extracted from the image and placed in the oTab,
44 and also section info placed in sectionTab.
45 RESOLVED -- HAVENAMES + all names *used* in this image have
46 successfully been resolved.
49 typedef enum { OBJECT_NOTINUSE,
57 /* Top-level structure for an object module. One of these is allocated
58 for each object file in use. This should really be an abstract type
66 char* formatName; /* eg "ELF32", "DLL", "COFF", etc. */
68 /* proc to call to deliver an error message to the client. */
69 void (*errMsg)(char*);
71 /* proc to call to resolve symbols not defined in this module,
72 when asked to resolve symbols in this module */
73 void* (*clientLookup)(char*);
75 /* ptr to malloc'd lump of memory holding the obj file */
78 /* ptr to object symbol table; lives in mallocville.
79 Dynamically expands. */
84 /* The section-kind entries for this object module.
85 Dynamically expands. */
90 /* Allow a chain of these things */
91 struct __ObjectCode * next;
97 extern ObjectCode* ocNew ( void (*errMsg)(char*),
98 void* (*clientLookup)(char*),
102 extern int /*Bool*/ ocLoadImage ( ObjectCode* oc, int verb );
103 extern int /*Bool*/ ocVerifyImage ( ObjectCode* oc, int verb );
104 extern int /*Bool*/ ocGetNames ( ObjectCode* oc, int verb );
105 extern int /*Bool*/ ocResolve ( ObjectCode* oc, int verb );
106 extern void ocFree ( ObjectCode* oc );
108 extern void* ocLookupSym ( ObjectCode* oc, char* sym );
109 extern char* ocLookupAddr ( ObjectCode* oc, void* addr );
110 extern OSectionKind ocLookupSection ( ObjectCode* oc, void* addr );
114 /*-------------------------------------------------------------------------*/