public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Xi Ruoyao <xry111@xry111.site>
To: WANG Xuerui <i.swmail@xen0n.name>, binutils@sourceware.org
Cc: Chenghua Xu <xuchenghua@loongson.cn>,
	Zhensong Liu <liuzhensong@loongson.cn>,
	 Qinggang Meng <mengqinggang@loongson.cn>,
	WANG Xuerui <git@xen0n.name>
Subject: Re: [PATCH] elfedit: add support for editing e_flags
Date: Thu, 02 Mar 2023 18:42:42 +0800	[thread overview]
Message-ID: <1b9715e49f81b2104364e8477889cc142c1011c3.camel@xry111.site> (raw)
In-Reply-To: <de6d1d4d71268e18b7273363bb5a621eb4f37e09.camel@xry111.site>

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

  reply	other threads:[~2023-03-02 10:42 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-02  8:01 WANG Xuerui
2023-03-02  8:20 ` Xi Ruoyao
2023-03-02  8:53   ` WANG Xuerui
2023-03-02  9:04     ` Xi Ruoyao
2023-03-02 10:42       ` Xi Ruoyao [this message]
2023-03-02 11:02         ` WANG Xuerui
2023-03-02 11:21           ` Xi Ruoyao
2023-03-03  1:28             ` Weining Lu
2023-03-02 16:11           ` Xi Ruoyao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1b9715e49f81b2104364e8477889cc142c1011c3.camel@xry111.site \
    --to=xry111@xry111.site \
    --cc=binutils@sourceware.org \
    --cc=git@xen0n.name \
    --cc=i.swmail@xen0n.name \
    --cc=liuzhensong@loongson.cn \
    --cc=mengqinggang@loongson.cn \
    --cc=xuchenghua@loongson.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).