This is the mail archive of the
mailing list for the binutils project.
Re: PowerPC ELF segment alignment
- From: Alan Modra <amodra at gmail dot com>
- To: Ramana <ramana dot venkat83 at gmail dot com>
- Cc: binutils at sourceware dot org
- Date: Wed, 4 Mar 2015 11:14:19 +1030
- Subject: Re: PowerPC ELF segment alignment
- Authentication-results: sourceware.org; auth=none
- References: <CAF4ZLksUH6mSFZXa=jh+U9uF=_=7fwrZ9Vo4oxJcBRC2HaR0eQ at mail dot gmail dot com>
On Tue, Mar 03, 2015 at 05:13:40PM +0530, Ramana wrote:
> I understand what the congruency means (p_vaddr % p_align == p_offset
> % p_align). But I am not able to understand why the segment's p_vaddr
> is not aligned to p_align boundary.
It's simple. The default linker script asks for the binary to be laid
out this way.
> Example, the following snippet is readelf dump of Power32 Linux ELF binary.
> Program Headers:
> Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
> LOAD 0x000000 0x01800000 0x01800000 0x0d27c 0x0d27c R E 0x10000
> LOAD 0x00d27c 0x0181d27c 0x0181d27c 0x0096c 0x009d4 RW 0x10000
> GNU_EH_FRAME 0x00d260 0x0180d260 0x0180d260 0x0001c 0x0001c R 0x4
> GNU_STACK 0x000000 0x00000000 0x00000000 0x00000 0x00000 RWE 0x4
Notice that p_offset for the second PT_LOAD is immediately after the
end of the first PT_LOAD. ie. no gaps on disk == small file size. If
you aligned the second PT_LOAD p_vaddr (0x1810000 is possible) then
p_offset would need to be 0x10000.
Australia Development Lab, IBM