From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by sourceware.org (Postfix) with ESMTP id 8B6473858D1E for ; Thu, 18 Aug 2022 02:19:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8B6473858D1E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=loongson.cn Received: from 5.5.5 (unknown [10.2.5.5]) by localhost.localdomain (Coremail) with SMTP id AQAAf8DxvmuVof1ipJADAA--.6638S2; Thu, 18 Aug 2022 10:19:01 +0800 (CST) From: caiyinyu To: adhemerval.zanella@linaro.org, libc-alpha@sourceware.org, i.swmail@xen0n.name Cc: joseph_myers@mentor.com, carlos@redhat.com, xuchenghua@loongson.cn, caiyinyu Subject: [PATCH 1/1] LoongArch: Fix ptr mangling/demangling features. Date: Thu, 18 Aug 2022 10:19:00 +0800 Message-Id: <20220818021900.3436740-1-caiyinyu@loongson.cn> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: AQAAf8DxvmuVof1ipJADAA--.6638S2 X-Coremail-Antispam: 1UD129KBjvJXoWxury8tFyUWrWfGr1UCw17KFg_yoWrJr4Dpr y3ua1FqFZrJas3JryUZa4YgFn5JFs5Gry7u3WfAr40yF4UAw18WwsIyrnxXayUWF95WrZY vr18K3WUuasruwUanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUkS14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26ryj6F1UM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26F4j 6r4UJwA2z4x0Y4vEx4A2jsIE14v26r4UJVWxJr1l84ACjcxK6I8E87Iv6xkF7I0E14v26r 4UJVWxJr1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2Wl Yx0E2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbV WUJVW8JwACjcxG0xvY0x0EwIxGrwACjI8F5VA0II8E6IAqYI8I648v4I1lc2xSY4AK6svP MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr 0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUAVWUtwCIc40Y0x0E wIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVWUJV W8JwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAI cVC2z280aVCY1x0267AKxVWUJVW8JbIYCTnIWIevJa73UjIFyTuYvjfUoOJ5UUUUU X-CM-SenderInfo: 5fdl5xhq1xqz5rrqw2lrqou0/ X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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-List-Received-Date: Thu, 18 Aug 2022 02:19:11 -0000 Tested on LoongArch machine: gcc 13.0.0, Linux kernel 5.19.0 rc2, binutils branch master 2eb132bdfb9. This patch is ok with gcc 12.0.1, Linux kernel 5.19.0 rc5, binutils 2.39. --- sysdeps/loongarch/__longjmp.S | 2 +- sysdeps/loongarch/setjmp.S | 2 +- sysdeps/unix/sysv/linux/loongarch/sysdep.h | 33 +++++++++++----------- 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/sysdeps/loongarch/__longjmp.S b/sysdeps/loongarch/__longjmp.S index c2c5b56a80..4207376f5e 100644 --- a/sysdeps/loongarch/__longjmp.S +++ b/sysdeps/loongarch/__longjmp.S @@ -22,7 +22,7 @@ ENTRY (__longjmp) #ifdef PTR_MANGLE REG_L t0, a0, 0*SZREG - PTR_DEMANGLE (ra, t0, t1, t2) + PTR_DEMANGLE (ra, t0, t1) REG_L t0, a0, 1*SZREG PTR_DEMANGLE2 (sp, t0, t1) #else diff --git a/sysdeps/loongarch/setjmp.S b/sysdeps/loongarch/setjmp.S index ec4ddc72da..298bb02a82 100644 --- a/sysdeps/loongarch/setjmp.S +++ b/sysdeps/loongarch/setjmp.S @@ -30,7 +30,7 @@ END (setjmp) ENTRY (__sigsetjmp) #ifdef PTR_MANGLE - PTR_MANGLE (t0, ra, t1, t2) + PTR_MANGLE (t0, ra, t1) REG_S t0, a0, 0*SZREG PTR_MANGLE2 (t0, sp, t1) REG_S t0, a0, 1*SZREG diff --git a/sysdeps/unix/sysv/linux/loongarch/sysdep.h b/sysdeps/unix/sysv/linux/loongarch/sysdep.h index 157cbd6c6b..f4a1d23a97 100644 --- a/sysdeps/unix/sysv/linux/loongarch/sysdep.h +++ b/sysdeps/unix/sysv/linux/loongarch/sysdep.h @@ -316,29 +316,28 @@ extern long int __syscall_error (long int neg_errno); /* Pointer mangling is supported for LoongArch. */ -/* Load or store to/from a got-relative EXPR into/from G, using T. +/* Load a got-relative EXPR into G, using T. Note G and T are register names. */ -#define LDST_GLOBAL(OP, G, T, EXPR) \ - pcalau12i T, %got_pc_hi20(EXPR); \ - OP T, T, %got_pc_lo12(EXPR); \ - OP G, T, 0; +#define LD_GLOBAL(G, EXPR) \ + la.global G, EXPR; \ + REG_L G, G, 0; -/* Load or store to/from a pc-relative EXPR into/from G, using T. +/* Load a pc-relative EXPR into G, using T. Note G and T are register names. */ -#define LDST_PCREL(OP, G, T, EXPR) \ - pcalau12i T, %pc_hi20(EXPR); \ - OP G, T, %pc_lo12(EXPR); +#define LD_PCREL(G, EXPR) \ + la.pcrel G, EXPR; \ + REG_L G, G, 0; #if (IS_IN (rtld) \ || (!defined SHARED && (IS_IN (libc) \ || IS_IN (libpthread)))) #ifdef __ASSEMBLER__ -#define PTR_MANGLE(dst, src, guard, tmp) \ - LDST_PCREL (REG_L, guard, tmp, __pointer_chk_guard_local); \ +#define PTR_MANGLE(dst, src, guard) \ + LD_PCREL (guard, __pointer_chk_guard_local); \ PTR_MANGLE2 (dst, src, guard); -#define PTR_DEMANGLE(dst, src, guard, tmp) \ - LDST_PCREL (REG_L, guard, tmp, __pointer_chk_guard_local); \ +#define PTR_DEMANGLE(dst, src, guard) \ + LD_PCREL (guard, __pointer_chk_guard_local); \ PTR_DEMANGLE2 (dst, src, guard); /* Use PTR_MANGLE2 for efficiency if guard is already loaded. */ #define PTR_MANGLE2(dst, src, guard) \ @@ -355,11 +354,11 @@ extern uintptr_t __pointer_chk_guard_local attribute_relro attribute_hidden; #else #ifdef __ASSEMBLER__ -#define PTR_MANGLE(dst, src, guard, tmp) \ - LDST_GLOBAL (REG_L, guard, tmp, __pointer_chk_guard); \ +#define PTR_MANGLE(dst, src, guard) \ + LD_GLOBAL (guard, __pointer_chk_guard); \ PTR_MANGLE2 (dst, src, guard); -#define PTR_DEMANGLE(dst, src, guard, tmp) \ - LDST_GLOBAL (REG_L, guard, tmp, __pointer_chk_guard); \ +#define PTR_DEMANGLE(dst, src, guard) \ + LD_GLOBAL (guard, __pointer_chk_guard); \ PTR_DEMANGLE2 (dst, src, guard); /* Use PTR_MANGLE2 for efficiency if guard is already loaded. */ #define PTR_MANGLE2(dst, src, guard) \ -- 2.31.1