Note: This article was originally found https://www.burtonini.com/blog/computers/ld-blobs-2007-07-13-15-50 but the blog is no longer available via normal means. It is replicated here to preserve the knowledge.
For a long time I've wanted to know how to embed binary blobs into executables. This would be most useful for files like Glade and and UI Manager definitions, which are required for a given program to work at all but either cannot be embedded as a string literal (Glade) or can be but is annoying (UI Manager). I finally asked the Interweb, and Daniel Jacobowitz replied with some pointers. It turns out that doing this is remarkable simple.
First, a caveat. This probably requires GNU ld, which may or may not be a deal breaker for many people.
First, create a data file. Let's call it foo.txt, and put some text in it.