This is the mail archive of the binutils@sourceware.org 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: In a Linux "elf" file, what is the difference between p_offset and sh_offset ?


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


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