This is the mail archive of the mailing list for the binutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PowerPC ELF segment alignment

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.

Alan Modra
Australia Development Lab, IBM

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]