From patchwork Fri Oct 22 21:12:01 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: 46551 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 9942C385782C for ; Fri, 22 Oct 2021 21:12:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9942C385782C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1634937149; bh=zxys48FYsPBkAZj7tTKGMjdbcC+bp1xXWq90DyEUJR4=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=DUw0cd/JBo7AyzwBcSKni+e1h4E/8WZoQhg15lEm7hEyrjO1VouK3mMpFrvhqbOxi XvJRVJve6eUiYXKKeS0ZRtELwA3sZfZMG2TKkgZCxmZ2OJyWAzprHC0LQ4UOhtgOxD R4usVurWrKqDDImhFDhYDqTR3kAGMF+AAkYJQ+g4= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id E621E3858416 for ; Fri, 22 Oct 2021 21:12:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E621E3858416 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 19MJlKBd005749 for ; Fri, 22 Oct 2021 17:12:06 -0400 Received: from ppma03dal.us.ibm.com (b.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.11]) by mx0a-001b2d01.pphosted.com with ESMTP id 3buwm8hd29-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 22 Oct 2021 17:12:05 -0400 Received: from pps.filterd (ppma03dal.us.ibm.com [127.0.0.1]) by ppma03dal.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 19ML7cHo006554 for ; Fri, 22 Oct 2021 21:12:05 GMT Received: from b03cxnp08026.gho.boulder.ibm.com (b03cxnp08026.gho.boulder.ibm.com [9.17.130.18]) by ppma03dal.us.ibm.com with ESMTP id 3bqpce2np7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 22 Oct 2021 21:12:05 +0000 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 19MLC3JN34406710 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 22 Oct 2021 21:12:03 GMT Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7E91D78060; Fri, 22 Oct 2021 21:12:03 +0000 (GMT) Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EFA4878069; Fri, 22 Oct 2021 21:12:02 +0000 (GMT) Received: from localhost (unknown [9.160.187.233]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP; Fri, 22 Oct 2021 21:12:02 +0000 (GMT) To: libc-alpha@sourceware.org Subject: [PATCH] powerpc: Use the correct flag for 32-bit known libraries Date: Fri, 22 Oct 2021 18:12:01 -0300 Message-Id: <20211022211201.983646-1-lamm@linux.ibm.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: p-2y3HPoNt9gwshCn5JMMZuBaTDjLiiy X-Proofpoint-ORIG-GUID: p-2y3HPoNt9gwshCn5JMMZuBaTDjLiiy X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.0.607.475 definitions=2021-10-22_05,2021-10-22_01,2020-04-07_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 impostorscore=0 clxscore=1015 suspectscore=0 mlxscore=0 spamscore=0 lowpriorityscore=0 adultscore=0 priorityscore=1501 phishscore=0 bulkscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2109230001 definitions=main-2110220118 X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H2, 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: 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_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,