home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / unix / aix / 8277 < prev    next >
Encoding:
Text File  |  1992-07-28  |  7.3 KB  |  178 lines

  1. Path: sparky!uunet!haven.umd.edu!darwin.sura.net!mips!sdd.hp.com!usc!sol.ctr.columbia.edu!The-Star.honeywell.com!umn.edu!noc.msc.net!uc.msc.edu!shamash!runyon.cim.cdc.com!pbd
  2. From: pbd@runyon.cim.cdc.com (Paul Dokas x4629)
  3. Newsgroups: comp.unix.aix
  4. Subject: more dynamic loading problems...
  5. Message-ID: <45808@shamash.cdc.com>
  6. Date: 28 Jul 92 21:33:58 GMT
  7. Sender: usenet@shamash.cdc.com
  8. Reply-To: pbd@runyon.cim.cdc.com (Paul Dokas x4629)
  9. Organization: ICEM Systems, Inc
  10. Lines: 166
  11.  
  12. I thought that I had solved my problems with dynamic loading, but things
  13. still aren't working properly.  It seems that when I create a dynamically
  14. loadable module, that the value returned by nlist() is not always the
  15. correct offset to the begining of the routine.  The included code for
  16. example creates a dynamically loadable module with 2 functions 'a_function()'
  17. and 'b_function()'.  Using nm, I find that the symbol 'a_function' has
  18. a value of 0x54.  But if I use dbx to look at the location pointed to by
  19. fn_ptr, I find that the value of 'a_function' should really be 0x18!
  20.  
  21. Here's a what I see on my screen when I just run the program:
  22.  
  23. % test ./mod.ld a_function
  24. Looking for a_function in ./mod.ld
  25. Loaded ./mod.ld at 0x2005263c
  26. Name:    a_function
  27. Value:   0x54
  28. SCNUM:   4
  29. Type:    0
  30. SClass:  2 ()
  31. NumAux:  1
  32. Calling 0x20052690
  33. Illegal instruction (core dumped)
  34.  
  35. Here's a dbx run:
  36.  
  37. % dbx test
  38. dbx version 3.1 for AIX.
  39. Type 'help' for help.
  40. reading symbolic information ...
  41. (dbx) stop in call_func
  42. [1] stop in call_func
  43. (dbx) r ./mod.ld a_function
  44. Looking for a_function in ./mod.ld
  45. Loaded ./mod.ld at 0x2005263c
  46. Name:    a_function
  47. Value:   0x54
  48. SCNUM:   4
  49. Type:    0
  50. SClass:  2 ()
  51. NumAux:  1
  52. [1] stopped in call_func at line 65
  53.    65     printf("Calling 0x%lx\n", (long) f);
  54. (dbx) up
  55. main(argc = 3, argv = 0x2ff7f3d0), line 57 in "test.c"
  56. (dbx) p fn_ptr
  57. 0x2005263c
  58. (dbx) 0x2005263c/10X
  59. 2005263c:  d1772400 20052660 00000000 d177247c
  60. 2005264c:  20052660 00000000 d17724d4 20052660
  61. 2005265c:  00000000 20052600
  62. (dbx) 0xd17724d4/10i
  63. 0xd17724d4 (a_function)      7c0802a6       mflr   r0
  64. 0xd17724d8 (a_function+0x4)  93e1fffc         st   r31,-4(r1)
  65. 0xd17724dc (a_function+0x8)  90010008         st   r0,0x8(r1)
  66. 0xd17724e0 (a_function+0xc)  9421ffb0        stu   r1,-80(r1)
  67. 0xd17724e4 (a_function+0x10) 83e2000c          l   r31,0xc(r2)
  68. 0xd17724e8 (a_function+0x14) 90610068         st   r3,0x68(r1)
  69. 0xd17724ec (a_function+0x18) 63e30000       oril   r3,r31,0x0
  70. 0xd17724f0 (a_function+0x1c) 4bffff69         bl   0xd1772458 (_my_start+0x58)
  71. 0xd17724f4 (a_function+0x20) 80410014          l   r2,0x14(r1)
  72. 0xd17724f8 (a_function+0x24) 4bffff85         bl   0xd177247c (b_function)
  73. (dbx) quit
  74. % nm ./mod.ld
  75.          U printf
  76. 00000200 T ._my_start
  77. 00000200 t ._my_start
  78. 000002d4 T .a_function
  79. 000002d4 t .a_function
  80. 0000027c T .b_function
  81. 0000027c t .b_function
  82. 00000258 T .printf
  83. 00000258 t .printf
  84. 00000060 d TOC
  85. 00000000 d __start$$
  86. 00000060 d __start$$
  87. 00000028 d _mod$$
  88. 0000006c d _mod$$
  89. 00000010 d _mod1$$
  90. 00000068 d _mod1$$
  91. 0000003c D _my_start
  92. 00000054 D a_function
  93. 00000048 D b_function
  94. 00000064 d printf
  95.  
  96.  
  97. As you can see, the symbol table says that a_function() is located 0x54 bytes
  98. from the begining of the file.  But when I use dbx, I find that the actual
  99. offset is 0x18...
  100.  
  101. Is this a loader (ld) problem?  Or am I doing something wrong (very possible)?
  102. Any pointers would be a great help.  I'm really stumped.
  103.  
  104. ----------   Cut here  -----------
  105. table
  106.  !"#$%&'()*+,-./0123456789:;<=>?
  107. @ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_
  108. begin 644 dynlink.tar.Z
  109. M'YV09/*X89/&S9H7 !(J7,BPH<.'$"-*G$@1 (R+-VK4  $@!HT8-V;$X'CQg
  110. M8@P9)$NJ+ D"1@T9,VK,F/'1QD@8)VG8F $ 1(V*0(,*'4H40)TY=,+(L0@#h
  111. MCA@R12&ZJ5-G#)RH#5?"2*F2(]:O8,.*'5LTX,""!^F40>IB#-FW;TO:H$&#i
  112. MHT>0(KGB1,ETI0P;-U"ZA"ESQM\:-EK&F&%#!HV>,.!*GNSP:-*E%YU")3NUj
  113. MZE6Q6O5>]$JYM.G39$<4',.F#IDR('@@)9/FC0LT/A2H=L/:-6S9=,@0%',[k
  114. M]^[>KV.?98M;@0([;]*0 3$F#!LV7\S4X8T"NG00*%2D0)$BQ0[GWJ>W"5,0l
  115. M14$Z()2>&<.".AJE(%3(M[.E2PH%>R@  @A(R5$5?,O1D<! 6\C0Q7D#CG&?m
  116. M' DD $<8=*#1(&(/"FB?4A5JQ]N&-G0X8'H5JF"&&U_ 08<<$(+ QAMNG!$Bn
  117. MBV^88<8<9=!QGG,#OJ""?66,L08((X"0(P@7RA%&&SV6(<<<^;W@81IF@"??o
  118. M&""$T ,(,Z0 0H ##F@&''*\9P8*LTDI1WTB5#%'&&>4H<. )5"98QILP%:&p
  119. M&R_FP84;(M2WWQ8P^!?C@&7@D08=*,1@GH=]  F"D"#4"5^&L)G!)VQN/ F;q
  120. M"E8.6*!5>:!P88:&RG$&?S$H:BFFFL;GQG2>X@$"IR"(. 8=M;D!0JA05NGAr
  121. MJ7"DZFNKKS8HJY#'OE@=I,N"(,(7(D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. M7T"',<P!#2!H@1F<DZ1C)]N!L D#'.  @A.H!2DG4$"1T#"T$QA<;FI\.'1=y
  154. MX(*(CX%++1B:QG>U%NB.0>(2JC@9:%2&$$1<-\=$MMSB X)]Q95+B>1@PQ/Iz
  155. M KE%?.(5OSAM:@0"GLN-XQU7P,<#SJ7^*K@M2@<YSC4(]:6W8.IDB '4;]Q'a
  156. M@8. "DV @@O><-?IM"!=(?]ZV,=>= UJ?6@\)_O,6R &-.B@+BV@0@TTV0(Db
  157. M[!TE= _>%*10A("+P5-](@A2#$^W[,%!0D>B^WS$$+W[O3K@L#FPT^&3=J-/c
  158. MQP7-33!TAP9ZL(M]:+0%.1LT#-> 9\GT;%?!V%%.\8:OW TMCSA.)"U8PAK6d
  159. MLIEF+&?9 %G)XH&RE@VU<$;=6064NK:C+>UI4[O:UKXVML>-]:QMBUO=\E;7e
  160. M)'6GKWT<;.TGE]@",>1!$JEUM\0[+M:&)+0GJ1=J5_LNV2X,3&AP \70!#"Ef
  161. M]'ZG5&ZKA&YCX4[QU17M)H ,>%^_I$NS41O$]("_(4QI0!S-\1S&!$[S(DX g
  162. M5DT;,V"H4V <J$S3Q&"!E%PZD&+U%&)MP&(4%F0R1F,V)F54QFOOY&,@!F0Ph
  163. MAF1$%D]&UH(^Z 8*-5%-MH-/%A!1MDX"=8-6QAY8!EM:9E(H]64LY5(P)5/)i
  164. M4V:O=F8ZU65JI@-S%E1#]6HLJ%9_UB=,16=G=6=550=7M6=<E3Q^EE1](E:"j
  165. M5F=HU8*&YE:))E=X:%=XI5>1]E>3YGN6EEB9M6G-9WS(!VJ9Q7S$YWR@=6K2k
  166. MIVK5UVK8-UNU56^W]GV_)7Z_5ESS)&R]AA -F(JJN(JLV(JN^(JP&(NR.(NTl
  167. .6(NV>(NXF(NZN(N\V(J_m
  168.  n
  169. end
  170. ----------   Cut here  -----------
  171.  
  172. -- 
  173. #include <std.disclaimer>
  174. #define FULL_NAME               "Paul Dokas"
  175. #define EMAIL_PRIMARY           "pbd@runyon.cim.cdc.com"
  176. #define EMAIL_SECONDARY         "pbd@power1.cim.cdc.com"
  177. /*** Overpopulation is the leading cause of most environmental problems ***/
  178.