This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [patch] bfd_elf_bfd_from_remote_memory() workaround for the ELF misalignment [Re: loadbase alignment - ld.so/prelink/kernel or bfd_elf_bfd_from_remote_memory() bug?]
- From: Roland McGrath <roland at redhat dot com>
- To: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- Cc: "H.J. Lu" <hjl at lucon dot org>, binutils at sources dot redhat dot com
- Date: Mon, 20 Aug 2007 17:32:26 -0700 (PDT)
- Subject: Re: [patch] bfd_elf_bfd_from_remote_memory() workaround for the ELF misalignment [Re: loadbase alignment - ld.so/prelink/kernel or bfd_elf_bfd_from_remote_memory() bug?]
> You were suggesting a new parameter for bfd_elf_bfd_from_remote_memory()?
> Attached a patch using TEMPL's MINPAGESIZE value instead, isn't that sufficient?
I don't know what the BFD minpagesize value means exactly.
It may well matter to use the actual page size.
When dealing with a core file, the de facto standard is that the p_align of
the core file's PT_LOAD phdrs gives the real page size. (This is in phdrs
of the core file itself, not to be confused with the phdrs inside the
embedded ELF image of interest.) Note however that IIUC gdb's gcore does
not produce correct p_align values in its core files (it uses 1). If the
core PT_LOAD segment you are looking at has a p_align that is unreasonably
small, you could instead look for an NT_AUXV note and AT_PAGESZ inside it.
For a live process, the debugger might already have determined this.
One thing it can do is look in /proc/pid/auxv for AT_PAGESZ.
> Tried to remove the P_ALIGN use there completely - besides missing PHDRs read
> (EHDR is already read there) there should be no alignment requirements.
> Unfortunately IA64 Linux kernel vDSO provides debug symbols after the last
> segment ends but still in the same page - no symbols without the aligning:
> contents_size == 2512
> i_ehdr.e_shoff == 2640
> ia64 minpagesize == 16384
> i_phdrs[i].p_align == 0x10000
This is the practical example today. But it demonstrates the worth of
having the function follow the general principle I always intended for it.
That is, it should try to recover exactly everything that came from the ELF
file and is visible in the process memory. This means rounding segments to
include all the whole pages that include the [p_vaddr, p_vaddr+p_size) range.
Thanks,
Roland