Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: patcher.c 7483 2007-03-08 13:17:40Z michi $
+ $Id: patcher.c 7596 2007-03-28 21:05:53Z twisti $
*/
/* if we show disassembly, we have to skip the nop's */
- if (opt_showdisassemble)
+ if (opt_shownops)
ra = ra + 5;
/* patch the field value's address */
/* if we show disassembly, we have to skip the nop's */
- if (opt_showdisassemble)
+ if (opt_shownops)
ra = ra + 5;
/* patch the field's offset */
/* if we show disassembly, we have to skip the nop's */
- if (opt_showdisassemble)
+ if (opt_shownops)
ra = ra + 5;
/* patch the field's offset */
/* if we show disassembly, we have to skip the nop's */
- if (opt_showdisassemble)
+ if (opt_shownops)
ra = ra + 5;
/* patch the field's offset */
/* if we show disassembly, we have to skip the nop's */
- if (opt_showdisassemble)
+ if (opt_shownops)
ra = ra + 5;
/* patch the classinfo pointer */
/* if we show disassembly, we have to skip the nop's */
- if (opt_showdisassemble)
+ if (opt_shownops)
ra = ra + 5;
/* patch the classinfo pointer */
/* if we show disassembly, we have to skip the nop's */
- if (opt_showdisassemble)
+ if (opt_shownops)
ra = ra + 5;
/* patch the classinfo pointer */
/* if we show disassembly, we have to skip the nop's */
- if (opt_showdisassemble)
+ if (opt_shownops)
ra = ra + 5;
/* patch stubroutine */
/* if we show disassembly, we have to skip the nop's */
- if (opt_showdisassemble)
+ if (opt_shownops)
ra = ra + 5;
/* patch vftbl index */
/* if we show disassembly, we have to skip the nop's */
- if (opt_showdisassemble)
+ if (opt_shownops)
ra = ra + 5;
/* patch interfacetable index */
/* if we show disassembly, we have to skip the nop's */
- if (opt_showdisassemble)
+ if (opt_shownops)
ra = ra + 5;
/* patch class flags */
}
-/* patcher_checkcast_instanceof_interface **************************************
+/* patcher_checkcast_interface *************************************************
Machine code:
8b 91 00 00 00 00 mov 0x00000000(%ecx),%edx
81 ea 00 00 00 00 sub $0x00000000,%edx
85 d2 test %edx,%edx
- 0f 8e 00 00 00 00 jle 0x00000000
+ 0f 8f 06 00 00 00 jg 0x00000000
+ 8b 35 03 00 00 00 mov 0x3,%esi
8b 91 00 00 00 00 mov 0x00000000(%ecx),%edx
*******************************************************************************/
-bool patcher_checkcast_instanceof_interface(u1 *sp)
+bool patcher_checkcast_interface(u1 *sp)
{
u1 *ra;
u8 mcode;
/* if we show disassembly, we have to skip the nop's */
- if (opt_showdisassemble)
+ if (opt_shownops)
+ ra = ra + 5;
+
+ /* patch super class index */
+
+ *((s4 *) (ra + 6 + 2)) = (s4) c->index;
+
+ *((s4 *) (ra + 6 + 6 + 2 + 6 + 6 + 2)) =
+ (s4) (OFFSET(vftbl_t, interfacetable[0]) -
+ c->index * sizeof(methodptr*));
+
+ return true;
+}
+
+
+/* patcher_instanceof_interface ************************************************
+
+ Machine code:
+
+ <patched call position>
+ 8b 91 00 00 00 00 mov 0x00000000(%ecx),%edx
+ 81 ea 00 00 00 00 sub $0x00000000,%edx
+ 85 d2 test %edx,%edx
+ 0f 8e 13 00 00 00 jle 0x00000000
+ 8b 91 00 00 00 00 mov 0x00000000(%ecx),%edx
+
+*******************************************************************************/
+
+bool patcher_instanceof_interface(u1 *sp)
+{
+ u1 *ra;
+ u8 mcode;
+ constant_classref *cr;
+ classinfo *c;
+
+ /* get stuff from the stack */
+
+ ra = (u1 *) *((ptrint *) (sp + 6 * 4));
+ mcode = *((u8 *) (sp + 2 * 4));
+ cr = (constant_classref *) *((ptrint *) (sp + 1 * 4));
+
+ /* get the fieldinfo */
+
+ if (!(c = resolve_classref_eager(cr)))
+ return false;
+
+ /* patch back original code */
+
+ *((u4 *) (ra + 0)) = (u4) mcode;
+ *((u1 *) (ra + 4)) = (u1) (mcode >> 32);
+
+ /* if we show disassembly, we have to skip the nop's */
+
+ if (opt_shownops)
ra = ra + 5;
/* patch super class index */
/* if we show disassembly, we have to skip the nop's */
- if (opt_showdisassemble)
+ if (opt_shownops)
ra = ra + 5;
/* patch super class' vftbl */
/* if we show disassembly, we have to skip the nop's */
- if (opt_showdisassemble)
+ if (opt_shownops)
ra = ra + 5;
/* patch super class' vftbl */
/* if we show disassembly, we have to skip the nop's */
- if (opt_showdisassemble)
+ if (opt_shownops)
ra = ra + 5;
/* patch native function pointer */