From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qk1-x72c.google.com (mail-qk1-x72c.google.com [IPv6:2607:f8b0:4864:20::72c]) by sourceware.org (Postfix) with ESMTPS id 3AADD3858D28 for ; Fri, 3 Dec 2021 14:51:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 3AADD3858D28 Received: by mail-qk1-x72c.google.com with SMTP id a11so3554844qkh.13 for ; Fri, 03 Dec 2021 06:51:32 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=J2xTi5PVoKn8/l1nr6NAMg3JF+MwZoZOT+MGMIggoHA=; b=NxgqteNpfEks6fFhCPh+PU8M02qh0Jf7pe/9icl+T1L8dhnQledBBmimj9fKBMezat O8aXObWCYqCIKm1eoxXe33c02IZZZPFtpKS8QEzBeKTZe/p4YquZZlocL5RLAv+ejSG4 VilR76z06t/zyD5orEky9iQUVrt5TXPg2eYuAYO8p6V48jfQ2+VRn3Nko01JHn0tUsK5 p6jHrOgXmVc+FSfw3L2yvBxT64MsyREGcSwFQ6j5OoUhE8Dn6RQalBALQXYXDQiIxNOA 7Alyl+78im49322ox/lWsKp6hSwnaBvYAQlZ1P+ZrvF55ta2tObefm11/DJmu51Ovk/Q ysqQ== X-Gm-Message-State: AOAM532t8Yv6UASQ9nIw5Afoq1gWRXR+zArYkM4I2y5/GQiZoP3u5EDG NK79kdijzGMZ7Y3Q/PJKWB+r2g== X-Google-Smtp-Source: ABdhPJxPBBVEfpRVkKDe0kwCyeUmi4RuVHe572hTrrJpEoZ5P0IvuzaXSJKnn8ZFn5lKv3PqhE6E9g== X-Received: by 2002:a05:620a:2697:: with SMTP id c23mr17960375qkp.103.1638543091736; Fri, 03 Dec 2021 06:51:31 -0800 (PST) Received: from ?IPV6:2804:431:c7cb:30f8:f5d6:4b6d:fe6a:d565? ([2804:431:c7cb:30f8:f5d6:4b6d:fe6a:d565]) by smtp.gmail.com with ESMTPSA id a16sm2442739qta.94.2021.12.03.06.51.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 03 Dec 2021 06:51:31 -0800 (PST) Message-ID: Date: Fri, 3 Dec 2021 11:51:29 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.3.2 Subject: Re: [PATCH] powerpc: Use FLAG_ELF_LIBC6 for 32-bit known libraries Content-Language: en-US To: "Lucas A. M. Magalhaes" , libc-alpha@sourceware.org Cc: fweimer@redhat.com, tuliom@linux.ibm.com References: <20211022211201.983646-1-lamm@linux.ibm.com> <20211104181039.97106-1-lamm@linux.ibm.com> From: Adhemerval Zanella In-Reply-To: <20211104181039.97106-1-lamm@linux.ibm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Dec 2021 14:51:34 -0000 On 04/11/2021 15:10, Lucas A. M. Magalhaes via Libc-alpha wrote: > In systems with more versions of the known libraries, i.e. on IBM > Advance Toolchain, ldconfig will order them incorrectly on ld.cache. > > The issue only occurs with 32-bit libraries that don't depend on libc or > libm. That's because process_elf32_file check if the elf depends on one > of the libraries at known_libs to select the elf flag. For example, as > libc.so.6 don't depend on itself or on libm it will be flagged as > FLAG_ELF instead of FLAG_ELF_LIBC6 as expected. Wouldn't be simpler to check if the DT_SONAME matches any on 'known_libs' after dynamic section parsing and set the appropriated flag on generic 'process_file'? (also powerpc SYSDEP_KNOWN_LIBRARY_NAMES seems redundant). > > This commit fixes this by checking if a appropriate flag was set by > process_elf32_file. If not it will search on known_libs and use the flag > in there. > --- > sysdeps/unix/sysv/linux/powerpc/readelflib.c | 21 +++++++++++++++++--- > 1 file changed, 18 insertions(+), 3 deletions(-) > > diff --git a/sysdeps/unix/sysv/linux/powerpc/readelflib.c b/sysdeps/unix/sysv/linux/powerpc/readelflib.c > index 51f8a9496a..94da21c407 100644 > --- a/sysdeps/unix/sysv/linux/powerpc/readelflib.c > +++ b/sysdeps/unix/sysv/linux/powerpc/readelflib.c > @@ -33,11 +33,26 @@ process_elf_file (const char *file_name, const char *lib, int *flag, > char **soname, void *file_contents, size_t file_length) > { > ElfW(Ehdr) *elf_header = (ElfW(Ehdr) *) file_contents; > - int ret; > + int ret, j; > > if (elf_header->e_ident [EI_CLASS] == ELFCLASS32) > - return process_elf32_file (file_name, lib, flag, osversion, isa_level, > - soname, file_contents, file_length); > + { > + ret = process_elf32_file (file_name, lib, flag, osversion, isa_level, > + soname, file_contents, file_length); > + /* Use the apropriate flag for known_libs instead of FLAG_ELF. */ > + if (*flag == FLAG_ELF) > + { > + for (j = 0; > + j < sizeof (known_libs) / sizeof (known_libs [0]); > + ++j) > + if (strcmp (lib, known_libs [j].soname) == 0) > + { > + *flag = known_libs [j].flag; > + break; > + } > + } > + return ret; > + } > else > { > ret = process_elf64_file (file_name, lib, flag, osversion, isa_level, >