From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id E46DD3858D1E for ; Wed, 29 Mar 2023 13:13:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E46DD3858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680095583; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aCws9shXwt6mNJCpiU3z7RA9siVdIPm5awjD//HBhE4=; b=Y2Pcwr3YE0sirk10TuXlOPHCBd/hRBOg1XGzknhackMRugS9Ut5Mib9+FJ3tH2QdS49g7K B6638F+gm4uMtNEPJe5+MX+xB93WEWgw0xylkvEbEiQyMLXz/v5WNT/4ok5GYZhEE8PrCS F3+wTMPjtlEjuIarCMMH+HgehRWc0E4= Received: from mail-yw1-f198.google.com (mail-yw1-f198.google.com [209.85.128.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-523-daUHdtPxPfGzCzpqPORi7w-1; Wed, 29 Mar 2023 09:13:00 -0400 X-MC-Unique: daUHdtPxPfGzCzpqPORi7w-1 Received: by mail-yw1-f198.google.com with SMTP id 00721157ae682-536a4eba107so155286837b3.19 for ; Wed, 29 Mar 2023 06:12:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680095579; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=aCws9shXwt6mNJCpiU3z7RA9siVdIPm5awjD//HBhE4=; b=BuvaYi8S6PEulaL9c3DwJzljOghq3JMt5LP0JgKrQkwinpK2PdiMeFEz3Lukb2NVLk LlU2JmYir2abES9ekryvxGIFX2KEbHugbObH5SszDPc5rg8PAHTqt01SArUzujbX4Lug LU2NdRwhAnJx4kX/3mpbEZG79QF5FnTjTQRZDjNCi5qfhE5Zeihi1P8CWs0WBDwRQA6r b9BKy5o0BMMGIxj5jn9BACxy5N6hI77pRAKsvnL7pvlfHVJopn2Bh0yMIq6sx+DjpHVW ufZvNEaEvwLyVdXMhb8sqNXTfLaev5b9ZWj7XZAxEATv9GbJhXkKyPg5KW9DqlBoOVgX VHJg== X-Gm-Message-State: AAQBX9d5sgMKBDHzOho5AsIHw1VQcUlJ3h3JKOsL1J6kRiZaADxGq4Cm Q59KP3cG2MF34w4/ToxmgyMGyTHxw6w+7CuP5gAAqgpSU5pGOzkAF8ot/ZIkP35S84phpaohsg2 8G0dcYDln720HbVP1qKSicFKgZlCi X-Received: by 2002:a81:695:0:b0:541:697f:6434 with SMTP id 143-20020a810695000000b00541697f6434mr2094559ywg.24.1680095578768; Wed, 29 Mar 2023 06:12:58 -0700 (PDT) X-Google-Smtp-Source: AKy350apEiredc+cyZBQt1lHXRaRIOybLBvXfymt+Wun0NRKIHsiNteh8tulEAicc8VjDcHtn+cTuA== X-Received: by 2002:a81:695:0:b0:541:697f:6434 with SMTP id 143-20020a810695000000b00541697f6434mr2094540ywg.24.1680095578448; Wed, 29 Mar 2023 06:12:58 -0700 (PDT) Received: from [192.168.0.241] ([198.48.244.52]) by smtp.gmail.com with ESMTPSA id n38-20020a81af26000000b00545a08184d5sm2933209ywh.101.2023.03.29.06.12.57 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 29 Mar 2023 06:12:57 -0700 (PDT) Message-ID: <4b1411d2-b9ab-1395-9360-ced8d12c6ddc@redhat.com> Date: Wed, 29 Mar 2023 09:12:56 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: Re: [PATCH] LoongArch: ldconfig: Ignore EF_LARCH_OBJABI_V1 in shared objects To: Adhemerval Zanella Netto , Xi Ruoyao , libc-alpha@sourceware.org Cc: caiyinyu , Wang Xuerui References: <20230326111334.9920-1-xry111@xry111.site> <6f174ed1b3a54a83a8b0ff77fc0a50ceff2475a9.camel@xry111.site> From: Carlos O'Donell Organization: Red Hat In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00,BODY_8BITS,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham 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 3/27/23 12:54, Adhemerval Zanella Netto wrote: > > > On 27/03/23 11:57, Xi Ruoyao wrote: >> 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: OK, so the final form of the shared objects is compatible, this is only about static link compatibility and non-shared relocations. I would suggest reviewing ".gnu_attribute" for an extension to Ehdr->ef_flags that other architectures use, like ppc64le, to do such compatibility checking and error detection. >> 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. > > Since the boat is already sailed with 2.40, I think the proposed patch > is fine (it would be better if you indeed fix it on 2.41). I would > just like to add a comment on why this is required: > > /* The EF_LARCH_OBJABI_V1 flag indicate which set of static relocations > the object might use and it only considered during static linking, > it does not reflect in runtime relocations. However some binutils > version might set it on dynamic shared object, so clear it to avoid > see the SO as unsupported. */ Agreed. commit 07dd75589ecbedec5162a5645d57f8bd093a45db Author: caiyinyu Date: Tue Mar 28 09:19:53 2023 +0800 LoongArch: ldconfig: Add comments for using EF_LARCH_OBJABI_V1 We added Adhemerval Zanella's comment to explain the reason for using EF_LARCH_OBJABI_V1. And the comment is now in the sources. This is better, but I have a post-commit review comment here about the overall usage of ELF flags. While it is possible to use Ehdr->e_flags for such purposes as marking static relocation compatibility, you also have the broader use of ".gnu_attribute" via: GNU Object Attributes: https://sourceware.org/binutils/docs/as/GNU-Object-Attributes.html Which allows a richer set of non-flag-based attributes to be used for object files and for static link diagnostics. -- Cheers, Carlos.