public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
To: caiyinyu <caiyinyu@loongson.cn>, libc-alpha@sourceware.org
Cc: joseph_myers@mentor.com, xuchenghua@loongson.cn
Subject: Re: [PATCH v5 09/13] LoongArch: Linux ABI
Date: Tue, 7 Jun 2022 10:56:01 -0300	[thread overview]
Message-ID: <6ce5fddd-969d-d509-65c4-a257a000bad8@linaro.org> (raw)
In-Reply-To: <4b4ed912-244f-5a3e-38bd-574190a44154@loongson.cn>



On 07/06/2022 06:32, caiyinyu wrote:
> +static inline ElfW (Addr) __attribute ((always_inline))
> +elf_ifunc_invoke (ElfW (Addr) addr)
> +{
> +  return ((ElfW (Addr) (*) (void)) (addr)) ();
> 
> At least for RISCV, sparc, aarch64, powerpc, arm; the ifunc resolver expects
> a unsigned long int begin the hardware capability from kernelk (AT_HWCAP).
> 
> AArch64 also extends it by passing both uint64_t and a struct with both
> AT_HWCAP and AT_HWCAP2.  I am not sure if loongarch will ever use more
> than the AT_HWCAP.
> *Currently ifuncs (like __memchr_ifunc, __memcpy_ifunc ...) are not used in loongarch, and we will add these in future.*
> *or we can add the following patch (now **AT_HWCAP only) though not woking: ****>>>>>>>>>>>*
> 
> diff --git a/sysdeps/loongarch/dl-irel.h b/sysdeps/loongarch/dl-irel.h
> index 0dfe78c217..ef248095b9 100644
> --- a/sysdeps/loongarch/dl-irel.h
> +++ b/sysdeps/loongarch/dl-irel.h
> @@ -21,13 +21,18 @@
>  
>  #include <stdio.h>
>  #include <unistd.h>
> +#include <ldsodefs.h>
> +#include <sysdep.h>
>  
>  #define ELF_MACHINE_IRELA 1
>  
>  static inline ElfW (Addr) __attribute ((always_inline))
>  elf_ifunc_invoke (ElfW (Addr) addr)
>  {
> -  return ((ElfW (Addr) (*) (void)) (addr)) ();
> +  /* The second argument is a void pointer to preserve the extension
> +     fexibility.  */
> +  return ((ElfW(Addr) (*) (uint64_t, void *)) (addr))
> +        (GLRO(dl_hwcap), NULL);
>  }
>  
>  static inline void __attribute ((always_inline))
> 
> *<<<<<<<<<<<<<<<<<<*

AArch64 added the extra argument to preserve backwards compatibility, which
is not the case here.  Since ifunc is also used outside glibc, maybe it would
be better to  use the extendable struct as default:


 struct __ifunc_arg_t
 {
   unsigned long int _size; /* Size of the struct, so it can grow.  */
   unsigned long int _hwcap;
 };

 static inline ElfW (Addr) __attribute ((always_inline))
 elf_ifunc_invoke (ElfW (Addr) addr)
 {
   __ifunc_arg_t arg = 
   {
     ._size = sizeof (__ifunc_arg_t),
     ._hwcap = GLRO(dl_hwcap),
   }
   return ((ElfW(Addr) (*) (uint64_t, void *)) (addr)) (&arg);
 }

And then export __ifunc_arg_t on the sys/ifunc.h header like aarch64.

  reply	other threads:[~2022-06-07 13:56 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-01  2:18 [PATCH v5 00/13] GLIBC LoongArch PATCHES caiyinyu
2022-06-01  2:18 ` [PATCH v5 01/13] LoongArch: Update NEWS and README for the LoongArch port caiyinyu
2022-06-01  2:18 ` [PATCH v5 02/13] LoongArch: Add LoongArch entries to config.h.in caiyinyu
2022-06-01  2:18 ` [PATCH v5 03/13] LoongArch: Add relocations and ELF flags to elf.h and scripts/glibcelf.py caiyinyu
2022-06-01  2:18 ` [PATCH v5 04/13] LoongArch: ABI Implementation caiyinyu
2022-06-05 23:55   ` Fangrui Song
2022-06-10  7:54     ` caiyinyu
2022-06-10 20:26       ` Fangrui Song
2022-07-08  6:49         ` caiyinyu
2022-07-08 18:37           ` Fangrui Song
2022-06-11  6:19     ` caiyinyu
2022-06-01  2:18 ` [PATCH v5 05/13] LoongArch: Thread-Local Storage Support caiyinyu
2022-06-01  2:18 ` [PATCH v5 06/13] LoongArch: Generic <math.h> and soft-fp Routines caiyinyu
2022-06-01  2:18 ` [PATCH v5 07/13] LoongArch: Atomic and Locking Routines caiyinyu
2022-06-01  2:18 ` [PATCH v5 08/13] LoongArch: Linux Syscall Interface caiyinyu
2022-06-01  2:18 ` [PATCH v5 09/13] LoongArch: Linux ABI caiyinyu
2022-06-06 18:36   ` Adhemerval Zanella
2022-06-07  9:32     ` caiyinyu
2022-06-07 13:56       ` Adhemerval Zanella [this message]
2022-06-08  6:01         ` caiyinyu
2022-06-08 13:16           ` Adhemerval Zanella
2022-06-09  4:01             ` [PATCH v5 09/13] LoongArch: Linux ABI -- __ifunc_arg_t caiyinyu
2022-06-01  2:18 ` [PATCH v5 10/13] LoongArch: Add ABI Lists caiyinyu
2022-06-01  2:18 ` [PATCH v5 11/13] LoongArch: Build Infastructure caiyinyu
2022-06-07 14:09   ` Adhemerval Zanella
2022-06-07 15:25     ` Joseph Myers
2022-06-01  2:18 ` [PATCH v5 12/13] LoongArch: Hard Float Support caiyinyu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6ce5fddd-969d-d509-65c4-a257a000bad8@linaro.org \
    --to=adhemerval.zanella@linaro.org \
    --cc=caiyinyu@loongson.cn \
    --cc=joseph_myers@mentor.com \
    --cc=libc-alpha@sourceware.org \
    --cc=xuchenghua@loongson.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).