qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: Ilya Leoshkevich <iii@linux.ibm.com>, Laurent Vivier <laurent@vivier.eu>
Cc: "Alex Bennée" <alex.bennee@linaro.org>, qemu-devel@nongnu.org
Subject: Re: [PATCH v2] linux-user: Fix GDB complaining about system-supplied DSO string table index
Date: Fri, 25 Oct 2024 12:41:12 +0100	[thread overview]
Message-ID: <5cb882c5-a455-408b-9ec2-4e8d4bd88350@linaro.org> (raw)
In-Reply-To: <20241023202850.55211-1-iii@linux.ibm.com>

On 10/23/24 21:27, Ilya Leoshkevich wrote:
> When debugging qemu-user processes using gdbstub, the following warning
> appears every time:
> 
>      warning: BFD: warning: system-supplied DSO at 0x7f8253cc3000 has a corrupt string table index
> 
> The reason is that QEMU does not map the VDSO's section headers. The
> VDSO's ELF header's e_shoff points to zeros, which GDB fails to parse.
> 
> The difference with the kernel's VDSO is that the latter is mapped as a
> blob, ignoring program headers - which also don't cover the section
> table. QEMU, on the other hand, loads it as an ELF file.
> 
> There appears to be no way to place section headers inside a section,
> and, therefore, no way to refer to them from a linker script. Also, ld
> hardcodes section headers to be non-loadable, see
> _bfd_elf_assign_file_positions_for_non_load(). In theory ld could be
> enhanced by implementing an "SHDRS" keyword in addition to the existing
> "FILEHDR" and "PHDRS".
> 
> There are multiple ways to resolve the issue:
> 
> - Copy VDSO as a blob in load_elf_vdso(). This would require creating
>    specialized loader logic, that duplicates parts of load_elf_image().
> 
> - Fix up VDSO's PHDR size in load_elf_vdso(). This would require either
>    duplicating the parsing logic, or adding an ugly parameter to
>    load_elf_image().
> 
> - Fix up VDSO's PHDR size in gen-vdso. This is the simplest solution,
>    so do it.
> 
> There are two tricky parts:
> 
> - Byte-swaps need to be done either 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.
> 
> - There must be no .bss, which is already the case - but having an
>    explicit check is helpful to ensure correctness.
> 
> To verify this change, I diffed the on-disk and the loaded VDSOs; the
> result does not show anything unusual, except for what seems to be an
> existing oversight (which should probably be fixed separately):
> 
> │  Symbol table '.dynsym' contains 8 entries:
> │     Num:    Value          Size Type    Bind   Vis      Ndx Name
> │ -     0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND
> │ -     6: 0000000000000000     0 OBJECT  GLOBAL DEFAULT  ABS LINUX_2.6.29
> │ +     0: 00007f61075bf000     0 NOTYPE  LOCAL  DEFAULT  UND
> │ +     6: 00007f61075bf000     0 OBJECT  GLOBAL DEFAULT  ABS LINUX_2.6.29
> 
> Fixes: 2fa536d10797 ("linux-user: Add gen-vdso tool")
> Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
> ---
> 
> v1: https://lore.kernel.org/qemu-devel/20241023144744.50440-1-iii@linux.ibm.com/
> v1 -> v2: Check that there is no bss, mention linker scripts in the
>            commit message (Richard).

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~


  reply	other threads:[~2024-10-25 11:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-23 20:27 [PATCH v2] linux-user: Fix GDB complaining about system-supplied DSO string table index Ilya Leoshkevich
2024-10-25 11:41 ` Richard Henderson [this message]
2024-11-04 12:24   ` Richard Henderson

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=5cb882c5-a455-408b-9ec2-4e8d4bd88350@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=alex.bennee@linaro.org \
    --cc=iii@linux.ibm.com \
    --cc=laurent@vivier.eu \
    --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 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).