home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / unix / aix / 8985 < prev    next >
Encoding:
Internet Message Format  |  1992-08-21  |  4.2 KB

  1. Path: sparky!uunet!olivea!mintaka.lcs.mit.edu!hal.gnu.ai.mit.edu!mycroft
  2. From: mycroft@hal.gnu.ai.mit.edu (Charles Hannum)
  3. Newsgroups: comp.unix.aix
  4. Subject: Re: Shared libraries sharing from main app?
  5. Message-ID: <1992Aug21.173329.1517@mintaka.lcs.mit.edu>
  6. Date: 21 Aug 92 17:33:29 GMT
  7. References: <1992Aug20.220555.25326@spss.com> <MARC.92Aug21090935@marc.watson.ibm.com>
  8. Sender: news@mintaka.lcs.mit.edu
  9. Organization: /etc/organization
  10. Lines: 146
  11.  
  12.  
  13. In article <MARC.92Aug21090935@marc.watson.ibm.com> marc@watson.ibm.com
  14. (Marc Auslander) writes:
  15. >
  16. > It is possible to build a shared library which imports a symbol from
  17. > the main (i.e. exec'd) program.  However, the facility is clumsy,
  18.  
  19. Agreed on that much.
  20.  
  21. > because the shared library must contain the actual file name of the
  22. > exec'd program.
  23.  
  24. Not true.
  25.  
  26.  
  27. Here's an example of how to make this junk work.  Note that apparently
  28. some version of the automounter "fix" makes this not work.  Don't ask
  29. me why; I don't know and I really don't want to.
  30.  
  31.  
  32. #! /bin/sh
  33. # This is a shell archive.  Remove anything before this line, then unpack
  34. # it by saving it into a file and typing "sh file".  To overwrite existing
  35. # files, type "sh file -c".  You can also feed this as standard input via
  36. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  37. # will see the following message at the end:
  38. #        "End of shell archive."
  39. # Contents:  Makefile feh.c feh.exp foo.c foo.exp foo.imp
  40. # Wrapped by mycroft@hal.gnu.ai.mit.edu on Fri Aug 21 13:27:02 1992
  41. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  42. if test -f 'Makefile' -a "${1}" != "-c" ; then 
  43.   echo shar: Will not clobber existing file \"'Makefile'\"
  44. else
  45. echo shar: Extracting \"'Makefile'\" \(271 characters\)
  46. sed "s/^X//" >'Makefile' <<'END_OF_FILE'
  47. XCFLAGS = -g
  48. XLFLAGS = # -bnogc
  49. X
  50. Xall: feh
  51. X
  52. Xfoo.a: foo.o
  53. X    rm -f foo.a shr.o
  54. X    ld -o shr.o -bM\:SRE -bI\:foo.imp -bE\:foo.exp foo.o -lc
  55. X    ar clq foo.a shr.o
  56. X    rm -f shr.o
  57. X
  58. Xfeh: foo.a feh.o
  59. X    cc -o feh feh.o -bE\:feh.exp -L. foo.a 
  60. X
  61. Xclean:
  62. X    rm -f feh feh.o foo.a shr.o foo.o core
  63. END_OF_FILE
  64. if test 271 -ne `wc -c <'Makefile'`; then
  65.     echo shar: \"'Makefile'\" unpacked with wrong size!
  66. fi
  67. # end of 'Makefile'
  68. fi
  69. if test -f 'feh.c' -a "${1}" != "-c" ; then 
  70.   echo shar: Will not clobber existing file \"'feh.c'\"
  71. else
  72. echo shar: Extracting \"'feh.c'\" \(204 characters\)
  73. sed "s/^X//" >'feh.c' <<'END_OF_FILE'
  74. X#include <sys/types.h>
  75. X#include <sys/ldr.h>
  76. X
  77. Xextern void foo (void);
  78. X
  79. Xchar bar[] = "Crash and burn!";
  80. X
  81. Xint
  82. Xmain (int argc, char **argv, char **envp)
  83. X{
  84. X  loadbind (0, main, foo);
  85. X  puts (bar);
  86. X  foo ();
  87. X}
  88. END_OF_FILE
  89. if test 204 -ne `wc -c <'feh.c'`; then
  90.     echo shar: \"'feh.c'\" unpacked with wrong size!
  91. fi
  92. # end of 'feh.c'
  93. fi
  94. if test -f 'feh.exp' -a "${1}" != "-c" ; then 
  95.   echo shar: Will not clobber existing file \"'feh.exp'\"
  96. else
  97. echo shar: Extracting \"'feh.exp'\" \(4 characters\)
  98. sed "s/^X//" >'feh.exp' <<'END_OF_FILE'
  99. Xbar
  100. END_OF_FILE
  101. if test 4 -ne `wc -c <'feh.exp'`; then
  102.     echo shar: \"'feh.exp'\" unpacked with wrong size!
  103. fi
  104. # end of 'feh.exp'
  105. fi
  106. if test -f 'foo.c' -a "${1}" != "-c" ; then 
  107.   echo shar: Will not clobber existing file \"'foo.c'\"
  108. else
  109. echo shar: Extracting \"'foo.c'\" \(120 characters\)
  110. sed "s/^X//" >'foo.c' <<'END_OF_FILE'
  111. X#include <stdio.h>
  112. X
  113. Xextern char bar[];
  114. X
  115. Xvoid
  116. Xfoo (void)
  117. X{
  118. X  printf ("bar is at 0x%08lx\n", (long) bar);
  119. X  puts (bar);
  120. X}
  121. END_OF_FILE
  122. if test 120 -ne `wc -c <'foo.c'`; then
  123.     echo shar: \"'foo.c'\" unpacked with wrong size!
  124. fi
  125. # end of 'foo.c'
  126. fi
  127. if test -f 'foo.exp' -a "${1}" != "-c" ; then 
  128.   echo shar: Will not clobber existing file \"'foo.exp'\"
  129. else
  130. echo shar: Extracting \"'foo.exp'\" \(4 characters\)
  131. sed "s/^X//" >'foo.exp' <<'END_OF_FILE'
  132. Xfoo
  133. END_OF_FILE
  134. if test 4 -ne `wc -c <'foo.exp'`; then
  135.     echo shar: \"'foo.exp'\" unpacked with wrong size!
  136. fi
  137. # end of 'foo.exp'
  138. fi
  139. if test -f 'foo.imp' -a "${1}" != "-c" ; then 
  140.   echo shar: Will not clobber existing file \"'foo.imp'\"
  141. else
  142. echo shar: Extracting \"'foo.imp'\" \(7 characters\)
  143. sed "s/^X//" >'foo.imp' <<'END_OF_FILE'
  144. X#!
  145. Xbar
  146. END_OF_FILE
  147. if test 7 -ne `wc -c <'foo.imp'`; then
  148.     echo shar: \"'foo.imp'\" unpacked with wrong size!
  149. fi
  150. # end of 'foo.imp'
  151. fi
  152. echo shar: End of shell archive.
  153. exit 0
  154.  
  155. -- 
  156.  \   Charles Hannum, mycroft@ai.mit.edu
  157.  /\  White heterosexual atheist male (WHAM) pride!
  158.