[project @ 2005-02-17 16:58:18 by desrt]
[ghc-hetmet.git] / ghc / rts / LinkerInternals.h
1 /* -----------------------------------------------------------------------------
2  *
3  * (c) The GHC Team, 2000
4  *
5  * RTS Object Linker
6  *
7  * ---------------------------------------------------------------------------*/
8
9 typedef enum { OBJECT_LOADED, OBJECT_RESOLVED } OStatus;
10
11 /* Indication of section kinds for loaded objects.  Needed by
12    the GC for deciding whether or not a pointer on the stack
13    is a code pointer.
14 */
15 typedef 
16    enum { SECTIONKIND_CODE_OR_RODATA,
17           SECTIONKIND_RWDATA,
18           SECTIONKIND_OTHER,
19           SECTIONKIND_NOINFOAVAIL } 
20    SectionKind;
21
22 typedef 
23    struct _Section { 
24       void* start; 
25       void* end; 
26       SectionKind kind;
27       struct _Section* next;
28    } 
29    Section;
30
31 typedef 
32    struct _ProddableBlock {
33       void* start;
34       int   size;
35       struct _ProddableBlock* next;
36    }
37    ProddableBlock;
38
39 /* Jump Islands are sniplets of machine code required for relative
40  * address relocations on the PowerPC.
41  */
42 #ifdef powerpc_HOST_ARCH
43 typedef struct {
44     short lis_r12, hi_addr;
45     short ori_r12_r12, lo_addr;
46     long mtctr_r12;
47     long bctr;
48 } ppcJumpIsland;
49 #endif
50
51 /* Top-level structure for an object module.  One of these is allocated
52  * for each object file in use.
53  */
54 typedef struct _ObjectCode {
55     OStatus    status;
56     char*      fileName;
57     int        fileSize;
58     char*      formatName;            /* eg "ELF32", "DLL", "COFF", etc. */
59
60     /* An array containing ptrs to all the symbol names copied from
61        this object into the global symbol hash table.  This is so that
62        we know which parts of the latter mapping to nuke when this
63        object is removed from the system. */
64     char**     symbols;
65     int        n_symbols;
66
67     /* ptr to malloc'd lump of memory holding the obj file */
68     char*      image;
69
70     /* The section-kind entries for this object module.  Linked
71        list. */
72     Section* sections;
73
74     /* A private hash table for local symbols. */
75     HashTable* lochash;
76     
77     /* Allow a chain of these things */
78     struct _ObjectCode * next;
79
80     /* SANITY CHECK ONLY: a list of the only memory regions which may
81        safely be prodded during relocation.  Any attempt to prod
82        outside one of these is an error in the linker. */
83     ProddableBlock* proddables;
84
85 #ifdef ia64_HOST_ARCH
86     /* Procedure Linkage Table for this object */
87     void *plt;
88     unsigned int pltIndex;
89 #endif
90
91 #ifdef powerpc_HOST_ARCH
92     ppcJumpIsland   *jump_islands;
93     unsigned long   island_start_symbol;
94     unsigned long   n_islands;
95 #endif
96
97 } ObjectCode;
98
99 extern ObjectCode *objects;