[comp.os.mach] Need help with load interface

rcb@cs.brown.edu (Robert Boyer) (10/31/90)

I'm having some trouble getting the programmable loader interface
working on our pmax OSF/1 (snapshot 5) system.  No matter what I try,
the "load" system call always returns with 0 and EINVAL in errno.  As
far as I can tell, I am following almost exactly the example in
section 3.3.1 of the "OSF/1 Applications Programmer's Guide - SNAPSHOT
5".

here is the code fragment that fails:

int load_it() 
{
   ldr_module_t hdl;
   ldr_load_flags_t flags=0;
   void (*p)();

   if ( (hdl = load( "./foo",flags)) <= 0 ) {
      perror("load error");   
      return -1;
   } else {
      p = ldr_lookup(hdl, "foobar" );
      (*p)();
      return 0;
   }   
}


"./foo" was compiled with -mpic as follows:

cc -mpic -c foo.c
as: Flag option -G has already been seen!
ld -warn_nopic -o foo foo.o


The module foo.c is:

foobar() {
	return 1;
}



Any help would be greatly appreciated.

lwa@skeptic.osf.org (Larry Allen) (11/06/90)

You're doing the right thing, but all the pieces weren't
in the right places in Snapshot 5 for this to work.  In
particular, the C library "load" routine was a stub
(i.e. didn't call the loader).

If you're just doing this for testing purposes, you can
hack up your Makefiles to compile your program with the
loader linked in; see the Makefile for the "tload2"
program in <src>/sbin/loader/tests.

The loader has been fully integrated, and the C library
stub routines replaced by the "real thing", in the
final OSF/1 release.
						-Larry Allen
						 OSF