This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: PATCH: Preserve ELF program header
On Fri, May 26, 2006 at 10:21:00AM +0930, Alan Modra wrote:
> On Thu, May 25, 2006 at 02:44:16PM -0700, H. J. Lu wrote:
> > --- binutils/bfd/elf.c.pagesize 2006-05-22 12:36:40.000000000 -0700
> > +++ binutils/bfd/elf.c 2006-05-22 16:24:05.000000000 -0700
> > @@ -4292,7 +4292,9 @@ assign_file_positions_for_load_sections
> > return FALSE;
> > }
> >
> > - if (m->count == 0)
> > + if (m->p_vaddr_valid)
> > + p->p_vaddr = m->p_vaddr;
> > + else if (m->count == 0)
> > p->p_vaddr = 0;
> > else
> > p->p_vaddr = m->sections[0]->vma;
>
> I don't see the need for m->p_vaddr and m->p_vaddr_valid. How can you
> get into a situation where m->sections[0]->vma or 0 is not the right
> initialisation for p->p_vaddr?
>
Here is an x86 example, which is generated with 2MB maximum page size.
Due to
TEXT_START_ADDR=0x08048000
We got p->p_vaddr != m->sections[0]->vma to satisfy 2MB alignment.
H.J.
---
There are 6 section headers, starting at offset 0x480a4:
Section Headers:
[Nr] Name Type Addr Off Size ES Flg Lk Inf Al
[ 0] NULL 00000000 000000 000000 00 0 0 0
[ 1] .text PROGBITS 08048074 048074 000004 00 AX 0 0 4
[ 2] .data PROGBITS 08248078 048078 000004 00 WA 0 0 4
[ 3] .shstrtab STRTAB 00000000 04807c 000027 00 0 0 1
[ 4] .symtab SYMTAB 00000000 048194 0000a0 10 5 6 4
[ 5] .strtab STRTAB 00000000 048234 000020 00 0 0 1
Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings)
I (info), L (link order), G (group), x (unknown)
O (extra OS processing required) o (OS specific), p (processor specific)
Elf file type is EXEC (Executable file)
Entry point 0x8048074
There are 2 program headers, starting at offset 52
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
LOAD 0x000000 0x08000000 0x08000000 0x48078 0x48078 R E 0x200000
LOAD 0x048078 0x08248078 0x08248078 0x00004 0x00004 RW 0x200000
Section to Segment mapping:
Segment Sections...
00 .text
01 .data