Hi!

On Mon, May 12, 2025 at 01:31:34PM +1000, Michael Ellerman wrote:
> Paul Mackerras <pau...@ozlabs.org> writes:
> Are you building with pcrel? Otherwise r2 shouldn't be getting used as
> an ordinary register.

With any ELFv2 in fact, which is implied by the target triple.  PCrel
has nothing to do with it (well, indirectly, functions that use PCrel
less often need a TOC register after all).

GPR2 usually *is* a normal volatile register in ELFv2.  (You detect
ELFv2 by checking if _CALL_ELF is 2).  If you want to treat it
differently (just like on other ABIs) you'll need to arrange for that,
maybe using some inline asm or such?  Ideally this will work everywhere
of course, and you do no longer depend on it accidentally working
elsewhere :-)


Segher

Reply via email to