Skip to content

foxx/elfdataembed

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ELF data embedder

NOTE: This code should be considered experimental only, as I am not a C developer.

Embeds files into 32/64bit ELF sections, and provides a simple C interface for the runtime to extract them.

This approach allows you to extract embedded data with tiny memory overhead, or pass position/offset reference to an external tool for direct usage without having to extract at all. You can create memory efficient self extracting binaries, or even create read-only loop mounts directly from the binary without any extraction at all.

Alternative methods are not suitable for large files as they load the entire binary into memory, and make it difficult for external applications to reference the data directly.

Usage

This project contains a small example app which demonstrates how to use it;

$ make

$ build/app
[x] embedded image found at offset 13756, size 1500

$ dd if=build/app of=build/test bs=1 skip=13756 count=1500
1500 bytes (1.5 kB) copied, 0.00259477 s, 578 kB/s

$ md5sum build/image.file build/test
09441e5fd94bf722af5b5bfc2676638f  build/image.file
09441e5fd94bf722af5b5bfc2676638f  build/test

Alternative methods (and why they suck);

Compile as symbol and link

This is detailed here and here, however this becomes troublesome for large files as the entire binary must be loaded into memory in order to read it (even if you read sequentially). An example project can be found here.

Append to end of file

This is detailed here but can cause some anti virus / integrity tools to throw warnings. It also breaks any hash checking you put into your binary.

Convert to data array

This is shown here and here, but has the same problems as compiling to a symbol afaik.

Acknowledgements

Thanks to harryr and freenode/##c for code review and assistance

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published