From patchwork Thu Nov 4 18:10:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lucas A. M. Magalhaes" X-Patchwork-Id: 47065 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A21B53857C62 for ; Thu, 4 Nov 2021 18:16:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A21B53857C62 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1636049782; bh=XlOip3wyaF87GcZaFBT2B/Qjyqz67FUjpFkwV475e4M=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=DFDxCyJBmuVJx8aPv+hMhBWrzcQanW1IxtMvAv/BqmaRHGxIg1DtGO+IeOJVw2vDf wBNG2fapb3U4zZ9ncuq4KMcxWH7niNR61gSKUrWppilYhFAJFAk2pWGtyGf+BGtSlZ kXh9Z7QEl8hIfRym/dbg/vsLWbIVHVtNYgg+3J/Q= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id 84354385803D for ; Thu, 4 Nov 2021 18:10:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 84354385803D Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1A4HR7Do002041 for ; Thu, 4 Nov 2021 18:10:44 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3c4kx30tag-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 04 Nov 2021 18:10:43 +0000 Received: from m0098417.ppops.net (m0098417.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 1A4HSYLm008566 for ; Thu, 4 Nov 2021 18:10:43 GMT Received: from ppma02dal.us.ibm.com (a.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.10]) by mx0a-001b2d01.pphosted.com with ESMTP id 3c4kx30ta8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Nov 2021 18:10:43 +0000 Received: from pps.filterd (ppma02dal.us.ibm.com [127.0.0.1]) by ppma02dal.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 1A4I70nn027654; Thu, 4 Nov 2021 18:10:43 GMT Received: from b03cxnp07027.gho.boulder.ibm.com (b03cxnp07027.gho.boulder.ibm.com [9.17.130.14]) by ppma02dal.us.ibm.com with ESMTP id 3c22tu1e33-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Nov 2021 18:10:42 +0000 Received: from b03ledav006.gho.boulder.ibm.com (b03ledav006.gho.boulder.ibm.com [9.17.130.237]) by b03cxnp07027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 1A4IAfTx29425924 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 4 Nov 2021 18:10:41 GMT Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4CC22C6055; Thu, 4 Nov 2021 18:10:41 +0000 (GMT) Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D9995C6059; Thu, 4 Nov 2021 18:10:40 +0000 (GMT) Received: from localhost (unknown [9.160.8.33]) by b03ledav006.gho.boulder.ibm.com (Postfix) with ESMTP; Thu, 4 Nov 2021 18:10:40 +0000 (GMT) To: libc-alpha@sourceware.org Subject: [PATCH] powerpc: Use FLAG_ELF_LIBC6 for 32-bit known libraries Date: Thu, 4 Nov 2021 15:10:39 -0300 Message-Id: <20211104181039.97106-1-lamm@linux.ibm.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211022211201.983646-1-lamm@linux.ibm.com> References: <20211022211201.983646-1-lamm@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: ca1tb4BqiBCWDq6skgIk3e4k7tWMbHiD X-Proofpoint-ORIG-GUID: 7MmwtjCxZqYf3y4oypxA2yk_2pSRodSE X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.0.607.475 definitions=2021-11-04_06,2021-11-03_01,2020-04-07_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 priorityscore=1501 malwarescore=0 bulkscore=0 suspectscore=0 mlxscore=0 adultscore=0 clxscore=1015 lowpriorityscore=0 phishscore=0 impostorscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2111040070 X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, 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-Patchwork-Original-From: "Lucas A. M. Magalhaes via Libc-alpha" From: "Lucas A. M. Magalhaes" Reply-To: "Lucas A. M. Magalhaes" Cc: fweimer@redhat.com, tuliom@linux.ibm.com Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" 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. 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,