[patch] Fix bfd_elf_bfd_from_remote_memory() loadbase

Alan Modra amodra@bigpond.net.au
Sat Aug 11 00:22:00 GMT 2007


On Fri, Aug 10, 2007 at 05:15:46PM +0200, Jan Kratochvil wrote:
> I believe a simple rule "just the first PT_LOAD segment" implemented in my
> patch should be enough.

No.  Please fix this properly as per the ELF gABI.

"An executable or shared object file's base address (on platforms that
support the concept) is calculated during execution from three values:
the virtual memory load address, the maximum page size, and the lowest
virtual address of a program's loadable segment. To compute the base
address, one determines the memory address associated with the lowest
p_vaddr value for a PT_LOAD segment. This address is truncated to the
nearest multiple of the maximum page size. The corresponding p_vaddr
value itself is also truncated to the nearest multiple of the maximum
page size. The base address is the difference between the truncated
memory address and the truncated p_vaddr value."

-- 
Alan Modra
Australia Development Lab, IBM



More information about the Binutils mailing list