about summary refs log tree commit diff
diff options
context:
space:
mode:
authorXi Ruoyao <xry111@xry111.site>2023-08-27 00:36:51 +0800
committercaiyinyu <caiyinyu@loongson.cn>2023-08-29 10:35:38 +0800
commit3efa26749e4d28768558330353dc15c6f325ed4e (patch)
tree189e3ec2424ee8c65ab11a1fca53295156e10459
parentaac842d0edbe53a150ab57a4f776cb50294b6388 (diff)
downloadglibc-3efa26749e4d28768558330353dc15c6f325ed4e.tar.gz
glibc-3efa26749e4d28768558330353dc15c6f325ed4e.tar.xz
glibc-3efa26749e4d28768558330353dc15c6f325ed4e.zip
LoongArch: Micro-optimize LD_PCREL
We are requiring Binutils >= 2.41, so explicit relocation syntax is
always supported by the assembler.  Use it to reduce one instruction.

Signed-off-by: Xi Ruoyao <xry111@xry111.site>
-rw-r--r--sysdeps/unix/sysv/linux/loongarch/pointer_guard.h10
1 files changed, 4 insertions, 6 deletions
diff --git a/sysdeps/unix/sysv/linux/loongarch/pointer_guard.h b/sysdeps/unix/sysv/linux/loongarch/pointer_guard.h
index b25e353b37..d6c78687d4 100644
--- a/sysdeps/unix/sysv/linux/loongarch/pointer_guard.h
+++ b/sysdeps/unix/sysv/linux/loongarch/pointer_guard.h
@@ -19,17 +19,15 @@
 #ifndef POINTER_GUARD_H
 #define POINTER_GUARD_H
 
-/* Load a got-relative EXPR into G, using T.
-   Note G and T are register names.  */
+/* Load a got-relative EXPR into register G.  */
 #define LD_GLOBAL(G, EXPR) \
   la.global G,  EXPR; \
   REG_L     G,  G,  0;
 
-/* Load a pc-relative EXPR into G, using T.
-   Note G and T are register names.  */
+/* Load a pc-relative EXPR into register G.  */
 #define LD_PCREL(G, EXPR) \
-  la.pcrel  G,  EXPR; \
-  REG_L     G,  G,  0;
+  pcalau12i G, %pc_hi20(EXPR); \
+  REG_L     G, G, %pc_lo12(EXPR);
 
 #if (IS_IN (rtld) \
      || (!defined SHARED && (IS_IN (libc) \