From: Nikita Karetnikov <nikita@karetnikov.org>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: guix-devel@gnu.org
Subject: Re: 'substitute*' fails with "string contains #\nul character"
Date: Sun, 18 Aug 2013 09:57:28 +0400 [thread overview]
Message-ID: <87ob8vilrr.fsf@karetnikov.org> (raw)
In-Reply-To: <87li43kzoo.fsf@gnu.org> ("Ludovic Courtès"'s message of "Thu, 15 Aug 2013 12:37:11 +0200")
[-- Attachment #1: Type: text/plain, Size: 1958 bytes --]
> 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
[-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --]
next prev parent reply other threads:[~2013-08-18 5:53 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-14 13:33 'patchelf' doesn't change shared libraries Nikita Karetnikov
2013-07-14 13:44 ` Ludovic Courtès
2013-07-14 15:10 ` Nikita Karetnikov
2013-07-15 22:01 ` Ludovic Courtès
2013-07-16 17:55 ` 'substitute*' fails with "string contains #\nul character" (was: 'patchelf' doesn't change shared libraries) Nikita Karetnikov
2013-07-16 19:07 ` 'substitute*' fails with "string contains #\nul character" Ludovic Courtès
2013-08-05 21:20 ` Nikita Karetnikov
2013-08-15 10:37 ` Ludovic Courtès
2013-08-18 5:57 ` Nikita Karetnikov [this message]
2013-08-18 22:13 ` Ludovic Courtès
2013-08-18 23:53 ` Nikita Karetnikov
2013-08-19 11:22 ` Ludovic Courtès
2013-08-20 5:42 ` Nikita Karetnikov
2013-08-20 7:23 ` Ludovic Courtès
2013-08-21 5:15 ` Nikita Karetnikov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ob8vilrr.fsf@karetnikov.org \
--to=nikita@karetnikov.org \
--cc=guix-devel@gnu.org \
--cc=ludo@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.