I have stumbled upon a problem by trying to move the ld.so.cache file to another location. I have tried to create a symlink for it in its previous location -- /etc/ -- but it seems that the loader cannot follow this symlink. Also, a hardlink is not viable since the new location is on another partition.

My final purpose is to have a read-only root filesystem and this is maybe the last thing which stops me from this.

Thank you in advance!

  • Uh... ld.so.cache is only written to during software installs & removals, for which you'll need to enable writing to the root partition anyways. almost all of the data in /etc will play nice with readonly root, except perhaps fstab (symlink that to /proc/mounts and you'll do just fine) – lornix Jun 18 '14 at 18:48
  • Thank you for your answer, lornix! My setup is somewhat different, the ld.so.cache file is regenerated only at each system startup and I have no need/requirement to make de rootfs writable for installing/removing software since I'm dealing with a custom-breed of embedded system where the applications are put somewhere else. Do you know by any chance an example for this kind of setup you were talking about? That would really help me in order to study it. – emmerich Jun 18 '14 at 19:28
  • almost every linux does this when you startup in single user mode (add a 1 to end of options in grub boot menu, or single, both are recognized I believe). root filesystem is read-only, but in that scenario, fstab is not symlinked to /proc/mounts and may be incorrect, confusing some programs (fsck!) into thinking the filesystem is mounted R/W. Couldn't you put (entire) /etc on other partition? I'm showing 12Meg total space for my /etc subdir. – lornix Jun 18 '14 at 19:35
  • Thanks lornix but I have solved it in the mean time, it seems that I had a permission denied (on read) for the folder where the ld.so.cache was moved. – emmerich Jun 19 '14 at 7:41
  • Congrats! Hurrah! Now go do good things! – lornix Jun 19 '14 at 7:42

I can confirm that at least in Glibc, ld.so does follow symlinks when opening /etc/ld.so.cache. The code is in elf/dl-cache.c in the function _dl_load_cache_lookup, referencing the function _dl_sysdep_read_whole_file from elf/dl-misc.c. That function opens the file and maps it into memory; it doesn't do anything about symbolic links.

Avoiding symbolic links would require extra effort, and I can't think of any reason why the loader would to this.

To debug your problem, you can use strace to follow what files the loader is reading or trying to read.

  • Thank you Gilles for pointing out the exact function, I've looked a bit yesterday for it and couldn't find it. Also, the strace tip did the trick, don't know why I didn't thought of this earlier. I've noticed that I had no permission of reading for the partition where I've moved the ld.so.cache file even if I have set the right permissions for the actual file. Once I've changed that it worked! Thank you again! – emmerich Jun 19 '14 at 7:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.