4 ms·
Make two apps A and B with their respective main() functions. Add some function foo() to app A. Now try to call A's foo() from B's main(). How many hoops do you
by mepian 3y ago
Make two apps A and B with their respective main() functions. Add some function foo() to app A. Now try to call A's foo() from B's main(). How many hoops do you need to jump through in every other OS to do this?
- xcdzvyn 3y agoThe amount of (wonderfully) horrible doors this opens is awesome.
- duped 3y agoNone, because this exists outside the scope of an operating system. This is the domain of an executable/linkage format and language compiler.
- wyldfire 3y agoMaybe the complexity lies in that possessive qualifier "A's foo()" - if this foo() can manipulate the callee state in some other virtual memory domain then it might not be sufficient to link against it in B's application.
- Karellen 3y agoNot many hoops, why? /* Create function pointer of appropriate type, initialised. */ int(*foo)(int, int) = NULL; int main() { void * ha; if ((ha = dlopen("A", RTLD_LAZY|RTLD_NODELETE)) != NULL) { foo = dlsym(ha, "foo"); dlclose(ha); } /* if "foo" is non-NULL you can call it now. */ ...
- mepian 3y agoIf you control the development of both A and B apps, then not so many. But generally you are not expected to load symbols from another application, you are expected to either use various IPC mechanisms or load symbols from a shared library instead of touching another application at all.