[project @ 2001-02-11 17:51:07 by simonmar]
[ghc-hetmet.git] / ghc / rts / LinkerInternals.h
1 /* -----------------------------------------------------------------------------
2  * $Id: LinkerInternals.h,v 1.1 2001/02/11 17:51:07 simonmar Exp $
3  *
4  * (c) The GHC Team, 2000
5  *
6  * RTS Object Linker
7  *
8  * ---------------------------------------------------------------------------*/
9
10 /* A bucket in the symbol hash-table.  Primarily, maps symbol names to
11  * absolute addresses.  All symbols from a given module are linked
12  * together, so they can be freed at the same time.  There's also a
13  * bucket link field for the hash table.
14  */
15 typedef struct _SymbolVal {
16     char   *lbl;
17     void   *addr;
18 } SymbolVal;
19
20 typedef enum { OBJECT_LOADED, OBJECT_RESOLVED } OStatus;
21
22 /* Indication of section kinds for loaded objects.  Needed by
23    the GC for deciding whether or not a pointer on the stack
24    is a code pointer.
25 */
26 typedef enum { SECTIONKIND_CODE_OR_RODATA,
27                SECTIONKIND_RWDATA,
28                SECTIONKIND_OTHER,
29                SECTIONKIND_NOINFOAVAIL } 
30    SectionKind;
31
32 typedef struct { void* start; void* end; SectionKind kind; } 
33    Section;
34
35 /* Top-level structure for an object module.  One of these is allocated
36  * for each object file in use.
37  */
38 typedef struct _ObjectCode {
39     OStatus   status;
40     char*     fileName;
41     int       fileSize;
42     char*     formatName;            /* eg "ELF32", "DLL", "COFF", etc. */
43
44     SymbolVal *symbols;
45     int       n_symbols;
46
47     /* ptr to malloc'd lump of memory holding the obj file */
48     void*     image;
49
50     /* The section-kind entries for this object module.  Dynamically expands. */
51     Section*  sections;
52     int       n_sections;
53     
54     /* Allow a chain of these things */
55     struct _ObjectCode * next;
56 } ObjectCode;
57
58 extern ObjectCode *objects;