Author Topic: Embedding content in ELF executables  (Read 1517 times)

solo

  • Member
  • **
  • Posts: 344
  • Kudos: 1
    • http://www.komodolinux.org/
Embedding content in ELF executables
« on: 21 June 2003, 21:57 »
I am working on a self-extracting Linux installation system, and I need to be able to embed the data at the end of the executable file, and be able to recognize where the executable ends and the tdata begins. Anyone have any experience with this?
Komodoware, moving Linux to your desktop.
http://www.komodoware.com/

solo

  • Member
  • **
  • Posts: 344
  • Kudos: 1
    • http://www.komodolinux.org/
Embedding content in ELF executables
« Reply #1 on: 21 June 2003, 10:08 »
well i found another project similiar to mine, but still it would be useful to know how its done.
Komodoware, moving Linux to your desktop.
http://www.komodoware.com/

solo

  • Member
  • **
  • Posts: 344
  • Kudos: 1
    • http://www.komodolinux.org/
Embedding content in ELF executables
« Reply #2 on: 23 June 2003, 07:13 »
well ok i guess no one cares in the proggin' forum but i've solved my own problem and if anyone else is interested its quite simple:

<original executable><file><toc><int len><int headercnt>

The <toc> section is a bunch of headers, each describing a file, and the length of the file.
<char 10><int len><filename><char 13>

The <len> element is the integer length of the <toc> section.

The <headercnt> section is an integer count of how many headers there are in the <toc> section.

With this, all one must do to read the additional data at the end of the executable is seek to the end minus 8 bytes, read 2 integers, seek back to end minus len+8 read the headers, seek back to file offset, output data to file.

And to top it off, all I've done is create an archive format with the headers on the *end*. So they should prolly be called footers i guess but whatever.

i coded 3 apps to handle the file type. I think I'm gonna call it 'Tick'.

This one embeds a file into an existing executable and adds Tick data. Sends result to stdout
embedball <exec> <file>

This one reads information about the Tick file and prints it out, in the fashion of
File "/x/x/xxx", format correct.
   TOC length, 31 bytes.
   2 headers.

Header # 0:
    type: File (10)
    length: 123789
    data: somefile
...

readball <tickball>

This one extracts all files except for the first one (the executable). So if one were to write an interface that supported multiple files in Tickballs, it would be supported. I probably will later, when I need it.

extractball <tickball>

Yay! I learned something completely new in one day!

MICROSUCK OWNS! we are becoming the anti-microsoft monopoly!
Komodoware, moving Linux to your desktop.
http://www.komodoware.com/