There are several excellent discussions on SO already covering how to produce an executable shared library on Linux:
- See https://unix.stackexchange.com/questions/7066
- and building a .so that is also an executable as examples
In C/C++, this seems relatively straightforward; essentially there are two parts:
- Add an
.interp
section to the ELF (asld
doesn't include one for shared libraries) by including something along these lines in the library source:
const char interp_section[] __attribute__((section(".interp"))) = "/path/to/dynamic/linker";
- Set an appropriate entry point when linking, using
-Wl,-e,entry_point
Does anyone know how to achieve this with a library written in Fortran? Specifically, how to add a .interp
section to a shared library compiled with ifort
?