qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] linux-user: Fix GDB complaining about system-supplied DSO st


From: Ilya Leoshkevich
Subject: Re: [PATCH] linux-user: Fix GDB complaining about system-supplied DSO string table index
Date: Wed, 23 Oct 2024 21:47:50 +0200
User-agent: Evolution 3.52.4 (3.52.4-1.fc40)

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.

[...]



reply via email to

[Prev in Thread] Current Thread [Next in Thread]