[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: mips64 assembler



On 09/17/2010 01:44 PM, Camm Maguire wrote:
Greetings!

David Daney<ddaney@caviumnetworks.com>  writes:

On 09/17/2010 07:16 AM, Camm Maguire wrote:
Greetings!  Is there anyway to load a known 64bit number into a given
register in two instructions?

Not in the general case where the value of the 64-bit number is
unconstrained...

Said number is guaranteed to be within
32bits of the current value of another register.

In other words, you want to add an arbitrary 32-bit constant to the
value in a register.  You would need three instructions to do this.
Two to generate the 32-bit constant and another to do the addition.

David Daney.


Alas, this was as I had expected.  Perhaps you can suggest a course of
action.

On mips only, there is no plt support -- executables instead have
.MIPS.stubs entries for lazy relocations to external symbols.  Problem
is, these are only callable if the gp register is left at its
canonical position.  I need to load, relocate, and execute code which
might call these functions, which I currently redirect to the stub.
This means that any .got references to addresses in the code to be
relocated, which will of course not be in the global .got table, have
to be patched to immediate addressess, which on mips32 is easy
enough -- ld v0,oooo(gp) ->  lui v0,hhhh.  This won't work on mips64.


PLT support works with the n32 ABI (with new toolchains).  Can you use that?

I am missing part of the puzzle. ld.so handles all of this, why can't you let it do its job?


This seems to indicate to me that I will need to craft my own lazy
relocation stub for each call to a shared lib symbol at the end of
each loaded block of code.  Then I can mode the gp pointer to a local
.got table as well.  This is unfortunate, but can be done.  Two
questions remain:

1) Is there an alternative, e.g. some flag like -mplt to generate a
genuine .plt section in the base executable, or other way out?


You haven't specified at a high level what problem you are trying to solve.

2) I don't completely understand the stub:

->    12010e090:	df998010 	ld	t9,-32752(gp)
      12010e094:	03e0782d 	move	t3,ra
      12010e098:	0320f809 	jalr	t9
      12010e09c:	641807c6 	daddiu	t8,zero,1990
->    12010e0a0:	df998010 	ld	t9,-32752(gp)
      12010e0a4:	03e0782d 	move	t3,ra
      12010e0a8:	0320f809 	jalr	t9
      12010e0ac:	641807c5 	daddiu	t8,zero,1989

->  denotes stub entry points.  How does the add ever get called?  This
add contains the only reference to the .got entry of the external
symbol.  It appears that it should be called before the jump.

On MIPS the instruction after a branch or jump is executed as part of the control transfer instruction. This called the Delay Slot.

t9 is loaded with the address of the lazy resolver. Return address saved into t3, symbol index loaded into t8, make the call to the lazy resolver via t9 ...



Thanks so much.


Reply to: