Greetings! David Daney <dda...@caviumnetworks.com> writes:
> On 10/15/2010 10:11 AM, Camm Maguire wrote: >> Greetings! What is wrong with this stub attempting a jump to contents >> of register $t0? >> >> (gdb) p/x *(ul *)0x1094...@4 >> $3 = {0x3c080077, /*lui t0,0x77*/ >> 0x2508a170, /*addui t0,t0,0xa170*/ >> 0x8d08a288, /*lw t0,-23928(t0) */ >> 0x1000008 /* jr t0*/ } > > What instruction follows this JR? It will always be executed in the > delay slot of the jump. If it causes an exception, like BREAK or an > illegal instruction would, $pc will be left pointing at the JR so that > it can retry the whole thing once the mess is cleaned up. > > David Daney > Thanks so much -- guessed this from an earlier post you sent shortly before receiving this. Am now uploading gcl native relocation for mips using a local got table for each loaded .o file. Looks solid on gabrielli. The idea is to write a little stub in the got table for entries referring to e.g. _setjmp. In the stub I load the address from the global table into t9 and jump. Presupposes running with LD_BIND_NOW, as a pointer to the .MIPS.stub will not work as the gp register has been reset. Wish I knew how to do this from within the C program instead of having to rely on shell script wrappers. I still overwrite GOT16/LO16 with HI16/LO16 on 32bit, as I am too lazy at the moment to understand what the meaning of addends in the code: lw t0,1(gp) R_MIPS_GOT16 /*add one page to the symbol address?*/ addiu t0,t0,xxxx R_MIPS_LO16 /*presumably this needs to push the carry*/ /*bit above like with HI*/ I'm guessing that any GOT16 needs a got entry for each symbol times the highest addend used, on one loads addr,addr+4096,.... This snippet summarizes the reloc logic: #define GOT_RELOC(r) (ELF_R_TYPE(r->r_info)==R_MIPS_CALL16||ELF_R_TYPE(r->r_info)==R_MIPS_GOT16) case R_MIPS_JALR: break; case R_MIPS_32: add_val(where,~0L,s); break; case R_MIPS_GOT16: case R_MIPS_CALL16: if (!sym1[ELF_R_SYM(r->r_info)].st_shndx) { /*Better way to separate GOT16 from GOT16/LO16? */ gote=got; got+=sym1[ELF_R_SYM(r->r_info)].st_size-1; *got=s; store_val(where,MASK(16),(got-gote)*sizeof(*got)); if (s>=stub1 && s<stube) massert(!write_stub(s,got)); break; } massert(ELF_R_TYPE(r->r_info)==R_MIPS_GOT16); store_val(where,0xffe00000,0x3c000000); r->r_info=ELF_R_INFO(ELF_R_SYM(r->r_info),R_MIPS_HI16); case R_MIPS_HI16: if (!s) s=gpd=(ul)got-(ul)where; if (!hr) hr=r; if (a) add_vals(where,MASK(16),(s>>16)+a); break; case R_MIPS_LO16: if (!s) s=gpd; a=*where&MASK(16); if (a&0x8000) a|=0xffff0000; a+=s&MASK(16); a+=(a&0x8000)<<1; store_val(where,MASK(16),a); a=0x10000|(a>>16); for (hr=hr ? hr : r;--r>=hr && ELF_R_TYPE(r->r_info)==R_MIPS_HI16;) relocate(sym1,r,a,start,got,gote); hr=NULL;gpd=0; break; Take care, >> >> (gdb) c >> Program received signal SIGTRAP, Trace/breakpoint trap. >> 0x01094148 in ?? () /*this is the jump instruction*/ >> (gdb) i reg t0 >> t0: 0x2ae13bf0 /*this is the correct address*/ >> >> Any help most appreciated! >> >> Take care, >> >> >> David Daney<dda...@caviumnetworks.com> writes: >> >>> On 09/22/2010 04:05 PM, David Daney wrote: >>> [...] >>>> [11] .init PROGBITS 10000458 000458 000078 00 AX 0 0 8 >>>> [12] .plt PROGBITS 100004e0 0004e0 000030 00 AX 0 0 32 >>>> [13] .text PROGBITS 10000510 000510 0002c0 00 AX 0 0 16 >>>> [14] .MIPS.stubs PROGBITS 100007d0 0007d0 000020 00 AX 0 0 4 >>>> [15] .fini PROGBITS 100007f0 0007f0 000048 00 AX 0 0 8 >>>> [16] .rodata PROGBITS 10000838 000838 000020 00 A 0 0 8 >>>> [17] .eh_frame PROGBITS 10000858 000858 000004 00 A 0 0 4 >>>> [18] .ctors PROGBITS 1001085c 00085c 000008 00 WA 0 0 4 >>> [...] >>>> >>>> >>>> Look there, the PLT is section 17. >>>> >>>> >>> >>> Well really it is section 12. But what is a difference of 5 among friends? >>> >>> David Daney >>> >>> >>> >>> >>> >> > > > > > -- Camm Maguire c...@maguirefamily.org ========================================================================== "The earth is but one country, and mankind its citizens." -- Baha'u'llah _______________________________________________ Gcl-devel mailing list Gcl-devel@gnu.org http://lists.gnu.org/mailman/listinfo/gcl-devel