The solution

Our solution: BinReloc . It provides a set of convenience macros that can easily replace build time macros in your program. Often, the changes are as simple as a global find and replace.

It works by scanning the linker maps, looking for the base address of a dummy symbol (""). Because the linker mmaps shared libraries, it's possible to find the absolute path of the calling binary. The macros provides movement backwards from there, assuming a standard FHS style hierarchy.

See http://autopackage.org/docs/binreloc/for a guide about how to use BinReloc .