It's a configuration file, not something you need to execute.
As mentioned in the manualpage; what this does is allow you to map object dependencies. It's not something you execute yourself, it's something eventually used by the link editor (see
ld.so(1)) so that you can tell it to use a specific library instead of the default.
So... you install your Linux stuff somewhere separated from the rest, you then set up a constrain so that the linker will know that whenever such a binary (or library) tries to load something it needs to be mapped. Lets say you installed your Linux stuff (executables) in
/usr/local/linux/bin. You also know that your Linux programs shouldn't be trying to use
/usr/lib/ncurses.so but instead
/linux/compat/lib/ncurses.so.
Please note that these are examples only which I totally made up.
So this is what I would put into
/etc/libmap.conf:
Code:
[/usr/local/linux/bin/]
libncurses.so /linux/compat/lib/ncurses.so
After that all binaries in
/usr/local/linux/bin which try to access
libncurses.so should be immediately (re)directed to
/linux/compat/lib/ncurses.so instead of the linker searching through the library path and eventually coming across
/usr/lib/libncurses.so.
That's all there is to it.
Add the right mappings to the config file, and then check that the binary is using the right path. Use
ldd to check.
Because this is also somewhat new to me (I never bother with Linux stuff anymore and I seldomly use this feature) I decided to set up a test case. I'll share, hopefully this will can clear up any remaining confusing. Lets look what libraries
/usr/local/bin/tmux uses:
Code:
macron:/usr/local/bin $ ldd tmux
tmux:
libutil.so.9 => /lib/libutil.so.9 (0x280ec000)
libulog.so.0 => /lib/libulog.so.0 (0x280fe000)
libncurses.so.6 => /usr/local/lib/libncurses.so.6 (0x28101000)
libtinfo.so.6 => /usr/local/lib/libtinfo.so.6 (0x28122000)
libc.so.7 => /lib/libc.so.7 (0x2814d000)
libmd.so.6 => /lib/libmd.so.6 (0x282cb000)
That's no good. I want it to ignore the 3rd party stuff and instead use the base library (
/lib/libncurses.so.8).
Warning: This is a totally horrible idea and the perfect recipe to create problems. The only reason I'm doing this is to show you how to use
libmap.conf. It's bad to do this to
tmux but this is exactly what you want for your Linux binaries.
So... I now tell the system that whenever
tmux tries to load
libncurses.so.6 it should not use the default but the one in
/lib, namely
libncurses.so.8. So I add this to
/etc/libmap.conf:
Code:
[tmux]
libncurses.so.6 libncurses.so.8
So: I restrained the next rule solely to
tmux only. So any other binary which is using
libncurses.so.6 won't be affected.
And what do you know?
Code:
root@macron:/usr/local/bin # ldd tmux
tmux:
libutil.so.9 => /lib/libutil.so.9 (0x280ec000)
libulog.so.0 => /lib/libulog.so.0 (0x280fe000)
libncurses.so.6 => /lib/libncurses.so.8 (0x28101000)
libtinfo.so.6 => /usr/local/lib/libtinfo.so.6 (0x2813f000)
libc.so.7 => /lib/libc.so.7 (0x2816a000)
libmd.so.6 => /lib/libmd.so.6 (0x282e8000)
root@macron:/usr/local/bin # ldd irssi | grep ncurs
libncurses.so.6 => /usr/local/lib/libncurses.so.6 (0x28648000)
(ignore me for being root here, I just edited
/etc/libmap.conf and got lazy
).
As you can see: the changes are instant. And this is basically how you do it. Use
ldd, and set up a re-route. I used specific names here, you can do the same, but you can also re-map complete pathnames if you so desire.