public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Xi Ruoyao <xry111@xry111.site>
To: Carlos O'Donell <carlos@redhat.com>, libc-alpha@sourceware.org
Cc: caiyinyu <caiyinyu@loongson.cn>, Wang Xuerui <i@xen0n.name>,
	Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
Subject: Re: [PATCH] LoongArch: ldconfig: Ignore EF_LARCH_OBJABI_V1 in shared objects
Date: Mon, 27 Mar 2023 22:57:56 +0800	[thread overview]
Message-ID: <6f174ed1b3a54a83a8b0ff77fc0a50ceff2475a9.camel@xry111.site> (raw)
In-Reply-To: <b72544d0-17bd-0867-41c3-60183ed49b4b@redhat.com>

On Mon, 2023-03-27 at 09:44 -0400, Carlos O'Donell wrote:
> On 3/26/23 07:13, Xi Ruoyao via Libc-alpha wrote:
> > Binutils 2.40 sets EF_LARCH_OBJABI_V1 for shared objects:
> > 
> >     $ ld --version | head -n1
> >     GNU ld (GNU Binutils) 2.40
> >     $ echo 'int dummy;' > dummy.c
> >     $ cc dummy.c -shared
> >     $ readelf -h a.out | grep Flags
> >     Flags:                             0x43, DOUBLE-FLOAT, OBJ-v1
> > 
> > We need to ignore it in ldconfig or ldconfig will consider all shared
> > objects linked by Binutils 2.40 "unsupported".  Maybe we should stop
> > setting EF_LARCH_OBJABI_V1 for shared objects, but Binutils 2.40 is
> > already released and we cannot change it.
> > ---
> >  sysdeps/unix/sysv/linux/loongarch/readelflib.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/sysdeps/unix/sysv/linux/loongarch/readelflib.c b/sysdeps/unix/sysv/linux/loongarch/readelflib.c
> > index bcaff86b36..ceba355959 100644
> > --- a/sysdeps/unix/sysv/linux/loongarch/readelflib.c
> > +++ b/sysdeps/unix/sysv/linux/loongarch/readelflib.c
> > @@ -40,7 +40,7 @@ process_elf_file (const char *file_name, const char *lib, int *flag,
> >  
> >    ret = process_elf64_file (file_name, lib, flag, isa_level, soname,
> >                                 file_contents, file_length);
> > -  flags = elf64_header->e_flags;
> > +  flags = elf64_header->e_flags & ~EF_LARCH_OBJABI_V1;
> 
> Are such objects ABI compatible?

This flag was designed for indicating the relocation type usage in a .o
file:

If EF_LARCH_OBJABI_V1 is set, it's allowed to use relocation types with
ID in [64, 100], but it's prohibited to use relocation types with ID in
[22, 46].

If EF_LARCH_OBJABI_V1 is not set, it's allowed to use relocation types
with ID in [22, 46], but it's prohibited to use relocation types with ID
in [64, 100].

A linker may only support the .o files with EF_LARCH_OBJABI_V1 unset
(for example, GNU ld 2.38), or only support the .o files with
EF_LARCH_OBJABI_V1 set (for example, LLD under review at
https://reviews.llvm.org/D138135), or support both (for example, GNU ld
2.40).

If a linker supports both, it's OK to link a EF_LARCH_OBJABI_V1 .o file
together with a non-EF_LARCH_OBJABI_V1 .o file into an executable or
shared object.

But none of relocation type ID in [22, 46] or [64, 100] is runtime
relocation.  I. e. those relocation types should not show up in a shared
object at all (if one shows up, the linker is buggy).  So
EF_LARCH_OBJABI_V1 makes no difference for shared objects. 

> Why isn't this handled below via SUPPORTED_ELF_FLAGS?

If we add this into SUPPORTED_ELF_FLAGS, we'll need

  switch (flags & SUPPORTED_ELF_FLAGS)
    {
      case EF_LARCH_ABI_SOFT_FLOAT:
+     case EF_LARCH_ABI_SOFT_FLOAT | EF_LARCH_OBJABI_V1:
        *flag |= FLAG_LARCH_FLOAT_ABI_SOFT;
       break;
      case EF_LARCH_ABI_DOUBLE_FLOAT:
+     case EF_LARCH_ABI_DOUBLE_FLOAT | EF_LARCH_OBJABI_V1:
        *flag |= FLAG_LARCH_FLOAT_ABI_DOUBLE;
       break;
      default:
        return 1;
    }

I don't think it's better...  But if really you prefer this way I can
send a v2.

-- 
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University

  reply	other threads:[~2023-03-27 14:58 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-26 11:13 Xi Ruoyao
2023-03-27 13:44 ` Carlos O'Donell
2023-03-27 14:57   ` Xi Ruoyao [this message]
2023-03-27 16:54     ` Adhemerval Zanella Netto
2023-03-27 17:46       ` Xi Ruoyao
2023-03-29 13:12       ` Carlos O'Donell

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=6f174ed1b3a54a83a8b0ff77fc0a50ceff2475a9.camel@xry111.site \
    --to=xry111@xry111.site \
    --cc=adhemerval.zanella@linaro.org \
    --cc=caiyinyu@loongson.cn \
    --cc=carlos@redhat.com \
    --cc=i@xen0n.name \
    --cc=libc-alpha@sourceware.org \
    /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).