Fixing up an ELF executable
Posted: Tue Jun 19, 2007 7:30 am
Hi,
My kernel exe loader currently deals with PE and DJGPP-COFF files, but I am just in the process of adding ELF support.
Reading through the ELF docs, I think it all looks fairly similar to what I already do for COFF, but I'm a little confused over Program Headers and Section Headers.
Am I correct in thinking that for a statically linked executable with no residual dependancies, I only need to look at the Program Headers and fix-up based on that data?
Now, supposing as a debug tool, I want to display a table of sections (as I do for COFF files), I would need to obtain section names ".text", ".data" etc... However, the Elf32_Phdr structure does not appear to have a pointer in to the string table. Do I somehow need to extract these names from the section header table rather than the program header table?
I'm also a little confused over
. A program header points to a segment, which can contain one or more sections - but I have a separate section header table, so why do I need the program header table at all?
I hope someone can shed some light!
Cheers,
Adam[/quote]
My kernel exe loader currently deals with PE and DJGPP-COFF files, but I am just in the process of adding ELF support.
Reading through the ELF docs, I think it all looks fairly similar to what I already do for COFF, but I'm a little confused over Program Headers and Section Headers.
Am I correct in thinking that for a statically linked executable with no residual dependancies, I only need to look at the Program Headers and fix-up based on that data?
Now, supposing as a debug tool, I want to display a table of sections (as I do for COFF files), I would need to obtain section names ".text", ".data" etc... However, the Elf32_Phdr structure does not appear to have a pointer in to the string table. Do I somehow need to extract these names from the section header table rather than the program header table?
I'm also a little confused over
This seems a bit fractalAn object file segment contains one or more sections. Program headers are meaningful only for executable and shared object files.
![Shocked :shock:](./images/smilies/icon_eek.gif)
I hope someone can shed some light!
Cheers,
Adam[/quote]