Massive patch for the first months work adding System FC to GHC #35
[ghc-hetmet.git] / 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 #ifdef darwin_HOST_OS
74     /* record by how much image has been deliberately misaligned
75        after allocation, so that we can use realloc */
76     int        misalignment;
77 #endif
78
79     /* The section-kind entries for this object module.  Linked
80        list. */
81     Section* sections;
82
83     /* A private hash table for local symbols. */
84     HashTable* lochash;
85     
86     /* Allow a chain of these things */
87     struct _ObjectCode * next;
88
89     /* SANITY CHECK ONLY: a list of the only memory regions which may
90        safely be prodded during relocation.  Any attempt to prod
91        outside one of these is an error in the linker. */
92     ProddableBlock* proddables;
93
94 #ifdef ia64_HOST_ARCH
95     /* Procedure Linkage Table for this object */
96     void *plt;
97     unsigned int pltIndex;
98 #endif
99
100 #ifdef powerpc_HOST_ARCH
101     ppcJumpIsland   *jump_islands;
102     unsigned long   island_start_symbol;
103     unsigned long   n_islands;
104 #endif
105
106 } ObjectCode;
107
108 extern ObjectCode *objects;
109
110 #endif /* LINKERINTERNALS_H */