0

And what happens if the base adress the .so wants is not free, will loading the so fails, or will the dynamic loader perform relocation ?

hehehe
  • 1
  • pretty much any .so needs to support dynamic relocation or it's not [easily] usable. I don't see any reference to specific binaries supporting ASLR rather the program lodaer ([one reference of wikiepedia](https://en.wikipedia.org/wiki/Address_space_layout_randomization#Linux)). If it is somehow implemented in an .so itself, then it may be pretty hard to detect except by loading it and monitoring it's behaviour as it would involve programatically rearranging the code. – Philip Couling Nov 20 '21 at 01:42

1 Answers1

0

It's not obvious which platforms you are asking about (e.g. both Linux and Windows have shared libraries and ASLR and have somewhat similar issues with regards to preferred addresses) so I'll assume Linux.

All .so files have to be compiled with -fPIC so they all support ASLR and are based at address 0. But each .so may be prelinked by system administrator, in which case the loader will try to load the .so at a fixed address thus disabling ASLR. You may check if this is the case via

$ readelf -SW path/to/lib.so | grep prelink

If prelinked address is already occupied, the loader will relocate library to a different address.

Windows DLLs have a similar feature called preferred addresses which used to be enabled by default in older versions but AFAIK no longer is.

yugr
  • 146
  • 2