Thread (4 messages) 4 messages, 2 authors, 2021-02-27

Re: HELP: MIPS PC Relative Addressing

From: "Maciej W. Rozycki" <macro@orcam.me.uk>
Date: 2021-02-27 16:46:28

On Thu, 25 Feb 2021, Jiaxun Yang wrote:
quoted
  You may want to use composed relocations to refer to .LA1 (R_MIPS_32) and
.LA0 (R_MIPS_SUB).  There may or may not be linker updates needed; unlike
the RISC-V one the MIPS BFD backend already supports composed relocations
with the usual ELF gABI semantics.  It would be good to switch to RELA at
this point universally too; none of new stuff will work with old linkers
anyway.
Thanks for your hint;-)

I'm unsure about how should we express composed relocations in assembly :-/
 Just like we already do; R_MIPS_SUB could be easily produced directly 
from the `-' operator.

 I note too that $pc is effectively used twice in the calculation, 
cancelling itself, so I think we can do better, though it seems to me the 
original semantics of %pcrel_hi/%pcrel_lo pseudo-ops wasn't thought well 
(I guess it was just blindly copied from %hi/%lo by adding PC-relative 
interpretation with no further thinking as to whether it is usable in 
reality).  It seems to me that we could overload the semantics of these 
pseudo-ops in a compatible manner though.

 Also are you concerned about linker relaxation you're possibly working on 
here?  I'm asking because a calculation like (.LA1 - .LA0) works out as an 
assembly constant normally, so it's not a concern really.  And as I recall 
existing MIPS linker relaxation does not rely on label symbols anyway (and 
is probably not defined for plain R6 anyway as I reckon there is nothing 
to relax at the link stage for that ISA).

 Where it might start to matter is the microMIPS ISA however; offhand I 
don't remember what exactly it looks like at R6 though.
MIPS N32/N64 ABI is already using RELA, do you mean switch to RELA for o32
as well?
 Yes, with "universally" I meant: "across all the ABIs".

  Maciej
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help