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]

PowerPC ELF segment alignment


Regarding the 'p_align' member of program header, the ELF spec says:

Loadable process segments must have congruent values for p_vaddr and
p_offset, modulo the page size. This member gives the value to which
the segments are aligned in memory and in the file. Values 0 and 1
mean no alignment is required. Otherwise, p_align should be a
positive, integral power of 2, and p_vaddr should equal p_offset,
modulo p_align.

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.

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

 Section to Segment mapping:
  Segment Sections...
   00     .init .text .fini .rodata .eh_frame_hdr
   01     .eh_frame .ctors .dtors .jcr .fixup .data .sdata .sbss .bss
   02     .eh_frame_hdr

Clearly the virtual addresses of both of the first two segments are
not aligned to 0x10000 boundary. Could someone please help me
understand this?

Thank you,
Venkata Ramanaiah N

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