halo-project/halo

Turn halomon into a shared library

Opened this issue · 0 comments

kavon commented

Currently, small 50KiB executables balloon into >9MiB executables when we link in halomon. The reason why we had to go with a static library is due to issue #3.

Some progress was made on this front by not linking LLVM into halomon, but instead linking libLLVM into the executable (see issue #4). This brought down executable sizes by a few MiB.

What we're stuck on here is the need for only a subset of XRay to be statically linked in, due to the limitations of its implementation outlined in #3. The problem is that I don't know how to make a shared library resolve to symbols found in the executable that it is linked into.

I played very briefly with halomon as a shared lib and not linking with the XRay object file and declaring the XRay functions we needed to be weak symbols like #pragma weak __xray_init. The problem is when the library is linked into the executable, the symbols in the executable do not override our shared library's weak symbols, so those symbols become NULL and we segfault.

TODO: Play around with a tiny test library and see if you can synthesize the right linker flags to make this work, or ask on StackOverflow because this is a tricky problem.