[PATCH] Fix 64-bit T3 invert_limb.asm on PIC again.

Torbjorn Granlund tg at gmplib.org
Mon Apr 15 23:17:28 CEST 2013

David Miller <davem at davemloft.net> writes:

  From: nisse at lysator.liu.se (Niels Möller)
  Date: Mon, 15 Apr 2013 22:28:54 +0200
  > David Miller <davem at davemloft.net> writes:
  >> Accomodating a negative offset means using sethi+xor with the
  >> "%hix22()" and "%lox10()" relocs, which gets us potentially right back
  >> into the area where we could hit Solaris assembler/linker quirks.
  > Maybe I'm missing something, but is there no easier way to sign extend
  > from 32 to 64 bits? Under the (reasonable) assumption that the offset
  > fits in the range of a signed 32-bit value, do we really need any fancy
  > 64-bit relocation magic?
  The problem is that sethi zero extends.
  That's why you need to use a sethi+xor sequence to build a 32-bit
  value sign extended to 64-bits.  It's the only way to do this in
  2 instructions.
  And if you do form a symbol relative address this way, you need to use
  %hix22() and %lox10() relocations so that the linker knows that you
  are using sethi+xor rather than sethi+or.

One bit of (assumed) missing information: The xor version then will set
the sign bit of its 13 bit immediate field.  And the reloc for sethi
will conditionally ones-complement its 22-bit field...  I clever trick,
too bad they were daft when they designed the instruction set.


More information about the gmp-devel mailing list