[Aboriginal] Aboriginal Digest, Vol 4, Issue 6

Rob Landley rob at landley.net
Fri May 20 15:11:07 PDT 2011


On 05/20/2011 03:39 PM, Robert Thompson wrote:
>>The down side is if you don't install the shared libraries on the host
>>you won't be able to run the resulting binaries (unless they're
>>statically linked), because the shared library loader location is
>>hardwired into each binary as an absolute path, that's a limitation of
>>the ELF spec.  You can specify a different location for it to hardwire
>>in (export CCWRAP_DYNAMIC_LINKER=/blah/ld-uClibc.so.0), but that's not
>>much of an improvement.
> 
> I don't know if it's useful to anybody, but PatchELF (
> http://nixos.org/patchelf.html ) allows you to add, modify, and delete
> an ELF executable's RPATH or interpreter path. Also, the old,
> unmaintained chrpath (dead upstream, still available in Debian) allows
> you to modify the RPATH, with some limitations.

While I do have "LDSO_RUNPATH=y" set in sources/baseconfig-uClibc,
that's a property of the dynamic linker, meaning the dynamic linker has
to be running, meaning the kernel has to have found and executed the
dynamic linker in order for the RPATH to get checked.

I.E. this is a later step.

It should be possible to rewrite the interpreter value after the fact.
Let's see...

  http://refspecs.freestandards.org/elf/elf.pdf

The ELF header at the start of the file (section 1 page 4) has an
e_phoff value which indicates the start of the program header table in
the file, then section 2 page 3 says we want the entry with p_type equal
to 3 (PT_INTERP), which points to a string table entry.  Except book
three talks about the special section name .interp...

Sigh, I read through all this last year.  At some point I just need to
break down and write my own objdump/objcopy variant so that I properly
understand all this stuff.  I can generally remember about the
http://www.muppetlabs.com/~breadbox/software/tiny/teensy.html level of
this stuff, but dynamic linking at least quadruples the complexity...

Rob

 1305929467.0


More information about the Aboriginal mailing list