From: Ilya Leoshkevich <iii@linux.ibm.com>
To: Richard Henderson <richard.henderson@linaro.org>,
Laurent Vivier <laurent@vivier.eu>
Cc: "Alex Bennée" <alex.bennee@linaro.org>, qemu-devel@nongnu.org
Subject: Re: [PATCH] linux-user: Fix GDB complaining about system-supplied DSO string table index
Date: Wed, 23 Oct 2024 21:47:50 +0200 [thread overview]
Message-ID: <063c0c70df2d1a4b2c209bdf9fa8c451dfa7693a.camel@linux.ibm.com> (raw)
In-Reply-To: <d847f246-1772-4c9a-97f7-05118a311286@linaro.org>
On Wed, 2024-10-23 at 12:03 -0700, Richard Henderson wrote:
> On 10/23/24 07:46, Ilya Leoshkevich wrote:
> >
[...]
>
> > - Fix up VDSO's PHDR size in gen-vdso. This is the simplest
> > solution,
> > so do it. The only tricky part is byte-swaps: they need to be
> > either
> > done on local copies or in-place, and then reverted in the end.
> > To
> > preserve the existing code structure, do the former for Sym and
> > Dyn,
> > and the latter for Ehdr, Phdr, and Shdr.
>
> Or adjust the linker script, to mark those sections loaded.
> This may or may not be easier, considering the rest of the changes.
I forgot to mention that I investigated this too. The problem, as I see
it, is that there appears to be no way to place section headers inside
a section, and, therefore, no way to refer to them in a linker
script. I guess someone could add the ability to do this by defining
SHDRS keyword in addition to the existing FILEHDR and PHDRS. Also, ld
hardcodes section headers to be non-loadable:
static bool
_bfd_elf_assign_file_positions_for_non_load (bfd *abfd)
{
[...]
/* Place the section headers. */
i_ehdrp = elf_elfheader (abfd);
off = BFD_ALIGN (off, 1u << bed->s->log_file_align);
i_ehdrp->e_shoff = off;
off += i_ehdrp->e_shnum * i_ehdrp->e_shentsize;
elf_next_file_pos (abfd) = off;
So I figured it would be better to stay as close as possible to what
the kernel is doing without changing the existing loader design too
much.
> > @@ -154,6 +161,16 @@ static void elfN(process)(FILE *outf, void
> > *buf, bool need_bswap)
> > fprintf(stderr, "LOAD segment not loaded at address
> > 0\n");
> > errors++;
> > }
> > + /*
> > + * Extend the program header to cover the entire VDSO, so
> > that
> > + * load_elf_vdso() loads everything, including section
> > headers.
> > + */
> > + if (len > phdr[i].p_filesz) {
> > + phdr[i].p_filesz = len;
> > + }
> > + if (len > phdr[i].p_memsz) {
> > + phdr[i].p_memsz = len;
> > + }
>
> There should be no .bss, so these two numbers had better be
> identical. Certainly this
> adjustment *requires* that there be no .bss. I think we should error
> out if the two
> numbers differ.
Sounds reasonable, I'll send a v2 with the check.
[...]
prev parent reply other threads:[~2024-10-23 19:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-23 14:46 [PATCH] linux-user: Fix GDB complaining about system-supplied DSO string table index Ilya Leoshkevich
2024-10-23 19:03 ` Richard Henderson
2024-10-23 19:47 ` Ilya Leoshkevich [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=063c0c70df2d1a4b2c209bdf9fa8c451dfa7693a.camel@linux.ibm.com \
--to=iii@linux.ibm.com \
--cc=alex.bennee@linaro.org \
--cc=laurent@vivier.eu \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.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 NNTP newsgroup(s).