home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / sys / next / programm / 5816 < prev    next >
Encoding:
Text File  |  1992-08-26  |  2.3 KB  |  82 lines

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!pacbell.com!iggy.GW.Vitalink.COM!nocsun.NOC.Vitalink.COM!wetware!ditka!ntg!rosie!trouble.next.com
  2. From: gburd@trouble.next.com (Greg Burd (Temp))
  3. Newsgroups: comp.sys.next.programmer
  4. Subject: Re: PLEASE help me with rld! PLEASE! PLEASE! PLEASE! PLEASE! PLEASE!
  5. Message-ID: <4828@rosie.NeXT.COM>
  6. Date: 24 Aug 92 19:19:22 GMT
  7. References: <HRA6NUH@mailgzrz.tu-berlin.de>
  8. Sender: news@NeXT.COM
  9. Lines: 71
  10.  
  11. In article <HRA6NUH@mailgzrz.tu-berlin.de> mauriti@cs.tu-berlin.de (Frank  
  12. Hartlep) writes:
  13. > I've asked this already and nobody replied. But I can't believe there's
  14. > nobody on this big, big net who knows how to use rld.
  15. > Take a look at this code ...
  16. [[ deleted code  ]]
  17.  
  18. >.... and PLEASE!  PLEASE!  PLEASE!  PLEASE! tell me what's wrong with it.
  19. > Loader should load to_be_loaded.o and execute LoadedFunction.
  20. > Sounds easy, but why does it fail in rld_load_basefile (with a
  21. > floating point exception in NXCreateZone, as the debugger tells me)???
  22. > ANY info is welcome !
  23. > Thanks,
  24. > Frank
  25.  
  26. ---------------
  27.  
  28. Hello Frank,
  29.  
  30.     Here is a little goof off program where rld is used.  TestRLD and  
  31. toLoad.c should be in the same dir.  What happens is that TestRLD compiles  
  32. and then loads toLoad.c, and then it calls the funct myprintf() to verify  
  33. the load succeded.  Cut and paste the two files and then compile and run  
  34. TestRLD, and enjoy.
  35.  
  36. Greg Burd
  37. NeXT Developer Support Team
  38.  
  39. #import <std/disclaimer>
  40. #import <std/joke>
  41.                     :-)
  42.  
  43.  
  44. ----------------TestRLD.c------------------
  45. #include <stdio.h>
  46. #include <rld.h>
  47. #include <sys/stat.h>
  48. #include <sys/file.h>
  49.  
  50.  
  51. main()
  52. {
  53.     struct mach_header **addr;
  54.     unsigned long value = 0x0;
  55.     void (*myprint)();
  56.     char *files[]    = {"toLoad",NULL};
  57.     
  58.     system("cc -c -O -o toLoad toLoad.c");
  59.     if (rld_load(NULL,addr,files,NULL)) {
  60.         printf("I have loaded files\n");
  61.         if(rld_lookup(NULL,"_myprint",&value))
  62.           fprintf(stderr, "Lookup success\n");
  63.         else fprintf(stderr, "Lookup failure\n");
  64.         myprint=(void *) value;
  65.         printf("I have looked up value = %d\n",value);
  66.         (*myprint)();
  67.     }
  68. }
  69. -------------------------------------------
  70.  
  71. ----------------TestRLD.c------------------
  72. #include <stdio.h>
  73.  
  74. myprint()
  75. {
  76.     printf("I have been called\n");
  77. }
  78. -------------------------------------------
  79.