View Single Post
Old 06-01-2012, 04:53 PM   #21
liteon
Human being with feelings
 
liteon's Avatar
 
Join Date: Apr 2008
Posts: 510
Default

Quote:
Originally Posted by Justin View Post
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...
thanks for the changes and clarification,

just merged and updated...
but i might have messed the jump offset macro, since it confuses me a little.
best would be to actually get to the point of testing it, i guess.

--
liteon is offline   Reply With Quote