factor/native/relocate.h

63 lines
1.6 KiB
C
Raw Permalink Normal View History

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-12-11 15:14:41 -05:00
#define REL_ABSOLUTE_CELL 0
#define REL_ABSOLUTE 1
#define REL_RELATIVE 2
#define REL_2_2 3
/* the rel type is built like a cell to avoid endian-specific code in
the compiler */
2005-12-11 15:14:41 -05:00
#define REL_TYPE(r) ((r)->type & 0x000000ff)
#define REL_CLASS(r) (((r)->type & 0x0000ff00) >> 8)
#define REL_ARGUMENT(r) (((r)->type & 0xffff0000) >> 16)
2004-12-25 02:55:03 -05:00
/* code relocation consists of a table of entries for each fixup */
typedef struct {
CELL type;
2004-12-25 02:55:03 -05:00
CELL offset;
} 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-12-11 15:14:41 -05:00
INLINE CELL reloc_get_2_2(CELL cell)
2005-03-22 21:20:58 -05:00
{
2005-06-07 04:33:24 -04:00
return ((get(cell - CELLS) & 0xffff) << 16) | (get(cell) & 0xffff);
2005-03-22 21:20:58 -05:00
}
2005-12-11 15:14:41 -05:00
INLINE void reloc_set_2_2(CELL cell, CELL value)
2005-03-22 21:20:58 -05:00
{
2005-06-07 04:33:24 -04:00
put(cell - CELLS,((get(cell - CELLS) & ~0xffff) | ((value >> 16) & 0xffff)));
put(cell,((get(cell) & ~0xffff) | (value & 0xffff)));
2005-03-22 21:20:58 -05:00
}