Mayank Kaushik <mayank.utexas@xxxxxxxxx> writes: >> Worked fine when I tried it. I built your source code using >> >> gcc -fPIE -pie -o foo.so foo.c -rdynamic > > Thanks, it indeed does. I had to leave out -fPIC. I'm curious, why did > that cause a problem? I don't know. It works for me when I use -fPIC. There is no particular reason to specify both -fPIC and -fPIE. > Last question; is the first method expected to also work on Mac, with > the linker replaced by the appropriate linker for Mac, if I'm using > gcc et al to build? I.e.: > > const char my_interp[] __attribute__((section(".interp"))) = "<dyld path>"; > > (...) > > gcc -Wall -fPIC -shared -o library.so test.c -lc -Wl,-e,my_main > > In other words, does gcc on Mac support executable shared libraries? I have no idea, sorry. It's not a matter of whether gcc supports it; it's whether the Mach-O supports it. Ian