From patchwork Sun Mar 9 06:00:37 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiaotian Wu X-Patchwork-Id: 58519 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2A632C282D1 for ; Sun, 9 Mar 2025 06:00:58 +0000 (UTC) Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by mx.groups.io with SMTP id smtpd.web10.10950.1741500055467681158 for ; Sat, 08 Mar 2025 22:00:56 -0800 Authentication-Results: mx.groups.io; dkim=none (message not signed); spf=pass (domain: loongson.cn, ip: 114.242.206.163, mailfrom: wuxiaotian@loongson.cn) Received: from loongson.cn (unknown [192.168.100.1]) by gateway (Coremail) with SMTP id _____8Axz3OVLs1nPJqPAA--.48070S3; Sun, 09 Mar 2025 14:00:53 +0800 (CST) Received: from localhost.localdomain (unknown [192.168.100.1]) by front1 (Coremail) with SMTP id qMiowMBxb8eSLs1nJr0_AA--.40372S3; Sun, 09 Mar 2025 14:00:52 +0800 (CST) From: Xiaotian Wu To: yocto-patches@lists.yoctoproject.org Cc: Xiaotian Wu Subject: [pseudo] [PATCH 1/3] pseudo_wrappers.c: Add support for LoongArch64 Date: Sun, 9 Mar 2025 14:00:37 +0800 Message-ID: <20250309060039.454124-2-wuxiaotian@loongson.cn> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250309060039.454124-1-wuxiaotian@loongson.cn> References: <20250309060039.454124-1-wuxiaotian@loongson.cn> MIME-Version: 1.0 X-CM-TRANSID: qMiowMBxb8eSLs1nJr0_AA--.40372S3 X-CM-SenderInfo: 5zx0xtprwlt0o6or00hjvr0hdfq/1tbiAgEQCGfMz2ABsQALsk X-Coremail-Antispam: 1Uk129KBj93XoWxGFy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Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Sun, 09 Mar 2025 06:00:58 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/yocto-patches/message/1167 Since these symbols do not exist in LoongArch's libc.so, they need to be remapped, and the first "ver" function parameter does not exist in the mapped function. __fxstat __fxstat64 __fxstatat __fxstatat64 __lxstat __lxstat64 __xmknod __xmknodat __xstat __xstat64 Signed-off-by: Xiaotian Wu --- pseudo_wrappers.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/pseudo_wrappers.c b/pseudo_wrappers.c index 9ae1200..b54b0c3 100644 --- a/pseudo_wrappers.c +++ b/pseudo_wrappers.c @@ -122,6 +122,64 @@ pseudo_reinit_libpseudo(void) { _libpseudo_init(); } +#if defined(__loongarch_lp64) +#define LOAD_REAL_SYMBOL(name, symbol) \ + pseudo_real_##name = dlsym(RTLD_NEXT, symbol); \ + real_##name = pseudo_##name + +static int (*pseudo_real___fxstat)(int fd, struct stat *buf) = NULL; +static int (*pseudo_real___fxstat64)(int fd, struct stat64 *buf) = NULL; +static int (*pseudo_real___fxstatat)(int dirfd, const char *path, struct stat *buf, int flags) = NULL; +static int (*pseudo_real___fxstatat64)(int dirfd, const char *path, struct stat64 *buf, int flags) = NULL; +static int (*pseudo_real___lxstat)(const char *path, struct stat *buf) = NULL; +static int (*pseudo_real___lxstat64)(const char *path, struct stat64 *buf) = NULL; +static int (*pseudo_real___xmknod)(const char *path, mode_t mode, dev_t *dev) = NULL; +static int (*pseudo_real___xmknodat)(int dirfd, const char *path, mode_t mode, dev_t *dev) = NULL; +static int (*pseudo_real___xstat)(const char *path, struct stat *buf) = NULL; +static int (*pseudo_real___xstat64)(const char *path, struct stat64 *buf) = NULL; + +static int pseudo___fxstat(int ver __attribute__((unused)), int fd, struct stat *buf) +{ + return pseudo_real___fxstat(fd, buf); +} +static int pseudo___fxstat64(int ver __attribute__((unused)), int fd, struct stat64 *buf) +{ + return pseudo_real___fxstat64(fd, buf); +} +static int pseudo___fxstatat(int ver __attribute__((unused)), int dirfd, const char *path, struct stat *buf, int flags) +{ + return pseudo_real___fxstatat(dirfd, path, buf, flags); +} +static int pseudo___fxstatat64(int ver __attribute__((unused)), int dirfd, const char *path, struct stat64 *buf, int flags) +{ + return pseudo_real___fxstatat64(dirfd, path, buf, flags); +} +static int pseudo___lxstat(int ver __attribute__((unused)), const char *path, struct stat *buf) +{ + return pseudo_real___lxstat(path, buf); +} +static int pseudo___lxstat64(int ver __attribute__((unused)), const char *path, struct stat64 *buf) +{ + return pseudo_real___lxstat64(path, buf); +} +static int pseudo___xmknod(int ver __attribute__((unused)), const char *path, mode_t mode, dev_t *dev) +{ + return pseudo_real___xmknod(path, mode, dev); +} +static int pseudo___xmknodat(int ver __attribute__((unused)), int dirfd, const char *path, mode_t mode, dev_t *dev) +{ + return pseudo_real___xmknodat(dirfd, path, mode, dev); +} +static int pseudo___xstat(int ver __attribute__((unused)), const char *path, struct stat *buf) +{ + return pseudo_real___xstat(path, buf); +} +static int pseudo___xstat64(int ver __attribute__((unused)), const char *path, struct stat64 *buf) +{ + return pseudo_real___xstat64(path, buf); +} +#endif + static void pseudo_init_one_wrapper(pseudo_function *func) { int (*f)(void) = (int (*)(void)) NULL; @@ -185,6 +243,18 @@ pseudo_init_wrappers(void) { pseudo_real_fork = dlsym(RTLD_NEXT, "fork"); pseudo_real_execv = dlsym(RTLD_NEXT, "execv"); +#if defined(__loongarch_lp64) + LOAD_REAL_SYMBOL(__fxstat, "fstat"); + LOAD_REAL_SYMBOL(__fxstat64, "fstat64"); + LOAD_REAL_SYMBOL(__fxstatat, "fstatat"); + LOAD_REAL_SYMBOL(__fxstatat64, "fstatat64"); + LOAD_REAL_SYMBOL(__lxstat, "lstat"); + LOAD_REAL_SYMBOL(__lxstat64, "lstat64"); + LOAD_REAL_SYMBOL(__xmknod, "mknod"); + LOAD_REAL_SYMBOL(__xmknodat, "mknodat"); + LOAD_REAL_SYMBOL(__xstat, "stat"); + LOAD_REAL_SYMBOL(__xstat64, "stat64"); +#endif /* Once the wrappers are setup, we can now use open... so * setup the logfile, if necessary... */ From patchwork Sun Mar 9 06:00:38 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiaotian Wu X-Patchwork-Id: 58520 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0CA4FC28B30 for ; Sun, 9 Mar 2025 06:01:08 +0000 (UTC) Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by mx.groups.io with SMTP id smtpd.web10.10952.1741500057099942795 for ; Sat, 08 Mar 2025 22:00:57 -0800 Authentication-Results: mx.groups.io; dkim=none (message not signed); spf=pass (domain: loongson.cn, ip: 114.242.206.163, mailfrom: wuxiaotian@loongson.cn) Received: from loongson.cn (unknown [192.168.100.1]) by gateway (Coremail) with SMTP id _____8AxaeCXLs1nPZqPAA--.49779S3; Sun, 09 Mar 2025 14:00:55 +0800 (CST) Received: from localhost.localdomain (unknown [192.168.100.1]) by front1 (Coremail) with SMTP id qMiowMBxb8eSLs1nJr0_AA--.40372S4; Sun, 09 Mar 2025 14:00:55 +0800 (CST) From: Xiaotian Wu To: yocto-patches@lists.yoctoproject.org Cc: Xiaotian Wu Subject: [pseudo] [PATCH 2/3] Makefile.in: Use ARCH_FLAGS instead of -m32 and -m64 Date: Sun, 9 Mar 2025 14:00:38 +0800 Message-ID: <20250309060039.454124-3-wuxiaotian@loongson.cn> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250309060039.454124-1-wuxiaotian@loongson.cn> References: <20250309060039.454124-1-wuxiaotian@loongson.cn> MIME-Version: 1.0 X-CM-T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04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7 CjxVAFwI0_Jr0_GrUvcSsGvfC2KfnxnUUI43ZEXa7IU1QVy3UUUUU== List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Sun, 09 Mar 2025 06:01:08 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/yocto-patches/message/1168 Gcc on Loongarch does not support this -m32 and -m64 options. we can use the $(ARCH_CLAGS) variable instead. Signed-off-by: Xiaotian Wu --- Makefile.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile.in b/Makefile.in index 48fdbd2..0bb8a88 100644 --- a/Makefile.in +++ b/Makefile.in @@ -157,10 +157,10 @@ pseudo_wrappers.o: $(GUTS) pseudo_wrappers.c pseudo_wrapfuncs.c pseudo_wrapfuncs $(CC) -fno-strict-aliasing $(CFLAGS) $(CFLAGS_PSEUDO) -D_GNU_SOURCE -c -o pseudo_wrappers.o pseudo_wrappers.c offsets32: - $(CC) -m32 -o offsets32 offsets.c + $(CC) $(ARCH_FLAGS) -o offsets32 offsets.c offsets64: - $(CC) -m64 -o offsets64 offsets.c + $(CC) $(ARCH_FLAGS) -o offsets64 offsets.c $(PSEUDO_PROFILE): pseudo_profile | $(BIN) cp pseudo_profile $(BIN) From patchwork Sun Mar 9 06:00:39 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiaotian Wu X-Patchwork-Id: 58521 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A252C28B2E for ; Sun, 9 Mar 2025 06:01:08 +0000 (UTC) Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by mx.groups.io with SMTP id smtpd.web10.10953.1741500058660086762 for ; Sat, 08 Mar 2025 22:00:59 -0800 Authentication-Results: mx.groups.io; dkim=none (message not signed); spf=pass (domain: loongson.cn, ip: 114.242.206.163, mailfrom: wuxiaotian@loongson.cn) Received: from loongson.cn (unknown [192.168.100.1]) by gateway (Coremail) with SMTP id _____8AxCGqYLs1nPpqPAA--.48388S3; Sun, 09 Mar 2025 14:00:56 +0800 (CST) Received: from localhost.localdomain (unknown [192.168.100.1]) by front1 (Coremail) with SMTP id qMiowMBxb8eSLs1nJr0_AA--.40372S5; Sun, 09 Mar 2025 14:00:56 +0800 (CST) From: Xiaotian Wu To: yocto-patches@lists.yoctoproject.org Cc: Xiaotian Wu Subject: [pseudo] [PATCH 3/3] configure: Add support for LoongArch Date: Sun, 9 Mar 2025 14:00:39 +0800 Message-ID: <20250309060039.454124-4-wuxiaotian@loongson.cn> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250309060039.454124-1-wuxiaotian@loongson.cn> References: <20250309060039.454124-1-wuxiaotian@loongson.cn> MIME-Version: 1.0 X-CM-TRANSID: qMiowMBxb8eSLs1nJr0_AA--.40372S5 X-CM-SenderInfo: 5zx0xtprwlt0o6or00hjvr0hdfq/1tbiAgEQCGfMz2ABzgAAsQ X-Coremail-Antispam: 1Uk129KBj9xXoW7GryrJrW5tF1UJryxJFyUtwc_yoWfGwb_ZF yxXryrAw43tFykC342gr4Fv34fXaykJFnYka1qqr4xArWxJr47Wa93X3WkAF4UtF1v9r1S qrWIv3Z5ArnrJosvyTuYvTs0mTUanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUj1kv1TuYvT s0mT0YCTnIWjqI5I8CrVACY4xI64kE6c02F40Ex7xfYxn0WfASr-VFAUDa7-sFnT9fnUUI cSsGvfJTRUUUb7AYFVCjjxCrM7AC8VAFwI0_Jr0_Gr1l1xkIjI8I6I8E6xAIw20EY4v20x vaj40_Wr0E3s1l1IIY67AEw4v_Jr0_Jr4l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxS w2x7M28EF7xvwVC0I7IYx2IY67AKxVW5JVW7JwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxV W8JVWxJwA2z4x0Y4vEx4A2jsIE14v26r4UJVWxJr1l84ACjcxK6I8E87Iv6xkF7I0E14v2 6r4UJVWxJr1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqjxCEc2xF0cIa020Ex4CE44I27w Aqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_Jrv_JF1lYx0Ex4A2jsIE 14v26r1j6r4UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x0EwIxGrwCF04k20xvY0x 0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E 7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Jrv_JF1lIxkGc2Ij64vIr41lIxAIcV C0I7IYx2IY67AKxVWUCVW8JwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Jr0_Gr1lIxAIcVCF 04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7 CjxVAFwI0_Jr0_GrUvcSsGvfC2KfnxnUUI43ZEXa7IU1QVy3UUUUU== List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Sun, 09 Mar 2025 06:01:08 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/yocto-patches/message/1169 Set the default architecture based on the current machine Signed-off-by: Xiaotian Wu --- configure | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/configure b/configure index 39b5fbe..9fbba9a 100755 --- a/configure +++ b/configure @@ -22,8 +22,17 @@ opt_xattrdb=false opt_profile=false opt_passwd_fallback='""' +UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=x86 +case $UNAME_MACHINE in + i*86|x86_64) opt_arch=x86 ;; + arm|arm64) opt_arch=arm ;; + loongarch32|loongarch64) opt_arch=loongarch ;; +esac + compile_x86_32=-m32 compile_x86_64=-m64 +compile_loongarch_32= +compile_loongarch_64= usage() { @@ -170,7 +179,7 @@ do done case $opt_arch in -'' | x86 | arm ) +'' | x86 | arm | loongarch) ;; *) echo >&2 "Untested arch $opt_arch." ;;