This is dld.c in view mode; [Download] [Up]
/*********************************************************************** * * GNU Dynamic Linking support code * ***********************************************************************/ #include <dld.h> extern char *dldArgv0; static int getUndefinedSymCount() { return (dld_undefined_sym_count); } static void testDLD() { void (*func)(); /* printf("linking a file %d\n", dld_link("xxx.o")); */ printf("linking a file %d\n", dld_link("quem.o")); /* func = dld_get_func("foopartner");*/ func = dld_get_func("myFunc"); printf("func is %x\n", func); (*func)(); func = dld_get_func("printf"); printf("func is %x\n", func); (*func)("Here is a string passed to printf!\n"); } static void copyingDefineCFunc(funcName, funcAddr) char *funcName; void (*funcAddr)(); { defineCFunc(strdup(funcName), funcAddr); } initDldLib() { extern int main(); if (dld_init (dld_find_executable (dldArgv0)) == 0) { defineCFunc("dldLink", dld_link); defineCFunc("dldUnlinkByFile", dld_unlink_by_file); defineCFunc("dldUnlinkBySymbol", dld_unlink_by_symbol); defineCFunc("dldGetSymbol", dld_get_symbol); defineCFunc("dldGetFunc", dld_get_func); defineCFunc("dldFunctionExecutableP", dld_function_executable_p); defineCFunc("dldListUndefinedSym", dld_list_undefined_sym); defineCFunc("dldCreateReference", dld_create_reference); defineCFunc("dldDefineSym", dld_define_sym); defineCFunc("dldRemoveDefinedSymbol", dld_remove_defined_symbol); defineCFunc("getUndefinedSymCount", getUndefinedSymCount); /* so user level code can invoke it! */ defineCFunc("defineCFunc", copyingDefineCFunc); defineCFunc("testDLD", testDLD); } }
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.