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 v4 04/13] LoongArch: ABI Implementation
Date: Sun, 29 May 2022 10:10:53 -0300 [thread overview]
Message-ID: <83e13bba-5081-3df0-e0d7-9020bf38313e@linaro.org> (raw)
In-Reply-To: <20220509023010.1250020-5-caiyinyu@loongson.cn>
On 08/05/2022 23:30, caiyinyu wrote:
> ---
> +/* Return the run-time load address of the shared object. */
> +static inline ElfW (Addr) elf_machine_load_address (void)
> +{
> + ElfW (Addr) got_linktime_addr;
> + asm("la.got %0, _GLOBAL_OFFSET_TABLE_"
> + /* Link-time address in GOT entry before runtime relocation */
> + : "=r"(got_linktime_addr));
> + return (ElfW (Addr)) _GLOBAL_OFFSET_TABLE_ - got_linktime_addr;
> +}
> +
> +/* Initial entry point code for the dynamic linker.
> + The C function `_dl_start' is the real entry point;
> + its return value is the user program's entry point. */
> +
> +#define RTLD_START \
> + asm(".text\n\
> + " _RTLD_PROLOGUE (ENTRY_POINT) "\
> + .cfi_label .Ldummy \n\
> + " CFI_UNDEFINED (1) " \n\
> + or $a0, $sp, $zero \n\
> + bl _dl_start \n\
> + # Stash user entry point in s0. \n\
> + or $s0, $v0, $zero \n\
> + # See if we were run as a command with the executable file \n\
> + # name as an extra leading argument. \n\
> + la $a0, _dl_skip_args \n\
> + ld.w $a0, $a0, 0 \n\
> + # Load the original argument count. \n\
> + ld.d $a1, $sp, 0 \n\
> + # Subtract _dl_skip_args from it. \n\
> + sub.d $a1, $a1, $a0 \n\
> + # Adjust the stack pointer to skip _dl_skip_args words. \n\
> + slli.d $a0, $a0, 3 \n\
> + add.d $sp, $sp, $a0 \n\
> + # Save back the modified argument count. \n\
> + st.d $a1, $sp, 0 \n\
> + # Call _dl_init (struct link_map *main_map, int argc, char **argv, \
> + char **env) \n\
Since ad43cac44a6860eaefcadadfb2acb349921e96bf there is no need to adjust the
arguments using _dl_skip_args; if you don't do anything ABI special you just
need to just reload argc from _dl_argc. I have adapted all of architectures to
eventually remove _dl_skip_args [1], so please follow the same pattern here.
[1] https://patchwork.sourceware.org/project/glibc/list/?series=9706
> + la $a0, _rtld_local \n\
> + ld.d $a0, $a0, 0 \n\
> + addi.d $a2, $sp, 8 \n\
> + slli.d $a3, $a1, 3 \n\
> + add.d $a3, $a3, $a2 \n\
> + addi.d $a3, $a3, 8 \n\
> + # Adjust $sp for 16-aligned \n\
> + srli.d $t0, $sp, 4 \n\
> + slli.d $t0, $t0, 4 \n\
> + ori $t1, $sp, 0 \n\
> + addi.d $sp, $t0, -32 \n\
> + st.d $t1, $sp, 24 \n\
> + # Call the function to run the initializers. \n\
> + bl _dl_init \n\
> + # Pass our finalizer function to _start. \n\
> + ld.d $sp, $sp, 24 \n\
> + la $a0, _dl_fini \n\
> + # Jump to the user entry point. \n\
> + jirl $zero, $s0, 0 \n\
> + " _RTLD_EPILOGUE (ENTRY_POINT) "\
> + .previous");
>
next prev parent reply other threads:[~2022-05-29 13:10 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-09 2:29 [PATCH v4 00/13] GLIBC LoongArch PATCHES caiyinyu
2022-05-09 2:29 ` [PATCH v4 01/13] LoongArch: Update NEWS and README for the LoongArch port caiyinyu
2022-05-09 2:29 ` [PATCH v4 02/13] LoongArch: Add LoongArch entries to config.h.in caiyinyu
2022-05-09 2:30 ` [PATCH v4 03/13] LoongArch: Add relocations and ELF flags to elf.h and scripts/glibcelf.py caiyinyu
2022-05-09 2:30 ` [PATCH v4 04/13] LoongArch: ABI Implementation caiyinyu
2022-05-09 7:56 ` Fangrui Song
2022-05-24 9:49 ` 回复: " caiyinyu
2022-05-24 19:55 ` Fangrui Song
2022-05-09 8:20 ` Fangrui Song
2022-05-09 11:33 ` Adhemerval Zanella
2022-05-09 12:39 ` Adhemerval Zanella
2022-05-09 12:46 ` Florian Weimer
2022-05-29 13:10 ` Adhemerval Zanella [this message]
2022-05-09 2:30 ` [PATCH v4 05/13] LoongArch: Thread-Local Storage Support caiyinyu
2022-05-09 2:30 ` [PATCH v4 06/13] LoongArch: Generic <math.h> and soft-fp Routines caiyinyu
2022-05-09 2:30 ` [PATCH v4 07/13] LoongArch: Atomic and Locking Routines caiyinyu
2022-05-09 2:30 ` [PATCH v4 08/13] LoongArch: Linux Syscall Interface caiyinyu
2022-05-09 2:30 ` [PATCH v4 09/13] LoongArch: Linux ABI caiyinyu
2022-05-09 2:30 ` [PATCH v4 10/13] LoongArch: Add ABI Lists caiyinyu
-- strict thread matches above, loose matches on Subject: below --
2022-05-09 2:25 [PATCH v3 00/13] GLIBC LoongArch PATCHES caiyinyu
2022-05-09 2:26 ` [PATCH v4 04/13] LoongArch: ABI Implementation 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=83e13bba-5081-3df0-e0d7-9020bf38313e@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).