public inbox for glibc-cvs@sourceware.org help / color / mirror / Atom feed
From: Andreas Schwab <schwab@sourceware.org> To: glibc-cvs@sourceware.org Subject: [glibc] riscv: add support for static PIE Date: Mon, 22 Jan 2024 14:00:14 +0000 (GMT) [thread overview] Message-ID: <20240122140014.467593858291@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=6edaa12b41a373f249469d7b516d2043f81aea37 commit 6edaa12b41a373f249469d7b516d2043f81aea37 Author: Andreas Schwab <schwab@suse.de> Date: Wed Jan 17 15:35:57 2024 +0100 riscv: add support for static PIE In order to support static PIE the startup code must avoid relocations before __libc_start_main is called. Diff: --- sysdeps/riscv/start.S | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sysdeps/riscv/start.S b/sysdeps/riscv/start.S index 0a1f713742..ede186ef23 100644 --- a/sysdeps/riscv/start.S +++ b/sysdeps/riscv/start.S @@ -50,7 +50,13 @@ ENTRY (ENTRY_POINT) call load_gp mv a5, a0 /* rtld_fini. */ /* main may be in a shared library. */ +#if defined PIC && !defined SHARED + /* Avoid relocation in static PIE since _start is called before it + is relocated. */ + lla a0, __wrap_main +#else la a0, main +#endif REG_L a1, 0(sp) /* argc. */ addi a2, sp, SZREG /* argv. */ andi sp, sp, ALMASK /* Align stack. */ @@ -62,6 +68,11 @@ ENTRY (ENTRY_POINT) ebreak END (ENTRY_POINT) +#if defined PIC && !defined SHARED +__wrap_main: + tail main@plt +#endif + /* Dynamic links need the global pointer to be initialized prior to calling any shared library's initializers, so we use preinit_array to load it. This doesn't cut it for static links, though, since the global pointer
reply other threads:[~2024-01-22 14:00 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20240122140014.467593858291@sourceware.org \ --to=schwab@sourceware.org \ --cc=glibc-cvs@sourceware.org \ /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: linkBe 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).