home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / sys / amiga / programm / 18036 < prev    next >
Encoding:
Text File  |  1993-01-01  |  3.6 KB  |  91 lines

  1. Newsgroups: comp.sys.amiga.programmer
  2. Path: sparky!uunet!uunet.ca!canrem!dosgate!dosgate![jonathan.forbes@canrem.com]
  3. From: "jonathan forbes" <jonathan.forbes@canrem.com>
  4. Subject: sas/c 6.1 -large libs
  5. Message-ID: <19931.4249.21003@dosgate>
  6. Reply-To: "jonathan forbes" <jonathan.forbes@canrem.com>
  7. Organization: Canada Remote Systems
  8. Distribution: comp
  9. Date: 1 Jan 93 22:47:11 EST
  10. Lines: 79
  11.  
  12. I have been experimenting with SAS/C 6.1's support for making shared
  13. libraries (with one global data area).
  14.  
  15. Although everything seems to work just fine for small libraries (tiny
  16. ones which I tried for testing), for a large library (final output size
  17. about 85K) I have run into some problems.
  18.  
  19. For the past couple of years, I haven't used the SAS/C shared library
  20. support modules (LIBINIT.O, LIBENT.O) but rather have continued to
  21. expand upon the output of a rather ancient librarymaker program [I
  22. stopped using the librarymaker over a year ago since it couldn't handle
  23. > 128 functions in a library, but it was easy enough to see what it was
  24. doing and just add things to it manually].
  25.  
  26. The reason I'd like to use the SAS/C supported method is that it seems
  27. to produce a smaller output file size; perhaps because A4 is being
  28. loaded off A6 (the librarybase pointer) instead of LEA _LinkerDB, or
  29. maybe just more efficient startup code (LibInit, LibOpen, etc.)  Plus,
  30. I would feel more comfortable doing it in the SAS/C supported way.
  31.  
  32. Now, the problem is that many functions simply hang when called.  In
  33. order to try to narrow down the problem, I took one particular routine
  34. (let's call it "MyTestRoutine") and made it an almost do-nothing
  35. routine:
  36.  
  37. void __asm MyTestRoutine(register __a0 UBYTE *Str)
  38. {
  39.    strcpy(Str, "This is a test");
  40. }
  41.  
  42. (I'm compiling with SAVEDS, LIBCODE, NOSTKCHK and various other
  43. options).
  44.  
  45. I then wrote a small test program which opened the library, called the
  46. routine with a pointer to a blank string, and then printed what it got.
  47. Most of the time I got garbage back, and the times I didn't get garbage,
  48. my test program just hung after calling the routine.
  49.  
  50. I disassembled the library routine, and it looked just fine.
  51.  
  52. So, thinking it might be the size of my library, I replaced most of the
  53. library functions with empty functions, and somewhere around the 27-35K
  54. range of output file size, it no longer hung [but it didn't output the
  55. correct string either].
  56.  
  57. I also tried creating a completely new library with just one routine
  58. (the one above), and it worked fine.
  59.  
  60. The big library has about 170 routines in it, so I don't know if this is
  61. a problem for SAS/C.
  62.  
  63. I also have some assembly language routines which are linked in, and
  64. which use global data, but they do it in the proper way:
  65.  
  66. LEA _LinkerDB(a6),a4
  67.  
  68. [saving a4 first, of course]
  69.  
  70. I did some poking around in LIBINIT.O, and although I didn't understand
  71. everything there, it does seem to be doing some kind of relocation;
  72. perhaps it's choking when relocating the assembly language routines?
  73.  
  74. I'm extremely doubtful it's a problem of SAS/C 6.1, because I've found
  75. that errors which seem like compiler errors generally aren't, but I'm
  76. rather confused about where the problem might be.
  77.  
  78. Even stranger, the test program never hangs it Enforcer and MungWall are
  79. run in the background [although it still doesn't produce the correct
  80. output].
  81.  
  82. Basically, the thing which confuses me the most, is that a simple jump
  83. to a library function which does a strcpy simply doesn't work.  On the
  84. other hand, everything is fine and dandy if I use the old librarymaker
  85. method.
  86.  
  87. Any help would be much appreciated.
  88. --
  89. Canada Remote Systems  - Toronto, Ontario
  90. World's Largest PCBOARD System - 416-629-7000/629-7044
  91.