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

Re: mips64 assembler


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

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.

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?

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.

Thanks so much.
Camm Maguire			     		    camm@maguirefamily.org
"The earth is but one country, and mankind its citizens."  --  Baha'u'llah

Reply to: