This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: MIPS %half in gas


On Fri, Oct 12, 2007 at 05:06:38PM +0100, Maciej W. Rozycki wrote:
>  Hmm, I find it nice to discover yet another MIPS relocation type/operator 
> I was not aware of. ;-)  I can hardly see a use for this operator and I 
> have no idea as to where it is coming from, but your change looks 
> reasonable to me.

I've got no idea where it comes from either.

>  Though the test case may be confusing -- given the relocation operates on 
> an unsigned value, the use of "lw" in the test case is misleading.  I 
> think "ori", "andi" or "xori" would be better.  Although of these only 
> "ori" looks remotely useful and I am not sure if using this relocation on 
> code rather than data (".hword %half(foo)") makes sense at all.

This is where my lack of knowing what things are for comes into play.
The example in Eric's original mail from long ago uses a gp-relative
address.  GCC uses it for exactly that purpose, in a VxWorks PIC
model:

(define_split
  [(unspec_volatile [(match_operand:P 0 "symbol_ref_operand")
                     (match_operand:P 1 "symbol_ref_operand")]
		     UNSPEC_LOADGP)]
  "mips_current_loadgp_style () == LOADGP_RTP"
  [(set (match_dup 2) (high:P (match_dup 3)))
   (set (match_dup 2) (unspec:P [(match_dup 2)
                                 (match_dup 3)] UNSPEC_LOAD_GOT))
   (set (match_dup 2) (unspec:P [(match_dup 2)
                                 (match_dup 4)] UNSPEC_LOAD_GOT))]
{
  operands[2] = pic_offset_table_rtx;
  operands[3] = mips_unspec_address (operands[0], SYMBOL_ABSOLUTE);
  operands[4] = mips_unspec_address (operands[1], SYMBOL_HALF);
})

That expands to something like %half(__GOTT_INDEX__)($gp) which is a
magic symbol defined by the runtime to a small value, so the
signedness does not much matter.

-- 
Daniel Jacobowitz
CodeSourcery


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]