home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / sys / 3b1 / 3145 < prev    next >
Encoding:
Internet Message Format  |  1992-08-18  |  4.5 KB

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!ames!pacbell.com!tandem!zorch!hico2!sonyd1.Broadcast.Sony.COM!blilly.UUCP!bruce
  2. From: bruce@blilly.UUCP (Bruce Lilly)
  3. Newsgroups: comp.sys.3b1
  4. Subject: Re: Shared Libraries and mythical new releases
  5. Summary: It can be done (it already has been done).
  6. Message-ID: <1992Aug18.223926.5360@blilly.UUCP>
  7. Date: 18 Aug 92 22:39:26 GMT
  8. References: <l8rdpnINNdq4@skat.usc.edu> <Bt5D5u.KpG@hico2.westmark.com>
  9. Distribution: usa
  10. Organization: Bruce Lilly
  11. Lines: 123
  12.  
  13. In article <Bt5D5u.KpG@hico2.westmark.com> kak@hico2.westmark.com (Kris A. Kugel) wrote:
  14. [ ... ]
  15. >I'm not a object code guru, so my comments may be misleading.
  16. >If so, could somebody out there who knows post a correction?
  17. >Maybe a certain amount of slack already exists in the shared libraries.
  18.  
  19. In article <1212@icus.ICUS.COM> lenny@icus.ICUS.COM (Lenny Tropiano) wrote:
  20. [ ... ]
  21. Again, this is posted for Alex Crain, reply to him, not me.  His postings
  22. never hit the "net-at-large", so I'm posting them on his behalf.
  23. [ ... ] [those who can't read lines beginning with 'X' can filter the rest through 'sed -e "s/^X//"']
  24. X.TH shlib 4 UNIX-PC "CTIX 3.51"
  25. X.SH NAME
  26. Xshlib - the system shared libraries
  27. X.SH SYNTAX
  28. Xld /lib/crt0s.o /lib/shlib.ifile 
  29. X.SH DESCRIPTION
  30. XThe unixpc employees a single shared library to reduce the size of
  31. Xexecutable programs. As distributed, the shared library contains 
  32. Xmuch (but not all) of 
  33. X.I libc.a ,
  34. X.I libtermlib.a 
  35. Xand 
  36. X.I libcurses.a .
  37. XWhile useful in reducing the size of executables, using the shared library
  38. Xcan be frustrating to programmers because (a) it is not a complete library
  39. Xand (b) trying to link with the shared library 
  40. X.I and
  41. Xthe regular libc.a is not a trivial task, in some instances.
  42. X
  43. XSpecifically, the shared library (/lib/shlib) is a compiled object that 
  44. Xis mapped into a constant piece of
  45. X.I "virtual memory" .
  46. XThat is, the code in /lib/shlib appears at the same virtual address in every
  47. Xprogram that accesses it. Since this address space (0x300000-0x380000) is 
  48. Xoutside of the space normally used by executing programs, it goes unnoticed
  49. Xif it is not referenced. Furthermore, this address range (like any other) is
  50. Xdemand paged, so the library code is swapped out if it is not used.
  51. X
  52. X.SH CONSTRUCTION
  53. XThe shared library is a normal 3 part (TEXT, DATA and BSS) object file.
  54. XThe DATA and BSS sections are continuous and begin at virtual address 0x300000.
  55. XThe TEXT area begins at virtual address 0x310000.
  56. XThe first object in the text area is a jump table, which indexes the other 
  57. Xfunctions in the library. The presence of the jump table enables function
  58. Xaddresses to remain constant, even if the library is recompiled or reordered.
  59. X
  60. X.SH MODIFICATION
  61. XThe shared library is loaded on boot from the file /lib/shlib. This object
  62. Xcan be any non-relocatable object (created via /bin/ld). 
  63. XFor backward compatibility, is is recommend that any modifications to the
  64. Xlibrary be in the form of additions to the existing library (This is so
  65. Xthat the existing software will continue to work).
  66. X
  67. XThe rules of thumb for modifying the library are:
  68. X.RS
  69. X.HP
  70. X(a) maintain 3 sections (TEXT, DATA and BSS) as there is no specification
  71. Xregarding non-standard sections.
  72. X.HP
  73. X(b) Always 
  74. X.I append
  75. Xdata to sections. For compatibility, the new sections must overlay the old
  76. Xones perfectly, with new data overlaying previously unallocated space.
  77. X.RE
  78. X
  79. XAn example shared library is shown below:
  80. X.TS
  81. Xtab(@);
  82. Xcb cb
  83. Xc|l|l|
  84. Xc|l|l|
  85. Xc|l|l|
  86. Xc|l|l|
  87. Xc|l|l|
  88. Xc|l|l|
  89. Xc|l|l|
  90. Xc|l|l|
  91. Xc|l|l|
  92. Xc l
  93. Xc|l|l|.
  94. XAddress Range@Description@Section
  95. X@_@_
  96. X@New Text area@
  97. X0x330000@New Jump Table@
  98. X@_@
  99. X@*avail*@Text
  100. X@_@
  101. X@Old Text@
  102. X0x310000@Old Jump Table@
  103. X@_@_
  104. X@
  105. X@_@_
  106. X@New BSS@BSS
  107. X@_@_
  108. X@New Data@
  109. X@_@DATA
  110. X0x300000@Old DATA AND BSS@
  111. X@_@_
  112. X.TE
  113. X
  114. XNote that the old sections are aligned to the same addresses that they 
  115. Xwere before, and that new sections have been fitted around them. This example
  116. Xuses a second jump table rather then appending to the first one because it 
  117. Xassumes that source for the first library is unavailable. Having the second
  118. Xjump table (aligned at 0x330000 for neatness) means that further modification
  119. Xof the table is a trivial matter of adding indexes to the jump table and
  120. Xrecompiling.
  121. X
  122. X.SH FILES
  123. X.nf
  124. X/lib/shlib
  125. X/lib/shlib.ifile
  126. X.fi
  127. [ ... ]
  128. =============================================================
  129.  
  130. See shlib.sh.Z on osu-cis or any other Unix-pc.sources archive
  131. site.
  132.  
  133. -- 
  134.     Bruce Lilly        blilly!bruce@Broadcast.Sony.COM
  135.                     ...uunet!sonyusa!sonyd1!blilly!bruce
  136.