Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!auspex!guy From: guy@auspex.auspex.com (Guy Harris) Newsgroups: comp.soft-sys.andrew Subject: Re: porting atk to VMS ? Message-ID: <4283@auspex.auspex.com> Date: 8 Nov 90 18:44:52 GMT References: <9011071749.AA03496@riposte> Organization: Auspex Systems, Santa Clara Lines: 62 >The dynamic loading is probably not the hard part of porting >to VMS. VMS actually has a callable dynamic loader, in the form >of the 'lib_$find_symbol' library call. This call takes an object file >name and a symbol name. It loads the object file and returns a pointer >to the given symbol (if present). For an example of layer ATK on top >of an existing dynamic loader look at the Apollo specific code, which >uses the existing Apollo/Domain-OS dynamic loader. Or the IBM RISC System/6000 dynamic loader, which uses the existing AIX 3.1 dynamic loader. Bear in mind, though, that both those schemes depend on the ability to mark a particular symbol in the dynamically loaded file as "distinguished" by making it the "entry point symbol"; I don't know if the VMS dynamic loader has this facility, but the SunOS 4.1/System V Release 4 dynamic loader does *not*, as far as I know, so you may have to look up that symbol explicitly. The way that seemed to work in my cobbled-up prototype for SunOS 4.1/S5R4 is to do: /* * Construct name of GetClassInfo symbol from the package name * by stripping off the suffix and appending "__GetClassInfo". * You can't get the entry point value from a shareable object * from the "dl*()" routines, which is why we have to do this * stuff. * We strip off the suffix because "doindex", curse its soul, * hands us the last component of the name of the *file* as * the package name, suffix and all. */ (void) strcpy(epname, name); p = strrchr(epname, '.'); if (p == NULL) p = epname + strlen(epname); (void) strcpy(p, "__GetClassInfo"); to construct the name of the symbol in question. "name" is the second argument to "doload". The "path" (fifth) argument is the actual pathname of the file to be loaded. Note also that you will have to ensure that some symbols in the "class" loader code are accessible to the dynamic loader, as the dynamically-loaded object may refer to them (e.g., "class_RoutineStruct"). This appears to require varying amounts of hackery on Domain/OS and AIX 3.1, and also requires hackery in SunOS 4.1/S5R4: in Domain/OS, "doload()" explicilty calls the loader to add them to the Known Global Table; in AIX 3.1, the "class" loader ".o" files are linked together into a single ".o" file and the linker is explicitly told to export them; in SunOS 4.1 and (probably) S5R4, the best or maybe even only way to do so is to make "libclass.a" into a *shared* library. (No, the prototype doesn't really "work" - I hand-built pieces of it instead of changing the Imakefiles, and I've only tested it with the stuff in the "overhead/class/testing" directory, not with ATK itself. I've no idea when I'll do anything further on it, and there are some unresolved issues waiting some responses to mail I sent out....)