2004-12-25 02:55:03 -05:00
|
|
|
/* relocation base of currently loaded image's data heap */
|
|
|
|
CELL data_relocation_base;
|
2004-07-16 02:26:21 -04:00
|
|
|
|
2005-05-12 03:52:56 -04:00
|
|
|
INLINE void data_fixup(CELL *cell)
|
2004-12-25 02:55:03 -05:00
|
|
|
{
|
|
|
|
if(TAG(*cell) != FIXNUM_TYPE && *cell != F)
|
2005-05-11 00:43:52 -04:00
|
|
|
*cell += (tenured.base - data_relocation_base);
|
2004-12-25 02:55:03 -05:00
|
|
|
}
|
2004-07-16 02:26:21 -04:00
|
|
|
|
2004-12-25 02:55:03 -05:00
|
|
|
typedef enum {
|
|
|
|
/* arg is a primitive number */
|
2005-05-12 03:52:56 -04:00
|
|
|
F_PRIMITIVE,
|
2004-12-25 18:08:20 -05:00
|
|
|
/* arg is a pointer in the literal table hodling a cons where the
|
|
|
|
car is a symbol string, and the cdr is a dll */
|
2005-05-12 03:52:56 -04:00
|
|
|
F_DLSYM,
|
2004-12-25 02:55:03 -05:00
|
|
|
/* relocate an address to start of code heap */
|
2005-03-22 21:20:58 -05:00
|
|
|
F_ABSOLUTE,
|
2005-05-12 03:52:56 -04:00
|
|
|
/* store a pointer to environment table */
|
|
|
|
F_USERENV,
|
|
|
|
/* store the offset of the card table from the data heap base */
|
|
|
|
F_CARDS
|
2004-12-25 02:55:03 -05:00
|
|
|
} F_RELTYPE;
|
|
|
|
|
2005-05-13 18:27:18 -04:00
|
|
|
/* the rel type is built like a cell to avoid endian-specific code in
|
|
|
|
the compiler */
|
|
|
|
#define REL_TYPE(r) ((r)->type & 0xff)
|
|
|
|
/* on PowerPC, some values are stored in the high 16 bits of a pair
|
|
|
|
of consecutive cells */
|
|
|
|
#define REL_16_16(r) ((r)->type & 0xff00)
|
|
|
|
#define REL_RELATIVE(r) ((r)->type & 0xff0000)
|
|
|
|
|
2004-12-25 02:55:03 -05:00
|
|
|
/* code relocation consists of a table of entries for each fixup */
|
|
|
|
typedef struct {
|
2005-05-13 18:27:18 -04:00
|
|
|
CELL type;
|
2004-12-25 02:55:03 -05:00
|
|
|
CELL offset;
|
|
|
|
CELL argument;
|
|
|
|
} F_REL;
|
|
|
|
|
|
|
|
CELL code_relocation_base;
|
|
|
|
|
2005-05-12 03:52:56 -04:00
|
|
|
INLINE void code_fixup(CELL *cell)
|
2004-12-25 02:55:03 -05:00
|
|
|
{
|
|
|
|
*cell += (compiling.base - code_relocation_base);
|
|
|
|
}
|
|
|
|
|
|
|
|
void relocate_data();
|
|
|
|
void relocate_code();
|
2005-03-22 21:20:58 -05:00
|
|
|
|
|
|
|
/* on PowerPC, return the 32-bit literal being loaded at the code at the
|
|
|
|
given address */
|
2005-05-12 03:52:56 -04:00
|
|
|
INLINE CELL reloc_get_16_16(CELL cell)
|
2005-03-22 21:20:58 -05:00
|
|
|
{
|
2005-05-12 03:52:56 -04:00
|
|
|
return ((get(cell) & 0xffff) << 16) | (get(cell + 1) & 0xffff);
|
2005-03-22 21:20:58 -05:00
|
|
|
}
|
|
|
|
|
2005-05-12 03:52:56 -04:00
|
|
|
INLINE void reloc_set_16_16(CELL cell, CELL value)
|
2005-03-22 21:20:58 -05:00
|
|
|
{
|
2005-05-12 03:52:56 -04:00
|
|
|
put(cell,((get(cell) & ~0xffff) | ((value >> 16) & 0xffff)));
|
|
|
|
put(cell + 1,((get(cell + 1) & ~0xffff) | (value & 0xffff)));
|
2005-03-22 21:20:58 -05:00
|
|
|
}
|