> For the purposes of bootstrapping GHC, I would rather steal whatever > trick Nixpkgs uses, though. :-) I can’t find anything relevant there. I suppose that Nix people don’t have to touch those binaries since they have ‘/bin/sh’ in a chroot. > ELF tools like Andy Wingo’s tools being added to Guile 2.1, or maybe BFD > (part of Binutils), might allow you to modify the ELF string table that > contains string constants. Are you talking about the (system vm elf) module? I’ve been trying to cook a patch but haven’t succeeded yet. Even though I’ve looked through the ELF spec and this handy tutorial [1], some things are still not clear. First, here’s my understanding of the format. Each ELF file has an executable header, which is used to describe the rest of the file. A file can also include the following: 1. A program header, which describes the segments (in-memory representation). 2. Sections, which are used for linking (in-file representation). 3. A section table header, which stores information about the sections. For starters, I’d like to change the string in the “Hello, world!” binary. I assume that I don’t have to deal with segements in that case; and the binary only includes an executable header, sections, and a section table header. Right? For instance, in order to change the “Hello” part, I have to adjust the corresponding section (i.e., “.rodata”). Assuming that sections are stored in order, I have to modify the offsets of the subsequent sections and the offset of the section header table itself if I change the size of “.rodata.” Finally, I can combine the changed executable header (contains the offset of the section table header), the sections, and the section table header. Is it correct? [1] http://sourceforge.net/projects/elftoolchain/files/Documentation/libelf-by-example/20120308/libelf-by-example.pdf/download