View Single Post
Old 11-23-2016, 07:58 PM   #6
knc1
Going Viral
knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.
 
knc1's Avatar
 
Posts: 17,212
Karma: 18210809
Join Date: Feb 2012
Location: Central Texas
Device: No K1, PW2, KV, KOA
IIRC - Yes it does.
The dummy update package is suppose to be the worked example.

Another thing which is possible with patchelf -
Make the entire application behave like a Windows application -
Put both the executable and all the required libraries that are not already in /lib, /usr/lib in the same directory.
Include:
$ORIGIN
Exactly like the above including the '$' first in rpath (note that patchelf is actually setting runpath, they just kept the original terminology).

Then, just like the Windows dynamic loader, ld.so will first search the directory that holds the executable.

You can also use paths relative to $ORIGIN -
Here is what one example looks like (cvm - the Kindle's Java VM):
Code:
Dynamic section at offset 0xab4 contains 30 entries:
  Tag        Type                         Name/Value
 0x00000001 (NEEDED)                     Shared library: [libpthread.so.0]
 0x00000001 (NEEDED)                     Shared library: [libjli.so]
 0x00000001 (NEEDED)                     Shared library: [libdl.so.2]
 0x00000001 (NEEDED)                     Shared library: [libc.so.6]
 0x0000000e (SONAME)                     Library soname: [lib.so]
 0x0000000f (RPATH)                      Library rpath: [$ORIGIN/../lib/arm/jli:$ORIGIN/../lib/arm]
Note that it has an soname, even though it is called as an executable.
That is to allow external, dynamically loaded, libraries call back into it.
You can see that it also uses libdl (the dynamic library loader).
So it also loads other libraries ('plugins' in some languages) -
All-in-all, probably one tricky bit of coding in that application, that is about as complex as an ELF format file can get.

- - - -

I am not intentionally feeding you bits and pieces of the answer -
I am only remembering bits and pieces at any one time -
Age does that -
There are members of this site older than myself, but very few of them.

Last edited by knc1; 11-25-2016 at 12:44 AM.
knc1 is offline   Reply With Quote