Subject: Re: [PATCH] powerpc: Implement ARCH_HAS_CC_CAN_LINK

From: Segher Boessenkool <[email-masked]>
Date: Sat, 3 Jan 2026 08:06:42 -0600

Hi!

On Sat, Jan 03, 2026 at 11:39:12AM +0100, Christophe Leroy (CS GROUP) wrote:
> Le 30/12/2025 à 08:06, Thomas Weißschuh a écrit :
> > The generic CC_CAN_LINK detection does not handle different byte orders.
> > This may lead to userprogs which are not actually runnable on the target
> > kernel.
> 
> Isn't the kernel supposed to handle any userland endianess ? Macro
> SET_ENDIAN() is there for that as far as I understand.

Yes, the kernel does not get much data out of data structures in memory
in the first place :-)

> And if you want to be complete, I think you should also check whether the
> ELF ABI is v1 or v2.

ELFv2 is version 1 of ELF, as wel as version 1 of its particular ABI.
It is just a cutesy name.  The thing now called "ELFv1" was called
"PowerOpen", or simply "PowerPC 64-bit ELF", or one of a hundred other
names :-)

All of the ABIs we use with PowerPC (in trunk, anyway) work with either
endianness (well, you need a userland built for it of course, and maybe
AIX and/or Darwin have not actually been designed to work with wrong-
endian as well).

But powerpc-{elf,linux} and powerpcle-{elf,linux} work equivalently
well, and so do both BE and LE versions of ELFv2 (yes, BE of that exists
just as well, and some distros even ship it!)

powerpc64-linux and powerpc64le-linux use different ABIs though (BE
ELFv1 and LE ELFv2, resp.)

Segher