From patchwork Sun Jul 12 15:47:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 40048 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 550183851C0B; Sun, 12 Jul 2020 15:57:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 550183851C0B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1594569432; bh=t8X5USHOctK8S9i+F2q96i7frdk/gCJw9mHP2XHPbWI=; 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=hfJWtyIlnwqUpr1oMBNAk1yZfhSfKBc1xm9KLD4Kkc/wNIVM3F1/ZBN4EoSngMnCx 04v5Whmcl3NMgrvOLcuJbg9bqc64bhgJMPyvDGse4/r6Gm1yOjILGKTFQ/tWZYYV5t sEw1aO/izNJajx8mrP7SJbRHATlEoebw6CJu5Wj8= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from esa4.hgst.iphmx.com (esa4.hgst.iphmx.com [216.71.154.42]) by sourceware.org (Postfix) with ESMTPS id 013623857027 for ; Sun, 12 Jul 2020 15:57:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 013623857027 IronPort-SDR: 9/tsQjzjI5A2vPYtea2Qp1SeKGHnFuu/kVMgbF4qv6yb1S11CVKv+64nEcu+JQiH9EMhd5wLaH dPfpZZJ+YVvT9srciWQKjmyRhFV+wXJiJfJQevhGYK6aPdVS4DXRF4GlItgbUhoiG+Xhvd7XTP 9CLGZgvUltOIFZL3wCYl2pAmAGRM1Dr115lzFY9ybBj02f7GrmmBOTCwZzsk2TnWNz394BSmDh QuxL2fCIx1KpdOuxVYlVx/f+7ilBZGBOFyasA2wXWBH3QLzDjk3MbMwL734Z4YWSL+bquKLXKY orA= X-IronPort-AV: E=Sophos;i="5.75,344,1589212800"; d="scan'208";a="142250039" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 12 Jul 2020 23:57:09 +0800 IronPort-SDR: IZXZUX5KU7e0EgV3TmtkUQP2LrbHoCNWW3FoFODKuJnDaDeN0VXgZdZyJRn6YbjUvhw/a4DOwN Kz8BUK9RZQ0sG7OAgb8+XMQFjK+Wj0v58= Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jul 2020 08:45:07 -0700 IronPort-SDR: TZYedAHlfmtf/yhbzSyfrjWsA5mu6lxWJHJ/Ls8vDo2mn3whNmXGWaw8is6c8h5bnWNfm24YPQ 8SRkbmElrYBA== WDCIronportException: Internal Received: from usa002626.ad.shared (HELO risc6-mainframe.hgst.com) ([10.86.57.178]) by uls-op-cesaip01.wdc.com with ESMTP; 12 Jul 2020 08:57:11 -0700 To: libc-alpha@sourceware.org Subject: [PATCH v3 07/19] RISC-V: Add path of library directories for the 32-bit Date: Sun, 12 Jul 2020 08:47:39 -0700 Message-Id: <5cf15612abb2f89e7cf7b76b1546b558751ce261.1594568655.git.alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-15.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: Alistair Francis via Libc-alpha From: Alistair Francis Reply-To: Alistair Francis Cc: alistair.francis@wdc.com Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" With RV32 support the list of possible RISC-V system directories increases to: - /lib64/lp64d - /lib64/lp64 - /lib32/ilp32d - /lib32/ilp32 - /lib (only ld.so) This patch changes the add_system_di () macro to support the new ilp32d and ilp32 directories for RV32. While refactoring this code let's split out the confusing if statements into a loop to make it easier to understand and extend. --- sysdeps/unix/sysv/linux/riscv/dl-cache.h | 39 +++++++++++++++++------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/sysdeps/unix/sysv/linux/riscv/dl-cache.h b/sysdeps/unix/sysv/linux/riscv/dl-cache.h index b3cda4ef9f..7317406036 100644 --- a/sysdeps/unix/sysv/linux/riscv/dl-cache.h +++ b/sysdeps/unix/sysv/linux/riscv/dl-cache.h @@ -30,10 +30,12 @@ ((flags) == _DL_CACHE_DEFAULT_ID) /* If given a path to one of our library directories, adds every library - directory via add_dir (), otherwise just adds the giver directory. On + directory via add_dir (), otherwise just adds the given directory. On RISC-V, libraries can be found in paths ending in: - /lib64/lp64d - /lib64/lp64 + - /lib32/ilp32d + - /lib32/ilp32 - /lib (only ld.so) so this will add all of those paths. @@ -45,25 +47,40 @@ architectures and have that automatically imply /usr/local/lib64/lp64d etc. so that libraries can be found that come from software that does use the ABI-specific directories. */ + #define add_system_dir(dir) \ do \ { \ + static const char* lib_dirs[] = { \ + "/lib64/lp64d", \ + "/lib64/lp64", \ + "/lib32/ilp32d", \ + "/lib32/ilp32", \ + NULL, \ + }; \ size_t len = strlen (dir); \ - char path[len + 9]; \ + char path[len + 10]; \ memcpy (path, dir, len + 1); \ - if (len >= 12 && ! memcmp(path + len - 12, "/lib64/lp64d", 12)) \ - { \ - len -= 8; \ - path[len] = '\0'; \ - } \ - if (len >= 11 && ! memcmp(path + len - 11, "/lib64/lp64", 11)) \ - { \ - len -= 7; \ - path[len] = '\0'; \ + int i = 0; \ + const char* lib_dir = lib_dirs[0]; \ + \ + while (lib_dir != NULL) { \ + size_t dir_len = strlen (lib_dir); \ + if (len >= dir_len && ! memcmp(path + len - dir_len, lib_dir, dir_len)) { \ + len -= dir_len + 4; \ + path[len] = '\0'; \ + break; \ + } \ + i++; \ + lib_dir = lib_dirs[i]; \ } \ add_dir (path); \ if (len >= 4 && ! memcmp(path + len - 4, "/lib", 4)) \ { \ + memcpy (path + len, "32/ilp32d", 10); \ + add_dir (path); \ + memcpy (path + len, "32/ilp32", 9); \ + add_dir (path); \ memcpy (path + len, "64/lp64d", 9); \ add_dir (path); \ memcpy (path + len, "64/lp64", 8); \