[project @ 2001-08-29 15:12:21 by sewardj]
[ghc-hetmet.git] / ghc / rts / LinkerInternals.h
1 /* -----------------------------------------------------------------------------
2  * $Id: LinkerInternals.h,v 1.4 2001/08/29 15:12:21 sewardj Exp $
3  *
4  * (c) The GHC Team, 2000
5  *
6  * RTS Object Linker
7  *
8  * ---------------------------------------------------------------------------*/
9
10 typedef enum { OBJECT_LOADED, OBJECT_RESOLVED } OStatus;
11
12 /* Indication of section kinds for loaded objects.  Needed by
13    the GC for deciding whether or not a pointer on the stack
14    is a code pointer.
15 */
16 typedef enum { SECTIONKIND_CODE_OR_RODATA,
17                SECTIONKIND_RWDATA,
18                SECTIONKIND_OTHER,
19                SECTIONKIND_NOINFOAVAIL } 
20    SectionKind;
21
22 typedef struct { void* start; void* end; SectionKind kind; } 
23    Section;
24
25 typedef 
26    struct _ProddableBlock {
27       void* start;
28       int   size;
29       struct _ProddableBlock* next;
30    }
31    ProddableBlock;
32
33 /* Top-level structure for an object module.  One of these is allocated
34  * for each object file in use.
35  */
36 typedef struct _ObjectCode {
37     OStatus    status;
38     char*      fileName;
39     int        fileSize;
40     char*      formatName;            /* eg "ELF32", "DLL", "COFF", etc. */
41
42     /* An array containing ptrs to all the symbol names copied from
43        this object into the global symbol hash table.  This is so that
44        we know which parts of the latter mapping to nuke when this
45        object is removed from the system. */
46     char**     symbols;
47     int        n_symbols;
48
49     /* ptr to malloc'd lump of memory holding the obj file */
50     void*      image;
51
52     /* The section-kind entries for this object module.  Dynamically expands. */
53     Section*   sections;
54     int        n_sections;
55
56     /* A private hash table for local symbols. */
57     HashTable* lochash;
58     
59     /* Allow a chain of these things */
60     struct _ObjectCode * next;
61
62     /* SANITY CHECK ONLY: a list of the only memory regions which may
63        safely be prodded during relocation.  Any attempt to prod
64        outside one of these is an error in the linker. */
65     ProddableBlock* proddables;
66     
67 } ObjectCode;
68
69 extern ObjectCode *objects;