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 60BB63858C2D for ; Tue, 16 Aug 2022 06:34:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 60BB63858C2D 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 [10.20.4.187] (unknown [10.20.4.187]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Bx5OFnOvtiTmQCAA--.13565S3; Tue, 16 Aug 2022 14:34:15 +0800 (CST) Subject: Re: [PATCH 1/1] LoongArch: Add pointer mangling support. To: Xi Ruoyao , adhemerval.zanella@linaro.org, libc-alpha@sourceware.org, i.swmail@xen0n.name Cc: xuchenghua@loongson.cn, joseph_myers@mentor.com References: <20220811040056.3164122-1-caiyinyu@loongson.cn> From: caiyinyu Message-ID: <68a79804-a3a8-9d53-eea3-297a3661a443@loongson.cn> Date: Tue, 16 Aug 2022 14:34:15 +0800 User-Agent: Mozilla/5.0 (X11; Linux mips64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-CM-TRANSID: AQAAf8Bx5OFnOvtiTmQCAA--.13565S3 X-Coremail-Antispam: 1UD129KBjvJXoWxWFy7uF15XFyrJw4rKF17Wrg_yoWrJw18pr 4xW3W8tFWUJF4rGryUXFy5Ka43t3WrJ345Cas5uF40yF4UAryqqrZIgrn0g3yUGFs2grWj vr4UXw15ZayDZrDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUv0b7Iv0xC_Kw4lb4IE77IF4wAFF20E14v26r4j6ryUM7CY07I2 0VC2zVCF04k26cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rw A2F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Xr0_Ar1l84ACjcxK6xII jxv20xvEc7CjxVAFwI0_Cr0_Gr1UM28EF7xvwVC2z280aVAFwI0_Gr1j6F4UJwA2z4x0Y4 vEx4A2jsIEc7CjxVAFwI0_GcCE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xv F2IEw4CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r1j6r 4UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvEwIxGrwCYjI0SjxkI62AI1cAE67vIY487 MxkIecxEwVCm-wCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c 02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_ Jw1lIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7 CjxVAFwI0_Jr0_Gr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v2 6r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Jr0_GrUvcSsGvfC2KfnxnUUI43ZEXa7IU5 6c_DUUUUU== X-CM-SenderInfo: 5fdl5xhq1xqz5rrqw2lrqou0/ X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, BODY_8BITS, GIT_PATCH_0, KAM_DMARC_STATUS, NICE_REPLY_A, 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: Tue, 16 Aug 2022 06:34:20 -0000 在 2022/8/16 上午9:28, Xi Ruoyao 写道: > On Thu, 2022-08-11 at 12:00 +0800, caiyinyu wrote: >> +/* Load or store to/from a got-relative EXPR into/from 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); \ > Should this be "ld.d T, T, %got_pc_lo12(EXPR)"? Or if OP is a store > we'll store into GOT and break it. > > Or if we don't need to support store just rename it to "LD_GLOBAL". > >> +  OP       G, T, 0; >> + >> +/* Load or store to/from a pc-relative EXPR into/from 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); My mistake. We don't need to support store here. I thought you were ok with this patch so that it has been included. I made the following change in next patch: BTW,the macro REG_L can be ld.d for 64-bits system or ld.w for 32-bits and now it's ld.d. >>>>>>>>>>>>>> diff --git a/sysdeps/unix/sysv/linux/loongarch/sysdep.h b/sysdeps/unix/sysv/linux/loongarch/sysdep.h index 157cbd6c6b..7acd31d024 100644 --- a/sysdeps/unix/sysv/linux/loongarch/sysdep.h +++ b/sysdeps/unix/sysv/linux/loongarch/sysdep.h @@ -316,18 +316,18 @@ 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) \ +#define LD_GLOBAL(G, T,  EXPR) \    pcalau12i T, %got_pc_hi20(EXPR); \ -  OP       T, T, %got_pc_lo12(EXPR); \ -  OP       G, T, 0; +  REG_L            T, T, %got_pc_lo12(EXPR); \ +  REG_L            G, T, 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) \ +#define LD_PCREL(G, T,  EXPR) \    pcalau12i T, %pc_hi20(EXPR); \ -  OP       G, T, %pc_lo12(EXPR); +  REG_L            G, T, %pc_lo12(EXPR);  #if (IS_IN (rtld) \       || (!defined SHARED && (IS_IN (libc) \ @@ -335,10 +335,10 @@ extern long int __syscall_error (long int neg_errno);  #ifdef __ASSEMBLER__  #define PTR_MANGLE(dst, src, guard, tmp) \ -  LDST_PCREL (REG_L, guard, tmp, __pointer_chk_guard_local); \ +  LD_PCREL (guard, tmp, __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); \ +  LD_PCREL (guard, tmp, __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) \ @@ -356,10 +356,10 @@ extern uintptr_t __pointer_chk_guard_local attribute_relro attribute_hidden;  #ifdef __ASSEMBLER__  #define PTR_MANGLE(dst, src, guard, tmp) \ -  LDST_GLOBAL (REG_L, guard, tmp, __pointer_chk_guard); \ +  LD_GLOBAL (guard, tmp, __pointer_chk_guard); \    PTR_MANGLE2 (dst, src, guard);  #define PTR_DEMANGLE(dst, src, guard, tmp) \ -  LDST_GLOBAL (REG_L, guard, tmp, __pointer_chk_guard); \ +  LD_GLOBAL (guard, tmp, __pointer_chk_guard); \    PTR_DEMANGLE2 (dst, src, guard);  /* Use PTR_MANGLE2 for efficiency if guard is already loaded.  */  #define PTR_MANGLE2(dst, src, guard) \ <<<<<<<<<<<<<<<<<<<<<<<<<<<<<< >