[PATCH] elfedit: add support for editing e_flags
Xi Ruoyao
xry111@xry111.site
Thu Mar 2 10:42:42 GMT 2023
On Thu, 2023-03-02 at 17:04 +0800, Xi Ruoyao wrote:
> On Thu, 2023-03-02 at 16:53 +0800, WANG Xuerui wrote:
> > On 2023/3/2 16:20, Xi Ruoyao wrote:
> > > On Thu, 2023-03-02 at 16:01 +0800, WANG Xuerui wrote:
> > >
> > > > I have to pick up the work because I was trying to make AMDGPU DCN work
> > > > on LoongArch, but that piece of code requires hard-float support while
> > > > the LoongArch Linux kernel is compiled in the soft-float ABI, leading to
> > > > link-time failures intermixing the two.
> > > IMO we should keep soft-float ABI while enabling the FPU (i. e.
> > > -mabi=lp64s -mfpu=64). But ouch, this does not work properly with
> > > current GCC... -mfpu=64 silently enables using FPR to pass arg and
> > > return value, w/o even a warning. Not sure about Clang.
> > >
> > > <rant>I remember I've been saying "floating ABI and floating instruction
> > > set should be de-coupled" multiple times: "I" in "ABI" stands for
> > > "interface" anyway and all the interfaces are just designed for hiding
> > > implementation details. But it seems nobody took it seriously.</rant>
> >
> > Yeah. I remember the Toolchain Conventions has similar words so I've
> > immediately tried `-mdouble-float` without `-mabi=lp64d`, after seeing
> > the rejected interlinks, only to see the ABI implicitly promoted to
> > LP64D nevertheless...
Try "-mabi=lp64s -mfpu=64". It should create object files with SOFT-
FLOAT in flags.
The current GCC behavior is still problematic as it actually uses LP64D
ABI, though marking the file as LP64S. Example:
$ cat t.c
double t(double x)
{
return 1.0 / x;
}
$ cc t.c -O2 -mabi=lp64s -mfpu=64 -c
$ readelf -a t.o | grep FLOAT
Flags: 0x41, SOFT-FLOAT, OBJ-v1
But then bad thing happens:
$ objdump -d t.o
t.o: file format elf64-loongarch
Disassembly of section .text:
0000000000000000 <t>:
0: 01145800 frecip.d $fa0, $fa0 <= you can't expect the arg in the god-damn $fa0!
4: 4c000020 jirl $zero, $ra, 0 <= you can't just return the answer in $fa0!
This is completely broken. However if your elfedit hack will "work",
this will "work" too anyway.
--
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University
More information about the Binutils
mailing list