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