예제 #1
0
void dcbInitThunk(DCThunk* p, void (*entry)())
{
/*

Thunk Register: $t4 ($12)
According to o32abi: $t9 

'The Linux/MIPS convention is that all PIC calls use t9 to hold the address of
the called function.' [See MIPS Run, p.413]

    mips thunk code:
      lui $t4,      %hi(p)
      lui $t9,      %hi(entry)
      ori $t9, $t9, %lo(entry)
      jr  $t9
      ori $t4, $t4, %lo(p)        ; branch delay slot

thunk.o:     file format elf32-tradbigmips


Disassembly of section .text:

00000000 <thunk>:
   0:	3c0c0000 	lui	t4,0x0
   4:	3c190000 	lui	t9,0x0
   8:	37390000 	ori	t9,t9,0x0
   c:	03200008 	jr	t9
  10:	00200825 	move	at,at
  14:	358c0000 	ori	t4,t4,0x0
  18:	00200825 	move	at,at
  1c:	00200825 	move	at,at

  */

#if defined(DC__Endian_BIG)

  p->data[0] = 0x3c0c; p->data[1] = hi16(p);     /* lui $t4, hi(p) */
  p->data[2] = 0x3c19; p->data[3] = hi16(entry); /* lui $t9, hi(entry) */
  p->data[4] = 0x3739; p->data[5] = lo16(entry); /* ori $t9, $t9, lo(entry) */
  p->jump    = 0x03200008;                       /* jr $t9 */
  p->bddt[0] = 0x358c; p->bddt[1] = lo16(p);     /* ori $t4, $t4, lo(p) - branch delay slot */

#else /* defined(DC__Endian_LITTLE) */
  
  p->data[1] = 0x3c0c; p->data[0] = hi16(p);     /* lui $t4, hi(p) */
  p->data[3] = 0x3c19; p->data[2] = hi16(entry); /* lui $t9, hi(entry) */
  p->data[5] = 0x3739; p->data[4] = lo16(entry); /* ori $t9, $t9, lo(entry) */
  p->jump    = 0x03200008;                       /* jr $t9 */
  p->bddt[1] = 0x358c; p->bddt[0] = lo16(p);     /* ori $t4, $t4, lo(p) - branch delay slot */
  
#endif

}
예제 #2
0
void dcbInitThunk(DCThunk* p, void (*entry)())
{
  /*
    mips thunk code:
      lui $t4,      hi(p)
      lui $t5,      hi(entry)
      ori $t5, $t5, lo(entry)
      jr  $t5
      ori $t4, $t4, lo(p) - branch delay slot
  */

  p->data[0] = hi16(p);     /* lui $t4, hi(p) */
  p->data[1] = 0x3c0c;
  p->data[2] = hi16(entry); /* lui $t5, hi(entry) */
  p->data[3] = 0x3c0d;
  p->data[4] = lo16(entry); /* ori $t5, $t5, lo(entry) */
  p->data[5] = 0x35ad;
  p->jump    = 0x01a00008;  /* jr $t5 */
  p->bddt[0] = lo16(p);     /* ori $t4, $t4, lo(p) - branch delay slot */
  p->bddt[1] = 0x358c;
}
void dcbInitThunk(DCThunk* p, void (*entry)())
{
/*
   0:	3d 60 00 00 	lis     r11,0
   4:	61 6b 00 01 	ori     r11,r11,1
   8:	81 82 00 14 	lwz     r12,20(r2)
   c:	7d 89 03 a6 	mtctr   r12
  10:	4e 80 04 20 	bctr
*/
  p->code_load_hi = 0x3d60U;     /* lis  r11, HI16(p) */
  p->addr_self_hi = hi16(p);
  p->code_load_lo = 0x616bU; 	 /* ori  r11, r11, LO16(p) */
  p->addr_self_lo = lo16(p);
  p->code_jump[0] = 0x818b0014U; /* lwz   r12, 20(r11) */
  p->code_jump[1] = 0x7d8903a6U; /* mtclr r12 */
  p->code_jump[2] = 0x4e800420U; /* bctr */
  p->addr_entry   = entry;

}
예제 #4
0
void dcbInitThunk(DCThunk* p, void (*entry)())
{
    /*
      ppc32 thunk code:
        lis   r2 , HI16(p)
        ori   r2 , r2, LO16(p)
        lwz   r12, 20(r2)
        mtctr r12
        bctr
    */

    p->code_load_hi = 0x3c40U;     /* lis  r2, HI16(p) */
    p->addr_self_hi = hi16(p);
    p->code_load_lo = 0x6042U; 	 /* ori  r2, r2, LO16(p) */
    p->addr_self_lo = lo16(p);
    p->code_jump[0] = 0x81820014U; /* lwz   r12, 20(r2) */
    p->code_jump[1] = 0x7d8903a6U; /* mtclr r12 */
    p->code_jump[2] = 0x4e800420U; /* bctr */
    p->addr_entry   = entry;
}