libcrunch icon indicating copy to clipboard operation
libcrunch copied to clipboard

Stubs and preload DSOs suffer duplication

Open stephenrkell opened this issue 4 years ago • 2 comments

The shadow space has caused our stubs library to become not-so-minimal. It relies on mmap nudging, so depends on parts of liballocs, but it should be possible to make it avoid most duplication. This is also important for use of RTLD_NEXT -- we don't want a second copy of any of wrappers which use this.

stephenrkell avatar Feb 17 '21 23:02 stephenrkell

Non-obvious explanation: our preload wrappers don't compose because of the __avoid_libdl_calls hack. Once one of them is told not to make libdl calls, it will conservatively avoid downcalling (say to orig_dl_iterate_phdr) even if its callee is not the libdl version. This might be broken logic.

stephenrkell avatar Feb 18 '21 00:02 stephenrkell

Probably the right thing is to refactor so that the core runtime is in the _stubs.so, and the preload lib is just a minimal selection of hook points. But how does this design play with liballocs? And with the idea that we want to be our own ld.so, rather than a preload library?

stephenrkell avatar Feb 22 '21 13:02 stephenrkell