[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 'substitute*' fails with "string contains #\nul character"

From: Nikita Karetnikov
Subject: Re: 'substitute*' fails with "string contains #\nul character"
Date: Sun, 18 Aug 2013 09:57:28 +0400

> 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

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

2. Sections, which are used for linking (in-file representation).

3. A section table header, which stores information about the

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?


Attachment: pgpY7SII12GgO.pgp
Description: PGP signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]