From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
To: libc-alpha@sourceware.org
Subject: Re: [PATCH v2 4/6] elf: Move note processing after l_phdr is updated
Date: Thu, 10 Dec 2020 15:30:11 -0300 [thread overview]
Message-ID: <a0200de1-1f9e-cd71-942c-0ccf699cf53e@linaro.org> (raw)
In-Reply-To: <36d457074f389740b45afc4f9c6d124046f8352b.1606319495.git.szabolcs.nagy@arm.com>
On 27/11/2020 10:20, Szabolcs Nagy via Libc-alpha wrote:
> Program headers are processed in two pass: after the first pass
> load segments are mmapped so in the second pass target specific
> note processing logic can access the notes.
>
> The second pass is moved later so various link_map fields are
> set up that may be useful for note processing such as l_phdr.
> The second pass should be before the fd is closed so that is
> available.
LGTM, thanks.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
> ---
> elf/dl-load.c | 30 +++++++++++++++---------------
> 1 file changed, 15 insertions(+), 15 deletions(-)
>
> diff --git a/elf/dl-load.c b/elf/dl-load.c
> index 9c71b7562c..b0d65f32cc 100644
> --- a/elf/dl-load.c
> +++ b/elf/dl-load.c
> @@ -1268,21 +1268,6 @@ _dl_map_object_from_fd (const char *name, const char *origname, int fd,
> l->l_map_start = l->l_map_end = 0;
> goto call_lose;
> }
> -
> - /* Process program headers again after load segments are mapped in
> - case processing requires accessing those segments. Scan program
> - headers backward so that PT_NOTE can be skipped if PT_GNU_PROPERTY
> - exits. */
> - for (ph = &phdr[l->l_phnum]; ph != phdr; --ph)
> - switch (ph[-1].p_type)
> - {
> - case PT_NOTE:
> - _dl_process_pt_note (l, &ph[-1]);
> - break;
> - case PT_GNU_PROPERTY:
> - _dl_process_pt_gnu_property (l, &ph[-1]);
> - break;
> - }
> }
>
> if (l->l_ld == 0)
> @@ -1386,6 +1371,21 @@ cannot enable executable stack as shared object requires");
> if (l->l_tls_initimage != NULL)
> l->l_tls_initimage = (char *) l->l_tls_initimage + l->l_addr;
>
> + /* Process program headers again after load segments are mapped in
> + case processing requires accessing those segments. Scan program
> + headers backward so that PT_NOTE can be skipped if PT_GNU_PROPERTY
> + exits. */
> + for (ph = &l->l_phdr[l->l_phnum]; ph != l->l_phdr; --ph)
> + switch (ph[-1].p_type)
> + {
> + case PT_NOTE:
> + _dl_process_pt_note (l, &ph[-1]);
> + break;
> + case PT_GNU_PROPERTY:
> + _dl_process_pt_gnu_property (l, &ph[-1]);
> + break;
> + }
> +
> /* We are done mapping in the file. We no longer need the descriptor. */
> if (__glibc_unlikely (__close_nocancel (fd) != 0))
> {
>
next prev parent reply other threads:[~2020-12-10 18:30 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-27 13:19 [PATCH v2 0/6] aarch64: avoid mprotect(PROT_BTI|PROT_EXEC) [BZ #26831] Szabolcs Nagy
2020-11-27 13:19 ` [PATCH v2 1/6] aarch64: Fix missing BTI protection from dependencies [BZ #26926] Szabolcs Nagy
2020-12-10 17:51 ` Adhemerval Zanella
2020-12-11 15:33 ` Szabolcs Nagy
2020-11-27 13:20 ` [PATCH v2 2/6] elf: lose is closely tied to _dl_map_object_from_fd Szabolcs Nagy
2020-12-10 17:57 ` Adhemerval Zanella
2020-12-11 12:12 ` Szabolcs Nagy
2020-11-27 13:20 ` [PATCH v2 3/6] elf: Fix failure handling in _dl_map_object_from_fd Szabolcs Nagy
2020-12-10 18:25 ` Adhemerval Zanella
2020-12-11 9:32 ` Szabolcs Nagy
2020-11-27 13:20 ` [PATCH v2 4/6] elf: Move note processing after l_phdr is updated Szabolcs Nagy
2020-12-10 18:30 ` Adhemerval Zanella [this message]
2020-11-27 13:21 ` [PATCH v2 5/6] elf: Pass the fd to note processing Szabolcs Nagy
2020-12-10 18:35 ` Adhemerval Zanella
2020-11-27 13:21 ` [PATCH v2 6/6] aarch64: Use mmap to add PROT_BTI instead of mprotect [BZ #26831] Szabolcs Nagy
2020-12-02 8:55 ` [PATCH v3 1/2] aarch64: align address for BTI protection [BZ #26988] Szabolcs Nagy
2020-12-10 18:49 ` Adhemerval Zanella
2020-12-02 8:55 ` [PATCH v3 2/2] aarch64: Use mmap to add PROT_BTI instead of mprotect [BZ #26831] Szabolcs Nagy
2020-12-10 19:12 ` Adhemerval Zanella
2020-11-30 15:56 ` [PATCH v2 0/6] aarch64: avoid mprotect(PROT_BTI|PROT_EXEC) " Szabolcs Nagy
2020-12-03 17:30 ` Catalin Marinas
2020-12-07 20:03 ` Szabolcs Nagy
2020-12-11 17:46 ` Catalin Marinas
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=a0200de1-1f9e-cd71-942c-0ccf699cf53e@linaro.org \
--to=adhemerval.zanella@linaro.org \
--cc=libc-alpha@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: 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).