Nikita Karetnikov <nik...@karetnikov.org> skribis:

>> 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.

What string exactly are you trying to patch?  Just /bin/sh?  In which
binary?

>> 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 think so.

> 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.

[...]

> 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?

I’m not sure about the details.  I would have expected tools like BFD or
libelf to provide the necessary support to make this kind of operation
easier, but I’ve never tried myself.

Ludo’.

Reply via email to