public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 0/2] LoongArch: Fix ptr mangling/demangling features
@ 2022-08-23 12:28 caiyinyu
  2022-08-23 12:28 ` [PATCH 1/2] " caiyinyu
  2022-08-23 12:28 ` [PATCH 2/2] LoongArch: Add HAVE_LOONGARCH_EXPLICIT_RELOCS in config.h.in caiyinyu
  0 siblings, 2 replies; 9+ messages in thread
From: caiyinyu @ 2022-08-23 12:28 UTC (permalink / raw)
  To: adhemerval.zanella, libc-alpha, joseph_myers, carlos, i.swmail, xry111
  Cc: xuchenghua, caiyinyu

Tested on LoongArch machine: gcc 13.0.0, Linux kernel 5.19.0 rc2,
binutils branch master 2eb132bdfb9 and all passed[1].

Tested on LoongArch machine: gcc 12.0.1, Linux kernel 5.19.0 rc5,
binutils 2.39[2] and all passed besides ifunc related tests.


[1]
XPASS: conform/UNIX98/ndbm.h/linknamespace
XPASS: conform/XOPEN2K/ndbm.h/linknamespace
XPASS: conform/XOPEN2K8/ndbm.h/linknamespace
XPASS: conform/XPG42/ndbm.h/linknamespace
UNSUPPORTED: crypt/cert
UNSUPPORTED: elf/tst-env-setuid
UNSUPPORTED: elf/tst-env-setuid-tunables
XPASS: elf/tst-protected1a
XPASS: elf/tst-protected1b
UNSUPPORTED: elf/tst-valgrind-smoke
UNSUPPORTED: misc/tst-adjtimex
UNSUPPORTED: misc/tst-clock_adjtime
UNSUPPORTED: misc/tst-ntp_adjtime
UNSUPPORTED: misc/tst-pkey
UNSUPPORTED: misc/tst-rseq
UNSUPPORTED: misc/tst-rseq-disable
UNSUPPORTED: nptl/test-cond-printers
UNSUPPORTED: nptl/test-condattr-printers
UNSUPPORTED: nptl/test-mutex-printers
UNSUPPORTED: nptl/test-mutexattr-printers
UNSUPPORTED: nptl/test-rwlock-printers
UNSUPPORTED: nptl/test-rwlockattr-printers
UNSUPPORTED: nptl/tst-rseq-nptl
UNSUPPORTED: stdlib/tst-secure-getenv
UNSUPPORTED: time/tst-clock_settime
UNSUPPORTED: time/tst-settimeofday
Summary of test results:
   4583 PASS   
     20 UNSUPPORTED
     12 XFAIL  
      6 XPASS

[2]
XPASS: conform/UNIX98/ndbm.h/linknamespace
XPASS: conform/XOPEN2K/ndbm.h/linknamespace
XPASS: conform/XOPEN2K8/ndbm.h/linknamespace
XPASS: conform/XPG42/ndbm.h/linknamespace
UNSUPPORTED: crypt/cert
FAIL: elf/ifuncmain1
FAIL: elf/ifuncmain1pic
FAIL: elf/ifuncmain1pie
FAIL: elf/ifuncmain1staticpic
FAIL: elf/ifuncmain1staticpie
FAIL: elf/ifuncmain1vis
FAIL: elf/ifuncmain1vispic
FAIL: elf/ifuncmain1vispie
FAIL: elf/ifuncmain2
FAIL: elf/ifuncmain2pic
FAIL: elf/ifuncmain3
FAIL: elf/ifuncmain4
FAIL: elf/ifuncmain5staticpic
FAIL: elf/ifuncmain6pie
FAIL: elf/ifuncmain7
FAIL: elf/ifuncmain7pic
FAIL: elf/ifuncmain7pie
FAIL: elf/ifuncmain9
FAIL: elf/ifuncmain9pic
FAIL: elf/ifuncmain9pie
UNSUPPORTED: elf/tst-env-setuid
UNSUPPORTED: elf/tst-env-setuid-tunables
FAIL: elf/tst-ifunc-textrel
XPASS: elf/tst-protected1a
XPASS: elf/tst-protected1b
UNSUPPORTED: elf/tst-valgrind-smoke
UNSUPPORTED: misc/tst-adjtimex
UNSUPPORTED: misc/tst-clock_adjtime
UNSUPPORTED: misc/tst-ntp_adjtime
UNSUPPORTED: misc/tst-pkey
UNSUPPORTED: misc/tst-rseq
UNSUPPORTED: misc/tst-rseq-disable
UNSUPPORTED: nptl/test-cond-printers
UNSUPPORTED: nptl/test-condattr-printers
UNSUPPORTED: nptl/test-mutex-printers
UNSUPPORTED: nptl/test-mutexattr-printers
UNSUPPORTED: nptl/test-rwlock-printers
UNSUPPORTED: nptl/test-rwlockattr-printers
UNSUPPORTED: nptl/tst-rseq-nptl
UNSUPPORTED: stdlib/tst-secure-getenv
UNSUPPORTED: time/tst-clock_settime
UNSUPPORTED: time/tst-settimeofday
Summary of test results:
     21 FAIL
   4562 PASS
     20 UNSUPPORTED
     12 XFAIL
      6 XPASS

caiyinyu (2):
  LoongArch: Fix ptr mangling/demangling features.
  LoongArch: Add HAVE_LOONGARCH_EXPLICIT_RELOCS in config.h.in.

 config.h.in                                |  3 ++
 sysdeps/loongarch/__longjmp.S              |  2 +-
 sysdeps/loongarch/configure                | 26 ++++++++++++++
 sysdeps/loongarch/configure.ac             | 14 ++++++++
 sysdeps/loongarch/setjmp.S                 |  2 +-
 sysdeps/unix/sysv/linux/loongarch/sysdep.h | 40 +++++++++++++---------
 6 files changed, 68 insertions(+), 19 deletions(-)

-- 
2.31.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/2] LoongArch: Fix ptr mangling/demangling features.
  2022-08-23 12:28 [PATCH 0/2] LoongArch: Fix ptr mangling/demangling features caiyinyu
@ 2022-08-23 12:28 ` caiyinyu
  2022-08-25 15:08   ` Adhemerval Zanella Netto
  2022-08-23 12:28 ` [PATCH 2/2] LoongArch: Add HAVE_LOONGARCH_EXPLICIT_RELOCS in config.h.in caiyinyu
  1 sibling, 1 reply; 9+ messages in thread
From: caiyinyu @ 2022-08-23 12:28 UTC (permalink / raw)
  To: adhemerval.zanella, libc-alpha, joseph_myers, carlos, i.swmail, xry111
  Cc: xuchenghua, caiyinyu

Co-authored-by: Xi Ruoyao <xry111@xry111.site>
---
 sysdeps/loongarch/__longjmp.S              |  2 +-
 sysdeps/loongarch/configure                | 26 ++++++++++++++
 sysdeps/loongarch/configure.ac             | 14 ++++++++
 sysdeps/loongarch/setjmp.S                 |  2 +-
 sysdeps/unix/sysv/linux/loongarch/sysdep.h | 40 +++++++++++++---------
 5 files changed, 65 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/configure b/sysdeps/loongarch/configure
index 43b54d4965..54385786d2 100644
--- a/sysdeps/loongarch/configure
+++ b/sysdeps/loongarch/configure
@@ -3,3 +3,29 @@
 
 $as_echo "#define HIDDEN_VAR_NEEDS_DYNAMIC_RELOC 1" >>confdefs.h
 
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether explicit relocs can be used" >&5
+$as_echo_n "checking whether explicit relocs can be used... " >&6; }
+if ${libc_cv_loongarch_explicit_relocs+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat > conftest.s << EOF
+x: pcalau12i \$t0, %pc_hi20(x)
+EOF
+libc_cv_loongarch_explicit_relocs=no
+if { ac_try='${CC-cc} -c $CFLAGS conftest.s -o conftest.o 1>&5'
+  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; }; then
+  libc_cv_loongarch_explicit_relocs=yes
+fi
+rm -f conftest*
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_loongarch_explicit_relocs" >&5
+$as_echo "$libc_cv_loongarch_explicit_relocs" >&6; }
+if test $libc_cv_loongarch_explicit_relocs = yes; then
+  $as_echo "#define HAVE_LOONGARCH_EXPLICIT_RELOCS 1" >>confdefs.h
+
+fi
diff --git a/sysdeps/loongarch/configure.ac b/sysdeps/loongarch/configure.ac
index f744367bf3..c5d3cb5ead 100644
--- a/sysdeps/loongarch/configure.ac
+++ b/sysdeps/loongarch/configure.ac
@@ -4,3 +4,17 @@ GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
 dnl It is always possible to access static and hidden symbols in an
 dnl position independent way.
 AC_DEFINE(HIDDEN_VAR_NEEDS_DYNAMIC_RELOC)
+
+AC_CACHE_CHECK(whether explicit relocs can be used,
+               libc_cv_loongarch_explicit_relocs, [dnl
+cat > conftest.s << EOF
+x: pcalau12i \$t0, %pc_hi20(x)
+EOF
+libc_cv_loongarch_explicit_relocs=no
+if AC_TRY_COMMAND(${CC-cc} -c $CFLAGS conftest.s -o conftest.o 1>&AS_MESSAGE_LOG_FD); then
+  libc_cv_loongarch_explicit_relocs=yes
+fi
+rm -f conftest*])
+if test $libc_cv_loongarch_explicit_relocs = yes; then
+  AC_DEFINE(HAVE_LOONGARCH_EXPLICIT_RELOCS)
+fi
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..0a8773c38d 100644
--- a/sysdeps/unix/sysv/linux/loongarch/sysdep.h
+++ b/sysdeps/unix/sysv/linux/loongarch/sysdep.h
@@ -316,29 +316,35 @@ 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);
+
+#ifdef HAVE_LOONGARCH_EXPLICIT_RELOCS
+#define LD_PCREL(G, EXPR) \
+  pcalau12i G,	%pc_hi20(EXPR); \
+  REG_L	    G,	G,  %pc_lo12(EXPR);
+#else
+#define LD_PCREL(G, EXPR) \
+  la.pcrel  G,	EXPR; \
+  REG_L	    G,	G,  0;
+#endif
 
 #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 +361,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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 2/2] LoongArch: Add HAVE_LOONGARCH_EXPLICIT_RELOCS in config.h.in.
  2022-08-23 12:28 [PATCH 0/2] LoongArch: Fix ptr mangling/demangling features caiyinyu
  2022-08-23 12:28 ` [PATCH 1/2] " caiyinyu
@ 2022-08-23 12:28 ` caiyinyu
  2022-08-25 15:06   ` Adhemerval Zanella Netto
  1 sibling, 1 reply; 9+ messages in thread
From: caiyinyu @ 2022-08-23 12:28 UTC (permalink / raw)
  To: adhemerval.zanella, libc-alpha, joseph_myers, carlos, i.swmail, xry111
  Cc: xuchenghua, caiyinyu

---
 config.h.in | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/config.h.in b/config.h.in
index 43d32518ab..b182de0e91 100644
--- a/config.h.in
+++ b/config.h.in
@@ -138,6 +138,9 @@
 /* LOONGARCH floating-point ABI for ld.so.  */
 #undef LOONGARCH_ABI_FRLEN
 
+/* To Indicate whether we can use explicit relocs or not.  */
+#undef HAVE_LOONGARCH_EXPLICIT_RELOCS
+
 /* Linux specific: minimum supported kernel version.  */
 #undef	__LINUX_KERNEL_VERSION
 
-- 
2.31.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/2] LoongArch: Add HAVE_LOONGARCH_EXPLICIT_RELOCS in config.h.in.
  2022-08-23 12:28 ` [PATCH 2/2] LoongArch: Add HAVE_LOONGARCH_EXPLICIT_RELOCS in config.h.in caiyinyu
@ 2022-08-25 15:06   ` Adhemerval Zanella Netto
  0 siblings, 0 replies; 9+ messages in thread
From: Adhemerval Zanella Netto @ 2022-08-25 15:06 UTC (permalink / raw)
  To: caiyinyu, libc-alpha, joseph_myers, carlos, i.swmail, xry111; +Cc: xuchenghua



On 23/08/22 09:28, caiyinyu wrote:
> ---
>  config.h.in | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/config.h.in b/config.h.in
> index 43d32518ab..b182de0e91 100644
> --- a/config.h.in
> +++ b/config.h.in
> @@ -138,6 +138,9 @@
>  /* LOONGARCH floating-point ABI for ld.so.  */
>  #undef LOONGARCH_ABI_FRLEN
>  
> +/* To Indicate whether we can use explicit relocs or not.  */
> +#undef HAVE_LOONGARCH_EXPLICIT_RELOCS
> +
>  /* Linux specific: minimum supported kernel version.  */
>  #undef	__LINUX_KERNEL_VERSION
>  

This patch needs to be squashed with the first one to be concise (the
first one uses HAVE_LOONGARCH_EXPLICIT_RELOCS without being defined).

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/2] LoongArch: Fix ptr mangling/demangling features.
  2022-08-23 12:28 ` [PATCH 1/2] " caiyinyu
@ 2022-08-25 15:08   ` Adhemerval Zanella Netto
  2022-08-25 15:27     ` Xi Ruoyao
  0 siblings, 1 reply; 9+ messages in thread
From: Adhemerval Zanella Netto @ 2022-08-25 15:08 UTC (permalink / raw)
  To: caiyinyu, libc-alpha, joseph_myers, carlos, i.swmail, xry111; +Cc: xuchenghua

Does is really pay off the complexity to use HAVE_LOONGARCH_EXPLICIT_RELOCS? The
PTR_MANGLE is used some specific cases and hardly a hotstop.

On 23/08/22 09:28, caiyinyu wrote:
> Co-authored-by: Xi Ruoyao <xry111@xry111.site>
> ---
>  sysdeps/loongarch/__longjmp.S              |  2 +-
>  sysdeps/loongarch/configure                | 26 ++++++++++++++
>  sysdeps/loongarch/configure.ac             | 14 ++++++++
>  sysdeps/loongarch/setjmp.S                 |  2 +-
>  sysdeps/unix/sysv/linux/loongarch/sysdep.h | 40 +++++++++++++---------
>  5 files changed, 65 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/configure b/sysdeps/loongarch/configure
> index 43b54d4965..54385786d2 100644
> --- a/sysdeps/loongarch/configure
> +++ b/sysdeps/loongarch/configure
> @@ -3,3 +3,29 @@
>  
>  $as_echo "#define HIDDEN_VAR_NEEDS_DYNAMIC_RELOC 1" >>confdefs.h
>  
> +
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether explicit relocs can be used" >&5
> +$as_echo_n "checking whether explicit relocs can be used... " >&6; }
> +if ${libc_cv_loongarch_explicit_relocs+:} false; then :
> +  $as_echo_n "(cached) " >&6
> +else
> +  cat > conftest.s << EOF
> +x: pcalau12i \$t0, %pc_hi20(x)
> +EOF
> +libc_cv_loongarch_explicit_relocs=no
> +if { ac_try='${CC-cc} -c $CFLAGS conftest.s -o conftest.o 1>&5'
> +  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
> +  (eval $ac_try) 2>&5
> +  ac_status=$?
> +  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
> +  test $ac_status = 0; }; }; then
> +  libc_cv_loongarch_explicit_relocs=yes
> +fi
> +rm -f conftest*
> +fi
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_loongarch_explicit_relocs" >&5
> +$as_echo "$libc_cv_loongarch_explicit_relocs" >&6; }
> +if test $libc_cv_loongarch_explicit_relocs = yes; then
> +  $as_echo "#define HAVE_LOONGARCH_EXPLICIT_RELOCS 1" >>confdefs.h
> +
> +fi
> diff --git a/sysdeps/loongarch/configure.ac b/sysdeps/loongarch/configure.ac
> index f744367bf3..c5d3cb5ead 100644
> --- a/sysdeps/loongarch/configure.ac
> +++ b/sysdeps/loongarch/configure.ac
> @@ -4,3 +4,17 @@ GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
>  dnl It is always possible to access static and hidden symbols in an
>  dnl position independent way.
>  AC_DEFINE(HIDDEN_VAR_NEEDS_DYNAMIC_RELOC)
> +
> +AC_CACHE_CHECK(whether explicit relocs can be used,
> +               libc_cv_loongarch_explicit_relocs, [dnl
> +cat > conftest.s << EOF
> +x: pcalau12i \$t0, %pc_hi20(x)
> +EOF
> +libc_cv_loongarch_explicit_relocs=no
> +if AC_TRY_COMMAND(${CC-cc} -c $CFLAGS conftest.s -o conftest.o 1>&AS_MESSAGE_LOG_FD); then
> +  libc_cv_loongarch_explicit_relocs=yes
> +fi
> +rm -f conftest*])
> +if test $libc_cv_loongarch_explicit_relocs = yes; then
> +  AC_DEFINE(HAVE_LOONGARCH_EXPLICIT_RELOCS)
> +fi
> 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..0a8773c38d 100644
> --- a/sysdeps/unix/sysv/linux/loongarch/sysdep.h
> +++ b/sysdeps/unix/sysv/linux/loongarch/sysdep.h
> @@ -316,29 +316,35 @@ 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);
> +
> +#ifdef HAVE_LOONGARCH_EXPLICIT_RELOCS
> +#define LD_PCREL(G, EXPR) \
> +  pcalau12i G,	%pc_hi20(EXPR); \
> +  REG_L	    G,	G,  %pc_lo12(EXPR);
> +#else
> +#define LD_PCREL(G, EXPR) \
> +  la.pcrel  G,	EXPR; \
> +  REG_L	    G,	G,  0;
> +#endif
>  
>  #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 +361,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) \

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/2] LoongArch: Fix ptr mangling/demangling features.
  2022-08-25 15:08   ` Adhemerval Zanella Netto
@ 2022-08-25 15:27     ` Xi Ruoyao
  2022-08-25 17:01       ` Adhemerval Zanella Netto
  0 siblings, 1 reply; 9+ messages in thread
From: Xi Ruoyao @ 2022-08-25 15:27 UTC (permalink / raw)
  To: Adhemerval Zanella Netto, caiyinyu, libc-alpha, joseph_myers,
	carlos, i.swmail
  Cc: xuchenghua

On Thu, 2022-08-25 at 12:08 -0300, Adhemerval Zanella Netto wrote:
> Does is really pay off the complexity to use HAVE_LOONGARCH_EXPLICIT_RELOCS? The
> PTR_MANGLE is used some specific cases and hardly a hotstop.

LDST_PCREL added as a macro in sysdep.h, so further assembly
implementations might reuse it then it may appear in some hot spot.

If we quote "optimization too early is the ultimate evil", we can drop
it for now and review once we use LDST_PCREL somewhere else. But to me
this is rather a simple autoconf check and I can't figure out a
situation where it's evil...
-- 
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/2] LoongArch: Fix ptr mangling/demangling features.
  2022-08-25 15:27     ` Xi Ruoyao
@ 2022-08-25 17:01       ` Adhemerval Zanella Netto
  2022-08-26  2:44         ` caiyinyu
  0 siblings, 1 reply; 9+ messages in thread
From: Adhemerval Zanella Netto @ 2022-08-25 17:01 UTC (permalink / raw)
  To: Xi Ruoyao, caiyinyu, libc-alpha, joseph_myers, carlos, i.swmail
  Cc: xuchenghua



On 25/08/22 12:27, Xi Ruoyao wrote:
> On Thu, 2022-08-25 at 12:08 -0300, Adhemerval Zanella Netto wrote:
>> Does is really pay off the complexity to use HAVE_LOONGARCH_EXPLICIT_RELOCS? The
>> PTR_MANGLE is used some specific cases and hardly a hotstop.
> 
> LDST_PCREL added as a macro in sysdep.h, so further assembly
> implementations might reuse it then it may appear in some hot spot.
> 
> If we quote "optimization too early is the ultimate evil", we can drop
> it for now and review once we use LDST_PCREL somewhere else. But to me
> this is rather a simple autoconf check and I can't figure out a
> situation where it's evil...

It is more that configure checks might create maintainability burden or just
dead code in the long term, specially where it does have a fallback that works
with no much performance penalty. 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/2] LoongArch: Fix ptr mangling/demangling features.
  2022-08-25 17:01       ` Adhemerval Zanella Netto
@ 2022-08-26  2:44         ` caiyinyu
  2022-08-26  8:11           ` caiyinyu
  0 siblings, 1 reply; 9+ messages in thread
From: caiyinyu @ 2022-08-26  2:44 UTC (permalink / raw)
  To: Adhemerval Zanella Netto, Xi Ruoyao, libc-alpha, joseph_myers,
	carlos, i.swmail
  Cc: xuchenghua


How about using this patch[1] now to fix this build error first?

[1] https://sourceware.org/pipermail/libc-alpha/2022-August/141489.html

There is no modify in common files and all happy besides performance 
overhead

of one more instruction.


在 2022/8/26 上午1:01, Adhemerval Zanella Netto 写道:
>
> On 25/08/22 12:27, Xi Ruoyao wrote:
>> On Thu, 2022-08-25 at 12:08 -0300, Adhemerval Zanella Netto wrote:
>>> Does is really pay off the complexity to use HAVE_LOONGARCH_EXPLICIT_RELOCS? The
>>> PTR_MANGLE is used some specific cases and hardly a hotstop.
>> LDST_PCREL added as a macro in sysdep.h, so further assembly
>> implementations might reuse it then it may appear in some hot spot.
>>
>> If we quote "optimization too early is the ultimate evil", we can drop
>> it for now and review once we use LDST_PCREL somewhere else. But to me
>> this is rather a simple autoconf check and I can't figure out a
>> situation where it's evil...
> It is more that configure checks might create maintainability burden or just
> dead code in the long term, specially where it does have a fallback that works
> with no much performance penalty.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/2] LoongArch: Fix ptr mangling/demangling features.
  2022-08-26  2:44         ` caiyinyu
@ 2022-08-26  8:11           ` caiyinyu
  0 siblings, 0 replies; 9+ messages in thread
From: caiyinyu @ 2022-08-26  8:11 UTC (permalink / raw)
  To: Adhemerval Zanella Netto, Xi Ruoyao, libc-alpha, joseph_myers,
	carlos, i.swmail
  Cc: xuchenghua




在 2022/8/26 上午10:44, caiyinyu 写道:
>
> How about using this patch[1] now to fix this build error first?
>
> [1] https://sourceware.org/pipermail/libc-alpha/2022-August/141489.html
>
> There is no modify in common files and all happy besides performance 
> overhead
>
> of one more instruction.

I also sent a new patch which combined the two patches If community can 
accept it.

https://sourceware.org/pipermail/libc-alpha/2022-August/141677.html




>
>
> 在 2022/8/26 上午1:01, Adhemerval Zanella Netto 写道:
>>
>> On 25/08/22 12:27, Xi Ruoyao wrote:
>>> On Thu, 2022-08-25 at 12:08 -0300, Adhemerval Zanella Netto wrote:
>>>> Does is really pay off the complexity to use 
>>>> HAVE_LOONGARCH_EXPLICIT_RELOCS? The
>>>> PTR_MANGLE is used some specific cases and hardly a hotstop.
>>> LDST_PCREL added as a macro in sysdep.h, so further assembly
>>> implementations might reuse it then it may appear in some hot spot.
>>>
>>> If we quote "optimization too early is the ultimate evil", we can drop
>>> it for now and review once we use LDST_PCREL somewhere else. But to me
>>> this is rather a simple autoconf check and I can't figure out a
>>> situation where it's evil...
>> It is more that configure checks might create maintainability burden 
>> or just
>> dead code in the long term, specially where it does have a fallback 
>> that works
>> with no much performance penalty.


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-08-26  8:11 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-23 12:28 [PATCH 0/2] LoongArch: Fix ptr mangling/demangling features caiyinyu
2022-08-23 12:28 ` [PATCH 1/2] " caiyinyu
2022-08-25 15:08   ` Adhemerval Zanella Netto
2022-08-25 15:27     ` Xi Ruoyao
2022-08-25 17:01       ` Adhemerval Zanella Netto
2022-08-26  2:44         ` caiyinyu
2022-08-26  8:11           ` caiyinyu
2022-08-23 12:28 ` [PATCH 2/2] LoongArch: Add HAVE_LOONGARCH_EXPLICIT_RELOCS in config.h.in caiyinyu
2022-08-25 15:06   ` Adhemerval Zanella Netto

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).