From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from xry111.site (xry111.site [89.208.246.23]) by sourceware.org (Postfix) with ESMTPS id DE4EF3858D33 for ; Thu, 2 Mar 2023 10:42:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DE4EF3858D33 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=xry111.site Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=xry111.site DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xry111.site; s=default; t=1677753772; bh=HM9g1O4s/cs9XbXPJp7K+qyZLsaBUxyGg0237L3w1DM=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=IrUlE0fHsmVEOArTp82t98RStAj7b/uX9QVj7HIdQTj53S1G8XfWRqRoCyLLD7cjj q4NTmz+tuFk2x6GTeq6K5s1GYtbztXd2jx8F/A9hAPLhE68eUX4CwOKFNT8++e+mZQ O64IXd7U+HFo4SHBc1musnUOGz0iBJ6lwhiL4UTo= Received: from [IPv6:2408:8471:1003:36e3:fcc9:73a2:e263:ac75] (unknown [IPv6:2408:8471:1003:36e3:fcc9:73a2:e263:ac75]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) (Authenticated sender: xry111@xry111.site) by xry111.site (Postfix) with ESMTPSA id 96EBF65BFE; Thu, 2 Mar 2023 05:42:48 -0500 (EST) Message-ID: <1b9715e49f81b2104364e8477889cc142c1011c3.camel@xry111.site> Subject: Re: [PATCH] elfedit: add support for editing e_flags From: Xi Ruoyao To: WANG Xuerui , binutils@sourceware.org Cc: Chenghua Xu , Zhensong Liu , Qinggang Meng , WANG Xuerui Date: Thu, 02 Mar 2023 18:42:42 +0800 In-Reply-To: References: <20230302080137.3346439-1-i.swmail@xen0n.name> <502da978c3a38a5216a0d9abbbe3ebf22f8688e5.camel@xry111.site> <660c58cc-10bf-c43b-aded-27a27300cea3@xen0n.name> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.46.4 MIME-Version: 1.0 X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,LIKELY_SPAM_FROM,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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: > > >=20 > > > > 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 wh= ile > > > > the LoongArch Linux kernel is compiled in the soft-float ABI, leadi= ng to > > > > link-time failures intermixing the two. > > > IMO we should keep soft-float ABI while enabling the FPU (i. e. > > > -mabi=3Dlp64s -mfpu=3D64).=C2=A0 But ouch, this does not work properl= y with > > > current GCC...=C2=A0 -mfpu=3D64 silently enables using FPR to pass ar= g and > > > return value, w/o even a warning.=C2=A0 Not sure about Clang. > > >=20 > > > I remember I've been saying "floating ABI and floating instruct= ion > > > set should be de-coupled" multiple times: "I" in "ABI" stands for > > > "interface" anyway and all the interfaces are just designed for hidin= g > > > implementation details.=C2=A0 But it seems nobody took it seriously.<= /rant> > >=20 > > Yeah. I remember the Toolchain Conventions has similar words so I've > > immediately tried `-mdouble-float` without `-mabi=3Dlp64d`, after seein= g > > the rejected interlinks, only to see the ABI implicitly promoted to=20 > > LP64D nevertheless... Try "-mabi=3Dlp64s -mfpu=3D64". 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=3Dlp64s -mfpu=3D64 -c $ readelf -a t.o | grep FLOAT =20 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 : 0: 01145800 frecip.d $fa0, $fa0 <=3D you can't expect the arg i= n the god-damn $fa0! 4: 4c000020 jirl $zero, $ra, 0 <=3D 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. --=20 Xi Ruoyao School of Aerospace Science and Technology, Xidian University