View Single Post
Old 05-31-2012, 03:16 PM   #19
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 15,721
Default

OK, pushed an update, now the glue*.h implement:

GLUE_JMP_SET_OFFSET(endptrofinstruction, offset_in_bytes_from_end_of_instruction)


PPC implements it as:

#define GLUE_JMP_SET_OFFSET(endOfInstruction,offset) (((short *)(endOfInstruction))[-1] = ((offset) + 4) & 0xFFFC)

(since PPC jumps are relative to the start of the jump instruction)

whereas x86/x86-64 implement it as:

#define GLUE_JMP_SET_OFFSET(endOfInstruction,offset) (((int *)(endOfInstruction))[-1] = (offset))

(on x86 the jump is relative to the next instruction)

If it makes it easier to read, you could implement this as 'static void GLUE_JMP_SET_OFFSET(void *, int)' too...
Justin is offline   Reply With Quote