Re: [PATCH 1/3] crypto: X25519 low-level primitives for ppc64le.

Andy Polyakov
2024-05-16T13:42:18Z

Hi,

>>>> +.abiversion 2
>>>
>>> I'd prefer that was left to the compiler flags.
>>
>> Problem is that it's the compiler that is responsible for providing this
>> directive in the intermediate .s prior invoking the assembler. And there
>> is no assembler flag to pass through -Wa.
>
> Hmm, right. But none of our existing .S files include .abiversion
> directives.
>
> We build .S files with gcc, passing -mabi=elfv2, but it seems to have no
> effect.
>
> So all the intermediate .o's generated from .S files are not ELFv2:
>
> $ find .build/ -name '*.o' | xargs file | grep Unspecified
> .build/arch/powerpc/kernel/vdso/note-64.o: ELF 64-bit LSB relocatable, 64-bit PowerPC or cisco 7500, Unspecified or Power ELF V1 ABI, version 1 (SYSV), not stripped

I would guess that contemporary linker is more forgiving than it was
back then when the .abiversion directive was added. If it works now,
then it of course can be omitted. I suppose my original remark should be
viewed rather as "you can't replace it with a command line option" than
"you can't make it work without it." :-)

> But the actual code follows ELFv2, because we wrote it that way, and I
> guess the linker doesn't look at the actual ABI version of the .o ?
>
> So it currently works. But it's kind of gross that those .o files are
> not ELFv2 for an ELFv2 build.

Well, as far as passing base types and pointers to/from assembly goes,
there are no differences between the versions. Then it's a question of
meaning assigned to r2 and r13, but as long as you don't touch them, you
can freely reuse the code with either ABI. With this in mind the
.abiversion directive is effectively reduced to just a marker in the .o
file. In other words the instruction sequences by themselves are
customarily ABI-neutral, at least in "general calculation" modules such
as the suggested one, so that if it works 100% without the .abiversion
directive, then it can be safely omitted.

Cheers.