Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/1.0/patches/2175897/?format=api
{ "id": 2175897, "url": "http://patchwork.ozlabs.org/api/1.0/patches/2175897/?format=api", "project": { "id": 41, "url": "http://patchwork.ozlabs.org/api/1.0/projects/41/?format=api", "name": "GNU C Library", "link_name": "glibc", "list_id": "libc-alpha.sourceware.org", "list_email": "libc-alpha@sourceware.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20251219102029.2379555-5-mengqinggang@loongson.cn>", "date": "2025-12-19T10:20:28", "name": "[v3,4/5] LoongArch: Add support for LA32 in sysdeps/unix/sysv/linux/loongarch", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "222e8863f4d5882cb3a3734a161e57d7ccef7ddb", "submitter": { "id": 87178, "url": "http://patchwork.ozlabs.org/api/1.0/people/87178/?format=api", "name": "mengqinggang", "email": "mengqinggang@loongson.cn" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/glibc/patch/20251219102029.2379555-5-mengqinggang@loongson.cn/mbox/", "series": [ { "id": 485974, "url": "http://patchwork.ozlabs.org/api/1.0/series/485974/?format=api", "date": "2025-12-19T10:20:24", "name": "Add support for LoongArch32", "version": 3, "mbox": "http://patchwork.ozlabs.org/series/485974/mbox/" } ], "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2175897/checks/", "tags": {}, "headers": { "Return-Path": "<libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org>", "X-Original-To": [ "incoming@patchwork.ozlabs.org", "libc-alpha@sourceware.org" ], "Delivered-To": [ "patchwork-incoming@legolas.ozlabs.org", "libc-alpha@sourceware.org" ], "Authentication-Results": [ "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org\n (client-ip=38.145.34.32; helo=vm01.sourceware.org;\n envelope-from=libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org;\n receiver=patchwork.ozlabs.org)", "sourceware.org;\n dmarc=none (p=none dis=none) header.from=loongson.cn", "sourceware.org; spf=pass smtp.mailfrom=loongson.cn", "server2.sourceware.org;\n arc=none smtp.remote-ip=114.242.206.163" ], "Received": [ "from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4dXkDd2MJHz1xty\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 19 Dec 2025 21:24:49 +1100 (AEDT)", "from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 690794BA2E3D\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 19 Dec 2025 10:24:47 +0000 (GMT)", "from mail.loongson.cn (mail.loongson.cn [114.242.206.163])\n by sourceware.org (Postfix) with ESMTP id 4CACA4BA23C4\n for <libc-alpha@sourceware.org>; Fri, 19 Dec 2025 10:22:40 +0000 (GMT)", "from loongson.cn (unknown [10.2.6.7])\n by gateway (Coremail) with SMTP id _____8BxHMNSJ0VpDNMAAA--.2696S3;\n Fri, 19 Dec 2025 18:22:10 +0800 (CST)", "from amd9754.. (unknown [10.2.6.7])\n by front1 (Coremail) with SMTP id qMiowJAx38JSJ0VpacEBAA--.6524S2;\n Fri, 19 Dec 2025 18:22:10 +0800 (CST)" ], "DKIM-Filter": [ "OpenDKIM Filter v2.11.0 sourceware.org 690794BA2E3D", "OpenDKIM Filter v2.11.0 sourceware.org 4CACA4BA23C4" ], "DMARC-Filter": "OpenDMARC Filter v1.4.2 sourceware.org 4CACA4BA23C4", "ARC-Filter": "OpenARC Filter v1.0.0 sourceware.org 4CACA4BA23C4", "ARC-Seal": "i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1766139761; cv=none;\n b=LpGI/vCS3T9NQw8FXqJl5XwNTNvWxtftvN1vatpKCGmYRNW4StOVoF/CkvnuDwpiekFEtbg+TacU2gmQzflg0OxmGPMw6+rd6SifijgriowbLs/atyxANDdsxOCcUena9yBVcBuYBA77d/TgejFcAk5qXCYwV0Kj4TsRIe/6o0U=", "ARC-Message-Signature": "i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1766139761; c=relaxed/simple;\n bh=QsQqzc/MWqgoGd/T1w+DMlJqTEgm7nsOWAIl8Hlq2tY=;\n h=From:To:Subject:Date:Message-Id:MIME-Version;\n b=JU7MyGBQ7rMbW3VWMd6j6qla7Kb6hf4nwRFAh1Ox6fPNmOXyBxpY+/qOwd3QKNw8FYja2bw6/0YMMveLzcKxGCeSK6LmH3eWGRtl7kNkCW5WiDGfe2Vwq92iIY5OzF2cEjcImu1AdYQoyRQCSdCiyQiDAYZdjxY+GHtrwwxpwI0=", "ARC-Authentication-Results": "i=1; server2.sourceware.org", "From": "mengqinggang <mengqinggang@loongson.cn>", "To": "libc-alpha@sourceware.org", "Cc": "adhemerval.zanella@linaro.org, xuchenghua@loongson.cn,\n caiyinyu@loongson.cn, chenglulu@loongson.cn, cailulu@loongson.cn,\n xry111@xry111.site, i.swmail@xen0n.name, maskray@google.com,\n luweining@loongson.cn, hejinyang@loongson.cn, mengqinggang@loongson.cn", "Subject": "[PATCH v3 4/5] LoongArch: Add support for LA32 in\n sysdeps/unix/sysv/linux/loongarch", "Date": "Fri, 19 Dec 2025 18:20:28 +0800", "Message-Id": "<20251219102029.2379555-5-mengqinggang@loongson.cn>", "X-Mailer": "git-send-email 2.34.1", "In-Reply-To": "<20251219102029.2379555-1-mengqinggang@loongson.cn>", "References": "<20251219102029.2379555-1-mengqinggang@loongson.cn>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "X-CM-TRANSID": "qMiowJAx38JSJ0VpacEBAA--.6524S2", "X-CM-SenderInfo": "5phqw15lqjwttqj6z05rqj20fqof0/", "X-Coremail-Antispam": "1Uk129KBjDUn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7KY7\n ZEXasCq-sGcSsGvfJ3UbIjqfuFe4nvWSU5nxnvy29KBjDU0xBIdaVrnUUvcSsGvfC2Kfnx\n nUUI43ZEXa7xR_UUUUUUUUU==", "X-BeenThere": "libc-alpha@sourceware.org", "X-Mailman-Version": "2.1.30", "Precedence": "list", "List-Id": "Libc-alpha mailing list <libc-alpha.sourceware.org>", "List-Unsubscribe": "<https://sourceware.org/mailman/options/libc-alpha>,\n <mailto:libc-alpha-request@sourceware.org?subject=unsubscribe>", "List-Archive": "<https://sourceware.org/pipermail/libc-alpha/>", "List-Post": "<mailto:libc-alpha@sourceware.org>", "List-Help": "<mailto:libc-alpha-request@sourceware.org?subject=help>", "List-Subscribe": "<https://sourceware.org/mailman/listinfo/libc-alpha>,\n <mailto:libc-alpha-request@sourceware.org?subject=subscribe>", "Errors-To": "libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org" }, "content": "---\n sysdeps/unix/sysv/linux/loongarch/Makefile | 4 +-\n sysdeps/unix/sysv/linux/loongarch/clone.S | 10 ++---\n sysdeps/unix/sysv/linux/loongarch/clone3.S | 8 ++--\n sysdeps/unix/sysv/linux/loongarch/configure | 40 +++++++++++++++++++\n .../unix/sysv/linux/loongarch/configure.ac | 8 ++++\n .../unix/sysv/linux/loongarch/getcontext.S | 12 +++---\n .../unix/sysv/linux/loongarch/gettimeofday.c | 9 +++--\n .../unix/sysv/linux/loongarch/ldd-rewrite.sed | 2 +-\n .../linux/loongarch/{ => lp64}/arch-syscall.h | 0\n .../unix/sysv/linux/loongarch/pointer_guard.h | 18 ++-------\n .../unix/sysv/linux/loongarch/readelflib.c | 33 +++++++++++----\n .../unix/sysv/linux/loongarch/setcontext.S | 24 +++++------\n .../unix/sysv/linux/loongarch/shlib-versions | 8 +++-\n .../unix/sysv/linux/loongarch/swapcontext.S | 28 ++++++-------\n .../sysv/linux/loongarch/syscall_cancel.S | 2 +-\n sysdeps/unix/sysv/linux/loongarch/sysdep.S | 8 ++--\n sysdeps/unix/sysv/linux/loongarch/sysdep.h | 30 +++++++++++---\n .../sysv/linux/loongarch/ucontext-macros.h | 6 ++-\n sysdeps/unix/sysv/linux/loongarch/vfork.S | 6 +--\n 19 files changed, 171 insertions(+), 85 deletions(-)\n rename sysdeps/unix/sysv/linux/loongarch/{ => lp64}/arch-syscall.h (100%)", "diff": "diff --git a/sysdeps/unix/sysv/linux/loongarch/Makefile b/sysdeps/unix/sysv/linux/loongarch/Makefile\nindex c84a1762ed..0d5f087862 100644\n--- a/sysdeps/unix/sysv/linux/loongarch/Makefile\n+++ b/sysdeps/unix/sysv/linux/loongarch/Makefile\n@@ -2,11 +2,13 @@ ifeq ($(subdir),stdlib)\n gen-as-const-headers += ucontext_i.sym\n endif\n \n-abi-variants := lp64s lp64d\n+abi-variants := ilp32s ilp32d lp64s lp64d\n \n ifeq (,$(filter $(default-abi),$(abi-variants)))\n $(error Unknown ABI $(default-abi), must be one of $(abi-variants))\n endif\n \n+abi-ilp32s-condition\t:= __WORDSIZE == 32 && defined __loongarch_soft_float\n+abi-ilp32d-condition\t:= __WORDSIZE == 32 && defined __loongarch_double_float\n abi-lp64s-condition\t:= __WORDSIZE == 64 && defined __loongarch_soft_float\n abi-lp64d-condition\t:= __WORDSIZE == 64 && defined __loongarch_double_float\ndiff --git a/sysdeps/unix/sysv/linux/loongarch/clone.S b/sysdeps/unix/sysv/linux/loongarch/clone.S\nindex 2a68dd31ea..c5a82ba2cc 100644\n--- a/sysdeps/unix/sysv/linux/loongarch/clone.S\n+++ b/sysdeps/unix/sysv/linux/loongarch/clone.S\n@@ -33,13 +33,13 @@\n ENTRY (__clone)\n \n \t/* Align stack to 16. */\n-\tBSTRINS\t\ta1, zero, 3, 0\n+\tREG_ALIGN_ASM (a1, 4)\n \n \t/* Sanity check arguments. */\n-\tbeqz\t\ta0, L (invalid) /* No NULL function pointers. */\n-\tbeqz\t\ta1, L (invalid) /* No NULL stack pointers. */\n+\tbeq\t\ta0, zero, L (invalid) /* No NULL function pointers. */\n+\tbeq\t\ta1, zero, L (invalid) /* No NULL stack pointers. */\n \n-\tADDI \t\ta1, a1, -16 /* Reserve argument save space. */\n+\tADDI \t\ta1, a1, -STACK_ALIGN /* Reserve argument save space. */\n \tREG_S\t\ta0, a1, 0 /* Save function pointer. */\n \tREG_S\t\ta3, a1, SZREG /* Save argument pointer. */\n \n@@ -54,7 +54,7 @@ ENTRY (__clone)\n \tsyscall\t\t0\n \n \tblt\t\ta0, zero ,L (error)\n-\tbeqz\t\ta0,L (thread_start)\n+\tbeq\t\ta0, zero, L (thread_start)\n \n \t/* Successful return from the parent. */\n \tret\ndiff --git a/sysdeps/unix/sysv/linux/loongarch/clone3.S b/sysdeps/unix/sysv/linux/loongarch/clone3.S\nindex 39d43ca6e8..d2c116e429 100644\n--- a/sysdeps/unix/sysv/linux/loongarch/clone3.S\n+++ b/sysdeps/unix/sysv/linux/loongarch/clone3.S\n@@ -33,15 +33,15 @@\n ENTRY (__clone3)\n \n \t/* Sanity check arguments. */\n-\tbeqz\t\ta0, L (invalid)\t/* No NULL cl_args pointer. */\n-\tbeqz\t\ta2, L (invalid)\t/* No NULL function pointer. */\n+\tbeq\t\ta0, zero, L (invalid)\t/* No NULL cl_args pointer. */\n+\tbeq\t\ta2, zero, L (invalid)\t/* No NULL function pointer. */\n \n \t/* Do the system call. */\n \tLI\t\ta7, __NR_clone3\n \tsyscall\t\t0\n \n \tblt\t\ta0, zero ,L (error)\n-\tbeqz\t\ta0, L (thread_start3)\n+\tbeq\t\ta0, zero, L (thread_start3)\n \n \t/* Successful return from the parent. */\n \tret\n@@ -67,7 +67,7 @@ L (thread_start3):\n \tcfi_undefined (1)\n \n \t/* Align stack to 16. */\n-\tBSTRINS\t\tsp, zero, 3, 0\n+\tREG_ALIGN_ASM (sp, 4)\n \n \t/* Set up arguments for the function call. */\n \tmove\t\ta0, a3\t\t/* Argument. */\ndiff --git a/sysdeps/unix/sysv/linux/loongarch/configure b/sysdeps/unix/sysv/linux/loongarch/configure\nindex 914943f914..4a08e96487 100644\n--- a/sysdeps/unix/sysv/linux/loongarch/configure\n+++ b/sysdeps/unix/sysv/linux/loongarch/configure\n@@ -152,6 +152,18 @@ then :\n fi\n rm -rf conftest*\n \n+cat confdefs.h - <<_ACEOF >conftest.$ac_ext\n+/* end confdefs.h. */\n+__SIZEOF_INT__ __SIZEOF_LONG__ __SIZEOF_POINTER__\n+\n+_ACEOF\n+if (eval \"$ac_cpp conftest.$ac_ext\") 2>&5 |\n+ $EGREP_TRADITIONAL \"4 4 4\" >/dev/null 2>&1\n+then :\n+ libc_cv_loongarch_int_abi=ilp32\n+fi\n+rm -rf conftest*\n+\n if test $libc_cv_loongarch_int_abi = no; then\n as_fn_error $? \"Unable to determine integer ABI\" \"$LINENO\" 5\n fi\n@@ -193,6 +205,34 @@ config_vars=\"$config_vars\n default-abi = $libc_cv_loongarch_int_abi$libc_cv_loongarch_float_abi\"\n \n case $libc_cv_loongarch_int_abi$libc_cv_loongarch_float_abi in\n+ilp32s)\n+ test -n \"$libc_cv_slibdir\" ||\n+case \"$prefix\" in\n+/usr | /usr/)\n+ libc_cv_slibdir='/lib32/sf'\n+ libc_cv_rtlddir='/lib32'\n+ if test \"$libdir\" = '${exec_prefix}/lib'; then\n+ libdir='${exec_prefix}/lib32/sf';\n+ # Locale data can be shared between 32-bit and 64-bit libraries.\n+ libc_cv_complocaledir='${exec_prefix}/lib/locale'\n+ fi\n+ ;;\n+esac\n+ ;;\n+ilp32d)\n+ test -n \"$libc_cv_slibdir\" ||\n+case \"$prefix\" in\n+/usr | /usr/)\n+ libc_cv_slibdir='/lib32'\n+ libc_cv_rtlddir='/lib32'\n+ if test \"$libdir\" = '${exec_prefix}/lib'; then\n+ libdir='${exec_prefix}/lib32';\n+ # Locale data can be shared between 32-bit and 64-bit libraries.\n+ libc_cv_complocaledir='${exec_prefix}/lib/locale'\n+ fi\n+ ;;\n+esac\n+ ;;\n lp64s)\n test -n \"$libc_cv_slibdir\" ||\n case \"$prefix\" in\ndiff --git a/sysdeps/unix/sysv/linux/loongarch/configure.ac b/sysdeps/unix/sysv/linux/loongarch/configure.ac\nindex 04e9150a9b..f020fd34ec 100644\n--- a/sysdeps/unix/sysv/linux/loongarch/configure.ac\n+++ b/sysdeps/unix/sysv/linux/loongarch/configure.ac\n@@ -7,6 +7,8 @@ arch_minimum_kernel=5.19.0\n libc_cv_loongarch_int_abi=no\n AC_EGREP_CPP(4 8 8, [__SIZEOF_INT__ __SIZEOF_LONG__ __SIZEOF_POINTER__\n ], libc_cv_loongarch_int_abi=lp64)\n+AC_EGREP_CPP(4 4 4, [__SIZEOF_INT__ __SIZEOF_LONG__ __SIZEOF_POINTER__\n+ ], libc_cv_loongarch_int_abi=ilp32)\n if test $libc_cv_loongarch_int_abi = no; then\n AC_MSG_ERROR([Unable to determine integer ABI])\n fi\n@@ -27,6 +29,12 @@ fi\n LIBC_CONFIG_VAR([default-abi], [$libc_cv_loongarch_int_abi$libc_cv_loongarch_float_abi])\n \n case $libc_cv_loongarch_int_abi$libc_cv_loongarch_float_abi in\n+ilp32s)\n+ LIBC_SLIBDIR_RTLDDIR([lib32/sf], [lib32])\n+ ;;\n+ilp32d)\n+ LIBC_SLIBDIR_RTLDDIR([lib32], [lib32])\n+ ;;\n lp64s)\n LIBC_SLIBDIR_RTLDDIR([lib64/sf], [lib64])\n ;;\ndiff --git a/sysdeps/unix/sysv/linux/loongarch/getcontext.S b/sysdeps/unix/sysv/linux/loongarch/getcontext.S\nindex 4e78c7c717..eef4c0c2cc 100644\n--- a/sysdeps/unix/sysv/linux/loongarch/getcontext.S\n+++ b/sysdeps/unix/sysv/linux/loongarch/getcontext.S\n@@ -36,16 +36,16 @@ LEAF (__getcontext)\n \tSAVE_INT_REG (s6, 29, a0)\n \tSAVE_INT_REG (s7, 30, a0)\n \tSAVE_INT_REG (s8, 31, a0)\n-\tst.d\t\tra, a0, MCONTEXT_PC\n+\tREG_S\t\tra, a0, MCONTEXT_PC\n \n /* rt_sigprocmask (SIG_BLOCK, NULL, &ucp->uc_sigmask, _NSIG8) */\n-\tli.d\t\ta3, _NSIG8\n-\tli.d\t\ta2, UCONTEXT_SIGMASK\n-\tadd.d\t\ta2, a2, a0\n+\tLI\t\ta3, _NSIG8\n+\tLI\t\ta2, UCONTEXT_SIGMASK\n+\tADD\t\ta2, a2, a0\n \tori\t\ta1, zero,0\n-\tli.d\t\ta0, SIG_BLOCK\n+\tLI\t\ta0, SIG_BLOCK\n \n-\tli.d\t\ta7, SYS_ify (rt_sigprocmask)\n+\tLI\t\ta7, SYS_ify (rt_sigprocmask)\n \tsyscall\t\t0\n \tblt\t\ta0, zero, 99f\n \ndiff --git a/sysdeps/unix/sysv/linux/loongarch/gettimeofday.c b/sysdeps/unix/sysv/linux/loongarch/gettimeofday.c\nindex 93ea6ce445..b084d52769 100644\n--- a/sysdeps/unix/sysv/linux/loongarch/gettimeofday.c\n+++ b/sysdeps/unix/sysv/linux/loongarch/gettimeofday.c\n@@ -17,6 +17,9 @@\n License along with the GNU C Library. If not, see\n <https://www.gnu.org/licenses/>. */\n \n-\n-#define USE_IFUNC_GETTIMEOFDAY\n-#include <sysdeps/unix/sysv/linux/gettimeofday.c>\n+#ifdef __loongarch64\n+ #define USE_IFUNC_GETTIMEOFDAY\n+ #include <sysdeps/unix/sysv/linux/gettimeofday.c>\n+# else\n+ #include <sysdeps/unix/sysv/linux/gettimeofday.c>\n+#endif\ndiff --git a/sysdeps/unix/sysv/linux/loongarch/ldd-rewrite.sed b/sysdeps/unix/sysv/linux/loongarch/ldd-rewrite.sed\nindex cdbe5c3dc5..a868370aca 100644\n--- a/sysdeps/unix/sysv/linux/loongarch/ldd-rewrite.sed\n+++ b/sysdeps/unix/sysv/linux/loongarch/ldd-rewrite.sed\n@@ -1 +1 @@\n-s_^\\(RTLDLIST=\\)\\(.*lib\\)\\(\\|64\\|32\\)\\(/ld-linux-loongarch-\\)\\(lp\\|ilp\\)\\(64\\|32\\)\\(d\\|s\\)\\(\\.so\\.[0-9.]*\\)[[:blank:]]*$_\\1\"\\264\\4lp64d\\8 \\264\\4lp64s\\8\"_\n+s_^\\(RTLDLIST=\\)\\(.*lib\\)\\(\\|64\\|32\\)\\(/ld-linux-loongarch-\\)\\(lp\\|ilp\\)\\(64\\|32\\)\\(d\\|s\\)\\(\\.so\\.[0-9.]*\\)[[:blank:]]*$_\\1\"\\264\\4lp64d\\8 \\264\\4lp64s\\8 \\232\\4ilp32d\\8 \\232\\4ilp32s\\8\"_\ndiff --git a/sysdeps/unix/sysv/linux/loongarch/arch-syscall.h b/sysdeps/unix/sysv/linux/loongarch/lp64/arch-syscall.h\nsimilarity index 100%\nrename from sysdeps/unix/sysv/linux/loongarch/arch-syscall.h\nrename to sysdeps/unix/sysv/linux/loongarch/lp64/arch-syscall.h\ndiff --git a/sysdeps/unix/sysv/linux/loongarch/pointer_guard.h b/sysdeps/unix/sysv/linux/loongarch/pointer_guard.h\nindex 00f4ad79ad..b08686d375 100644\n--- a/sysdeps/unix/sysv/linux/loongarch/pointer_guard.h\n+++ b/sysdeps/unix/sysv/linux/loongarch/pointer_guard.h\n@@ -19,26 +19,16 @@\n #ifndef POINTER_GUARD_H\n #define POINTER_GUARD_H\n \n-/* Load a got-relative EXPR into register G. */\n-#define LD_GLOBAL(G, EXPR) \\\n- la.global G, EXPR; \\\n- REG_L G, G, 0;\n-\n-/* Load a pc-relative EXPR into register G. */\n-#define LD_PCREL(G, EXPR) \\\n- pcalau12i G, %pc_hi20(EXPR); \\\n- REG_L G, G, %pc_lo12(EXPR);\n-\n #if (IS_IN (rtld) \\\n || (!defined SHARED && (IS_IN (libc) \\\n || IS_IN (libpthread))))\n \n #ifdef __ASSEMBLER__\n #define PTR_MANGLE(dst, src, guard) \\\n- LD_PCREL (guard, __pointer_chk_guard_local); \\\n+ LOAD_LOCAL (guard, __pointer_chk_guard_local); \\\n PTR_MANGLE2 (dst, src, guard);\n #define PTR_DEMANGLE(dst, src, guard) \\\n- LD_PCREL (guard, __pointer_chk_guard_local); \\\n+ LOAD_LOCAL (guard, __pointer_chk_guard_local); \\\n PTR_DEMANGLE2 (dst, src, guard);\n /* Use PTR_MANGLE2 for efficiency if guard is already loaded. */\n #define PTR_MANGLE2(dst, src, guard) \\\n@@ -57,10 +47,10 @@ extern uintptr_t __pointer_chk_guard_local attribute_relro attribute_hidden;\n \n #ifdef __ASSEMBLER__\n #define PTR_MANGLE(dst, src, guard) \\\n- LD_GLOBAL (guard, __pointer_chk_guard); \\\n+ LOAD_GLOBAL (guard, __pointer_chk_guard); \\\n PTR_MANGLE2 (dst, src, guard);\n #define PTR_DEMANGLE(dst, src, guard) \\\n- LD_GLOBAL (guard, __pointer_chk_guard); \\\n+ LOAD_GLOBAL (guard, __pointer_chk_guard); \\\n PTR_DEMANGLE2 (dst, src, guard);\n /* Use PTR_MANGLE2 for efficiency if guard is already loaded. */\n #define PTR_MANGLE2(dst, src, guard) \\\ndiff --git a/sysdeps/unix/sysv/linux/loongarch/readelflib.c b/sysdeps/unix/sysv/linux/loongarch/readelflib.c\nindex bb7d6d254b..9124f78f64 100644\n--- a/sysdeps/unix/sysv/linux/loongarch/readelflib.c\n+++ b/sysdeps/unix/sysv/linux/loongarch/readelflib.c\n@@ -17,6 +17,9 @@\n <https://www.gnu.org/licenses/>. */\n \n \n+int process_elf32_file (const char *file_name, const char *lib,\n+\t\t\tint *flag, unsigned int *isa_level, char **soname,\n+\t\t\tvoid *file_contents, size_t file_length);\n int process_elf64_file (const char *file_name, const char *lib,\n \t\t\tint *flag, unsigned int *isa_level, char **soname,\n \t\t\tvoid *file_contents, size_t file_length);\n@@ -31,6 +34,7 @@ process_elf_file (const char *file_name, const char *lib, int *flag,\n \t\t size_t file_length)\n {\n ElfW(Ehdr) *elf_header = (ElfW(Ehdr) *) file_contents;\n+ Elf32_Ehdr *elf32_header = (Elf32_Ehdr *) elf_header;\n Elf64_Ehdr *elf64_header = (Elf64_Ehdr *) elf_header;\n int ret;\n long flags;\n@@ -38,15 +42,24 @@ process_elf_file (const char *file_name, const char *lib, int *flag,\n /* LoongArch libraries are always libc.so.6+. */\n *flag = FLAG_ELF_LIBC6;\n \n- ret = process_elf64_file (file_name, lib, flag, isa_level, soname,\n+ if (elf_header->e_ident[EI_CLASS] == ELFCLASS32)\n+ {\n+ ret = process_elf32_file (file_name, lib, flag, isa_level, soname,\n+\t\t\t\tfile_contents, file_length);\n+ flags = elf32_header->e_flags & ~EF_LARCH_OBJABI_V1;\n+ }\n+ else\n+ {\n+ ret = process_elf64_file (file_name, lib, flag, isa_level, soname,\n \t\t\t\tfile_contents, file_length);\n \n- /* The EF_LARCH_OBJABI_V1 flag indicate which set of static relocations\n- the object might use and it only considered during static linking,\n- it does not reflect in runtime relocations. However some binutils\n- version might set it on dynamic shared object, so clear it to avoid\n- see the SO as unsupported. */\n- flags = elf64_header->e_flags & ~EF_LARCH_OBJABI_V1;\n+ /* The EF_LARCH_OBJABI_V1 flag indicate which set of static relocations\n+ the object might use and it only considered during static linking,\n+ it does not reflect in runtime relocations. However some binutils\n+ version might set it on dynamic shared object, so clear it to avoid\n+ see the SO as unsupported. */\n+ flags = elf64_header->e_flags & ~EF_LARCH_OBJABI_V1;\n+ }\n \n /* LoongArch linkers encode the floating point ABI as part of the ELF headers. */\n switch (flags & SUPPORTED_ELF_FLAGS)\n@@ -70,6 +83,12 @@ process_elf_file (const char *file_name, const char *lib, int *flag,\n }\n \n #undef __ELF_NATIVE_CLASS\n+#undef process_elf_file\n+#define process_elf_file process_elf32_file\n+#define __ELF_NATIVE_CLASS 32\n+#include \"elf/readelflib.c\"\n+#undef __ELF_NATIVE_CLASS\n+\n #undef process_elf_file\n #define process_elf_file process_elf64_file\n #define __ELF_NATIVE_CLASS 64\ndiff --git a/sysdeps/unix/sysv/linux/loongarch/setcontext.S b/sysdeps/unix/sysv/linux/loongarch/setcontext.S\nindex ef4830ad71..291c81b247 100644\n--- a/sysdeps/unix/sysv/linux/loongarch/setcontext.S\n+++ b/sysdeps/unix/sysv/linux/loongarch/setcontext.S\n@@ -30,22 +30,22 @@\n \t.text\n LEAF (__setcontext)\n \n-\taddi.d\t\tsp, sp, -16\n-\tst.d\t\ta0, sp, 0\t/* Save ucp to stack */\n+\tADDI\t\tsp, sp, -16\n+\tREG_S\t\ta0, sp, 0\t/* Save ucp to stack */\n \n /* rt_sigprocmask (SIG_SETMASK, &ucp->uc_sigmask, NULL, _NSIG8) */\n-\tli.d\t\ta3, _NSIG8\n-\tli.d\t\ta2, 0\n-\tli.d\t\ta1, UCONTEXT_SIGMASK\n-\tadd.d\t\ta1, a1, a0\n-\tli.d\t\ta0, SIG_SETMASK\n+\tLI\t\ta3, _NSIG8\n+\tLI\t\ta2, 0\n+\tLI\t\ta1, UCONTEXT_SIGMASK\n+\tADD\t\ta1, a1, a0\n+\tLI\t\ta0, SIG_SETMASK\n \n-\tli.d\t\ta7, SYS_ify (rt_sigprocmask)\n+\tLI\t\ta7, SYS_ify (rt_sigprocmask)\n \tsyscall\t\t0\n \n \tblt\t\ta0, $r0, 99f\n \n-\tld.d\t\tt0, sp, 0\t/* Load ucp to t0 */\n+\tREG_L\t\tt0, sp, 0\t/* Load ucp to t0 */\n \tcfi_def_cfa (12, 0)\n \n /* Note the contents of argument registers will be random\n@@ -72,11 +72,11 @@ LEAF (__setcontext)\n \tRESTORE_INT_REG(s7, 30, t0)\n \tRESTORE_INT_REG(s8, 31, t0)\n \n-\tld.d\t\tt1, t0, MCONTEXT_PC\n+\tREG_L\t\tt1, t0, MCONTEXT_PC\n \tjirl\t\t$r0,t1,0\n \n 99:\n-\taddi.d\t\tsp, sp, 16\n+\tADDI\t\tsp, sp, 16\n \tb\t\t__syscall_error\n \n PSEUDO_END (__setcontext)\n@@ -92,7 +92,7 @@ LEAF (__start_context)\n \n \t/* Invoke subsequent context if present, else exit(0). */\n \tori\t\ta0, s2, 0\n-\tbeqz\t\ts2, 1f\n+\tbeq\t\ts2, zero, 1f\n \tbl\t\t__setcontext\n 1:\n \tb\t\tHIDDEN_JUMPTARGET(exit)\ndiff --git a/sysdeps/unix/sysv/linux/loongarch/shlib-versions b/sysdeps/unix/sysv/linux/loongarch/shlib-versions\nindex 5f40e7f5ec..7f85251e91 100644\n--- a/sysdeps/unix/sysv/linux/loongarch/shlib-versions\n+++ b/sysdeps/unix/sysv/linux/loongarch/shlib-versions\n@@ -1,6 +1,10 @@\n-DEFAULT\t\tGLIBC_2.36\n+DEFAULT\t\tGLIBC_2.43\n \n-%if LOONGARCH_ABI_GRLEN == 64 && LOONGARCH_ABI_FRLEN == 64\n+%if LOONGARCH_ABI_GRLEN == 32 && LOONGARCH_ABI_FRLEN == 64\n+ld=ld-linux-loongarch-ilp32d.so.1\n+%elif LOONGARCH_ABI_GRLEN == 32 && LOONGARCH_ABI_FRLEN == 0\n+ld=ld-linux-loongarch-ilp32s.so.1\n+%elif LOONGARCH_ABI_GRLEN == 64 && LOONGARCH_ABI_FRLEN == 64\n ld=ld-linux-loongarch-lp64d.so.1\n %elif LOONGARCH_ABI_GRLEN == 64 && LOONGARCH_ABI_FRLEN == 0\n ld=ld-linux-loongarch-lp64s.so.1\ndiff --git a/sysdeps/unix/sysv/linux/loongarch/swapcontext.S b/sysdeps/unix/sysv/linux/loongarch/swapcontext.S\nindex 4b8a90bc2e..0ebdf85738 100644\n--- a/sysdeps/unix/sysv/linux/loongarch/swapcontext.S\n+++ b/sysdeps/unix/sysv/linux/loongarch/swapcontext.S\n@@ -22,8 +22,8 @@\n \n LEAF (__swapcontext)\n \tori\t\ta2, sp, 0\t\t/* Save sp to a2 */\n-\taddi.d\t\tsp, sp, -16\n-\tst.d\t\ta1, sp, 0\n+\tADDI\t\tsp, sp, -16\n+\tREG_S\t\ta1, sp, 0\n \tori\t\tt0, a1, 0\n \n \tSAVE_INT_REG (ra, 1, a0)\n@@ -41,22 +41,22 @@ LEAF (__swapcontext)\n \tSAVE_INT_REG (s7, 30, a0)\n \tSAVE_INT_REG (s8, 31, a0)\n \n-\tst.d\t\tra, a0, MCONTEXT_PC\n+\tREG_S\t\tra, a0, MCONTEXT_PC\n \n /* rt_sigprocmask (SIG_SETMASK, &ucp->uc_sigmask, &oucp->uc_sigmask, _NSIG8) */\n-\tli.d\t\ta3, _NSIG8\n-\tli.d\t\ta2, UCONTEXT_SIGMASK\n-\tadd.d\t\ta2, a2, a0\n-\tli.d\t\ta1, UCONTEXT_SIGMASK\n-\tadd.d\t\ta1, a1, t0\n-\tli.d\t\ta0, SIG_SETMASK\n-\n-\tli.d\t\ta7, SYS_ify (rt_sigprocmask)\n+\tLI\t\ta3, _NSIG8\n+\tLI\t\ta2, UCONTEXT_SIGMASK\n+\tADD\t\ta2, a2, a0\n+\tLI\t\ta1, UCONTEXT_SIGMASK\n+\tADD\t\ta1, a1, t0\n+\tLI\t\ta0, SIG_SETMASK\n+\n+\tLI\t\ta7, SYS_ify (rt_sigprocmask)\n \tsyscall\t\t0\n \n \tblt\t\ta0, zero, 99f\n \n-\tld.d\t\tt0, sp, 0\t\t/* Load a1 to t0 */\n+\tREG_L\t\tt0, sp, 0\t\t/* Load a1 to t0 */\n \n /* Note the contents of argument registers will be random\n unless makecontext() has been called. */\n@@ -82,12 +82,12 @@ LEAF (__swapcontext)\n \tRESTORE_INT_REG (s7, 30, t0)\n \tRESTORE_INT_REG (s8, 31, t0)\n \n-\tld.d\t\tt1, t0, MCONTEXT_PC\n+\tREG_L\t\tt1, t0, MCONTEXT_PC\n \tjirl\t\t$r0, t1, 0\n \n \n 99:\n-\taddi.d\t\tsp, sp, 16\n+\tADDI\t\tsp, sp, 16\n \tb\t\t__syscall_error\n \n PSEUDO_END (__swapcontext)\ndiff --git a/sysdeps/unix/sysv/linux/loongarch/syscall_cancel.S b/sysdeps/unix/sysv/linux/loongarch/syscall_cancel.S\nindex 1cc3d61626..a6c763d29d 100644\n--- a/sysdeps/unix/sysv/linux/loongarch/syscall_cancel.S\n+++ b/sysdeps/unix/sysv/linux/loongarch/syscall_cancel.S\n@@ -28,7 +28,7 @@ __syscall_cancel_arch_start:\n \t __syscall_do_cancel() */\n \tld.w\tt0, a0, 0\n \tandi\tt0, t0, TCB_CANCELED_BITMASK\n-\tbnez\tt0, 1f\n+\tbne\tt0, zero, 1f\n \n \t/* Issue a 6 argument syscall. */\n \tmove\tt1, a1\ndiff --git a/sysdeps/unix/sysv/linux/loongarch/sysdep.S b/sysdeps/unix/sysv/linux/loongarch/sysdep.S\nindex 1680022096..966195f79f 100644\n--- a/sysdeps/unix/sysv/linux/loongarch/sysdep.S\n+++ b/sysdeps/unix/sysv/linux/loongarch/sysdep.S\n@@ -34,20 +34,20 @@ ENTRY (__syscall_set_errno)\n /* We got here because a0 < 0, but only codes in the range [-4095, -1]\n represent errors. Otherwise, just return the result normally.\n */\n-\tli.d\t\tt1, -4096\n+\tLI\t\tt1, -4096\n \tbgeu\t\tt1, a0, L (out)\n \tsub.w\t\ta0, zero, a0\n #if RTLD_PRIVATE_ERRNO\n \tla\t\tt1, rtld_errno\n #elif defined(__PIC__)\n \tla.tls.ie\tt1, errno\n-\tadd.d\t\tt1, tp, t1\n+\tADD\t\tt1, tp, t1\n #else\n \tla.tls.le\tt1, errno\n-\tadd.d\t\tt1, tp, t1\n+\tADD\t\tt1, tp, t1\n #endif\n \tst.w\t\ta0, t1, 0\n-\tli.d\t\ta0, -1\n+\tLI\t\ta0, -1\n L (out):\n \tret\n END (__syscall_set_errno)\ndiff --git a/sysdeps/unix/sysv/linux/loongarch/sysdep.h b/sysdeps/unix/sysv/linux/loongarch/sysdep.h\nindex b9835d8391..461b89a610 100644\n--- a/sysdeps/unix/sysv/linux/loongarch/sysdep.h\n+++ b/sysdeps/unix/sysv/linux/loongarch/sysdep.h\n@@ -34,9 +34,9 @@\n #undef PSEUDO\n #define PSEUDO(name, syscall_name, args) \\\n ENTRY (name); \\\n- li.d a7, SYS_ify (syscall_name); \\\n+ LI a7, SYS_ify (syscall_name); \\\n syscall 0; \\\n- li.d a7, -4096; \\\n+ LI a7, -4096; \\\n bltu a7, a0, .Lsyscall_error##name;\n \n #undef PSEUDO_END\n@@ -52,16 +52,16 @@\n .Lsyscall_error##name : la t0, rtld_errno; \\\n sub.w a0, zero, a0; \\\n st.w a0, t0, 0; \\\n- li.d a0, -1;\n+ LI a0, -1;\n \n #else\n \n #define SYSCALL_ERROR_HANDLER(name) \\\n .Lsyscall_error##name : la.tls.ie t0, errno; \\\n- add.d t0, tp, t0; \\\n+ ADD t0, tp, t0; \\\n sub.w a0, zero, a0; \\\n st.w a0, t0, 0; \\\n- li.d a0, -1;\n+ LI a0, -1;\n \n #endif\n #else\n@@ -74,7 +74,7 @@\n #undef PSEUDO_NEORRNO\n #define PSEUDO_NOERRNO(name, syscall_name, args) \\\n ENTRY (name); \\\n- li.d a7, SYS_ify (syscall_name); \\\n+ LI a7, SYS_ify (syscall_name); \\\n syscall 0;\n \n #undef PSEUDO_END_NOERRNO\n@@ -85,11 +85,17 @@\n \n /* Performs a system call, returning the error code. */\n #undef PSEUDO_ERRVAL\n+#if __loongarch_grlen == 64\n #define PSEUDO_ERRVAL(name, syscall_name, args) \\\n PSEUDO_NOERRNO (name, syscall_name, args); \\\n slli.d a0, a0, 32; \\\n srai.d a0, a0, 32; /* sign_ext */ \\\n sub.d a0, zero, a0;\n+#else\n+#define PSEUDO_ERRVAL(name, syscall_name, args) \\\n+ PSEUDO_NOERRNO (name, syscall_name, args); \\\n+ sub.w a0, zero, a0;\n+#endif\n \n #undef PSEUDO_END_ERRVAL\n #define PSEUDO_END_ERRVAL(name) END (name);\n@@ -109,6 +115,18 @@\n #undef SYS_ify\n #define SYS_ify(syscall_name) __NR_##syscall_name\n \n+#if __WORDSIZE == 32\n+/* Workarounds for generic code needing to handle 64-bit time_t. */\n+#define __NR_clock_getres\t__NR_clock_getres_time64\n+#define __NR_futex\t\t__NR_futex_time64\n+#define __NR_ppoll\t\t__NR_ppoll_time64\n+#define __NR_pselect6\t\t__NR_pselect6_time64\n+#define __NR_recvmmsg\t\t__NR_recvmmsg_time64\n+#define __NR_rt_sigtimedwait\t__NR_rt_sigtimedwait_time64\n+#define __NR_semtimedop\t\t__NR_semtimedop_time64\n+#define __NR_utimensat\t\t__NR_utimensat_time64\n+#endif /* __WORDSIZE == 32 */\n+\n #ifndef __ASSEMBLER__\n \n #define VDSO_NAME \"LINUX_5.10\"\ndiff --git a/sysdeps/unix/sysv/linux/loongarch/ucontext-macros.h b/sysdeps/unix/sysv/linux/loongarch/ucontext-macros.h\nindex 99bc8b0fa1..fd5da8d8ec 100644\n--- a/sysdeps/unix/sysv/linux/loongarch/ucontext-macros.h\n+++ b/sysdeps/unix/sysv/linux/loongarch/ucontext-macros.h\n@@ -23,10 +23,12 @@\n #include <sys/asm.h>\n #include \"ucontext_i.h\"\n \n+/* mcontext_t.__gregs is unsigned long long on la32 and la64,\n+ use 8 instead of SZREG. */\n #define SAVE_INT_REG(name, num, base) \\\n- REG_S name, base, ((num) *SZREG + MCONTEXT_GREGS)\n+ REG_S name, base, ((num) * 8 + MCONTEXT_GREGS)\n \n #define RESTORE_INT_REG(name, num, base) \\\n- REG_L name, base, ((num) *SZREG + MCONTEXT_GREGS)\n+ REG_L name, base, ((num) * 8 + MCONTEXT_GREGS)\n \n #endif /* _LINUX_LOONGARCH_UCONTEXT_MACROS_H */\ndiff --git a/sysdeps/unix/sysv/linux/loongarch/vfork.S b/sysdeps/unix/sysv/linux/loongarch/vfork.S\nindex 903d0f80ca..7001bdf8c5 100644\n--- a/sysdeps/unix/sysv/linux/loongarch/vfork.S\n+++ b/sysdeps/unix/sysv/linux/loongarch/vfork.S\n@@ -28,11 +28,11 @@\n \n ENTRY (__vfork)\n \n-\tli.d\ta0, 0x4111 /* CLONE_VM | CLONE_VFORK | SIGCHLD */\n-\tadd.d a1, zero, sp\n+\tLI\ta0, 0x4111 /* CLONE_VM | CLONE_VFORK | SIGCHLD */\n+\tADD a1, zero, sp\n \n \t/* Do the system call. */\n-\tli.d\ta7, __NR_clone\n+\tLI\ta7, __NR_clone\n \tsyscall\t0\n \n \tblt\ta0, zero ,L (error)\n", "prefixes": [ "v3", "4/5" ] }