This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: In a Linux "elf" file, what is the difference between p_offset and sh_offset ?
- From: Ian Lance Taylor <iant at google dot com>
- To: Serge Matovic <matovics at yahoo dot com>
- Cc: binutils at sourceware dot org
- Date: 10 Dec 2006 20:02:22 -0800
- Subject: Re: In a Linux "elf" file, what is the difference between p_offset and sh_offset ?
- References: <869243.88498.qm@web50407.mail.yahoo.com>
Serge Matovic <matovics@yahoo.com> writes:
> Hi to all: I'm trying to learn the details of the
> linux "elf" file format, and do not quite understand
> the difference between p_offset and sh_offset.
> Here are some basic facts (I can provide more detailed
> text and/or code samples later if anybody decides to
> help):
> I have a most simple "Hello world!" assembler program
> (hello.s), which I can compile (hello.o), and link
> (hello) and execute (./hello) and everything works as
> expected.
> Now I'm looking at the hello file in two ways: using
> readelf, and opening hello with a hexeditor. OK, here
> is the question:
> For the "data" parts of the file, both p_offset and
> sh_offset have the same value, but, for the "text"
> parts of the file, the p_offset and sh_offset are not
> the same, and that's what I do not understand, why?
The text segment (aka the first PT_LOAD segment) typically has
additional data which is not in the .text section. Specifically it
typically includes the ELF file header and the program segment header
themselves.
In any case you can figure out exactly what is in there by looking
closely at readelf -hl output.
Ian