From: "valium" <valium7171@gmail.com>
To: "Helge Deller" <deller@gmx.de>, "valium" <valium7171@gmail.com>,
<qemu-devel@nongnu.org>
Cc: <laurent@vivier.eu>, <pierrick.bouvier@oss.qualcomm.com>
Subject: Re: [PATCH] linux-user: Fix AT_PHDR when program headers are relocated into their own segment
Date: Wed, 17 Jun 2026 23:18:21 +0530 [thread overview]
Message-ID: <DJBIHVW6VRRY.3DGG8P9IB8SKL@gmail.com> (raw)
In-Reply-To: <b68ba255-8f8c-4c46-8090-5a7c73b4b46f@gmx.de>
On Wed Jun 17, 2026 at 10:18 PM IST, Helge Deller wrote:
> It's sufficient if you let us know what it should be.
My real name is Akshit Yadav.
>>
>>>> ---
>>>> linux-user/elfload.c | 21 ++++++++++++++++++++-
>>>> linux-user/qemu.h | 1 +
>>>> 2 files changed, 21 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/linux-user/elfload.c b/linux-user/elfload.c
>>>> index b05b8b0..8049c8a 100644
>>>> --- a/linux-user/elfload.c
>>>> +++ b/linux-user/elfload.c
>>>> @@ -699,7 +699,7 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc,
>>>> /* There must be exactly DLINFO_ITEMS entries here, or the assert
>>>> * on info->auxv_len will trigger.
>>>> */
>>>> - NEW_AUX_ENT(AT_PHDR, (abi_ulong)(info->load_addr + exec->e_phoff));
>>>> + NEW_AUX_ENT(AT_PHDR, (abi_ulong)(info->phdr_addr));
>>>> NEW_AUX_ENT(AT_PHENT, (abi_ulong)(sizeof (struct elf_phdr)));
>>>> NEW_AUX_ENT(AT_PHNUM, (abi_ulong)(exec->e_phnum));
>>>> NEW_AUX_ENT(AT_PAGESZ, (abi_ulong)(TARGET_PAGE_SIZE));
>>>> @@ -1469,6 +1469,12 @@ static void load_elf_image(const char *image_name, const ImageSource *src,
>>>> info->data_offset = load_bias;
>>>> info->load_addr = load_addr;
>>>> info->entry = ehdr->e_entry + load_bias;
>>>> + /*
>>>> + * Fallback for AT_PHDR if the program headers do not fall within
>>>> + * any PT_LOAD segment (see the loop below, which overrides this with
>>>> + * the correct in-memory address when a containing segment is found).
>>>> + */
>>>> + info->phdr_addr = load_addr + ehdr->e_phoff;
>>>> info->start_code = -1;
>>>> info->end_code = 0;
>>>> info->start_data = -1;
>>>> @@ -1523,6 +1529,19 @@ static void load_elf_image(const char *image_name, const ImageSource *src,
>>>> vaddr_ef = vaddr + eppnt->p_filesz;
>>>> vaddr_em = vaddr + eppnt->p_memsz;
>>>>
>>>> + /*
>>>> + * If this segment contains the program headers, record their
>>>> + * in-memory address for AT_PHDR. This matches the kernel, which
>>>> + * locates the headers via the containing PT_LOAD rather than
>>>> + * assuming load_addr + e_phoff (false when the phdrs are not
>>>> + * mapped 1:1 from file offset 0, e.g. relocated into their own
>>>> + * segment by a binary patcher).
>>>> + */
>>>> + if (eppnt->p_offset <= ehdr->e_phoff &&
>>>> + ehdr->e_phoff < eppnt->p_offset + eppnt->p_filesz) {
>>>> + info->phdr_addr = vaddr + (ehdr->e_phoff - eppnt->p_offset);
>>>> + }
>>>> +
>>>> /*
>>>> * Some segments may be completely empty, with a non-zero p_memsz
>>>> * but no backing file segment.
>>>> diff --git a/linux-user/qemu.h b/linux-user/qemu.h
>>>> index 07fe801..2268493 100644
>>>> --- a/linux-user/qemu.h
>>>> +++ b/linux-user/qemu.h
>>>> @@ -26,6 +26,7 @@
>>>> struct image_info {
>>>> abi_ulong load_bias;
>>>> abi_ulong load_addr;
>>>> + abi_ulong phdr_addr;
>>>> abi_ulong start_code;
>>>> abi_ulong end_code;
>>>> abi_ulong start_data;
>>
>>
prev parent reply other threads:[~2026-06-17 17:49 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-13 15:21 [PATCH] linux-user: Fix AT_PHDR when program headers are relocated into their own segment valium007
2026-06-15 16:06 ` Helge Deller
2026-06-15 17:33 ` Pierrick Bouvier
2026-06-17 12:41 ` valium
2026-06-17 16:48 ` Helge Deller
2026-06-17 17:48 ` valium [this message]
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=DJBIHVW6VRRY.3DGG8P9IB8SKL@gmail.com \
--to=valium7171@gmail.com \
--cc=deller@gmx.de \
--cc=laurent@vivier.eu \
--cc=pierrick.bouvier@oss.qualcomm.com \
--cc=qemu-devel@nongnu.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.