This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: ELF, Program Header, convert virtual addresses to physical addresses
- From: Ian Lance Taylor <ian at airs dot com>
- To: Torsten Mohr <tmohr at s dot netic dot de>
- Cc: binutils at sources dot redhat dot com
- Date: 18 Aug 2005 10:43:33 -0700
- Subject: Re: ELF, Program Header, convert virtual addresses to physical addresses
- References: <200508181932.58975.tmohr@s.netic.de>
Torsten Mohr <tmohr@s.netic.de> writes:
> i try to convert virtual addresses in an ELF file to
> physical addresses, all based on the program header
> entries with p_type == PT_LOAD.
What is the context? In other words, why do you want to do this?
> My first try to get the physical address P then was:
>
> P = X - p_vaddr + p_paddr
That is correct for the way that the GNU toolchain uses p_paddr. The
GNU toolchain uses p_paddr to represent the load address as set by the
AT modifier in a linker script.
> But that failed badly on an ELF file generated by a Greenhills
> toolchain for a NEC V850 and its program headers:
> readelf -l file.elf:
> Program Headers:
> Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
> LOAD 0x000240 0x00000000 0x00000000 0x00594 0x00594 R E 0
> LOAD 0x000840 0x00000600 0x00000000 0x00010 0x00010 R E 0
Evidently Green Hills doesn't use p_paddr at all. Presumably for them
p_paddr is always the same as p_vaddr.
Ian