Christopher Dumoulin
2008-May-05 20:54 UTC
[dtrace-discuss] Link errors with DTrace USDT in C++
Hi All, I''m getting link errors with code containing custom DTrace probes that I''ve added according to the instructions in Mr. Leventhal''s blog (http://blogs.sun.com/ahl/entry/user_land_tracing_gets_better). I''m able to get this working on an x86 system, so I know that the code and dtrace commands I''m invoking are correct. I''m using gcc to build my application. I run into problems trying to build the same thing on a Sparc system. Here are some pertinent details for both systems: Solaris x86 system (working): uname -a : SunOS fxbuild-x86 5.10 Generic_127112-11 i86pc i386 i86pc Solaris gcc --version : gcc (GCC) 4.2.1 ld -v : GNU ld (GNU Binutils) 2.18 isainfo -b : 64 Solaris Sparc system (link errors): uname -a : SunOS fxbuild-dev 5.10 Generic_127111-11 sun4u sparc SUNW,Sun-Fire-V240 Solaris gcc --version : gcc (GCC) 4.2.1 ld -v : GNU ld (GNU Binutils) 2.18 isainfo -b : 64 For both systems, I generate the header file containing the probe macros like this: dtrace -h -s cxs_dtrace.d For both systems, I generate the object code for the probes like this: dtrace -G -s cxs_dtrace.d $(OBJS) When it comes time to link everything together, I get the following error on the Sparc system: /home/dumoulin/cxs_dtrace/fxtrade/CXServer/bin/CXPSyncnoBumpHandler.o: could not read symbols: Bad value The file CXPSyncnoBumpHandler.cpp, from which CXPSyncnoBumpHandler.o is generated, contains calls to the custom probe functions. Any suggestions as to what the problem might be would be appreciated. Regards, Chris Dumoulin
Could this error be related to using GNU ld? This thread: http://mail.opensolaris.org/pipermail/dtrace-discuss/2006-March/001199.html indicates that DTrace USDT might not work with GNU ld, but that posting was over two years ago. Should this work with GNU ld? Why would it work on x86 and not on a Sparc system? Perhaps it''s related to the difference in object code that dtrace emits for these two platforms. Anybody have any comments? -- This message posted from opensolaris.org
On May 7, 2008, at 6:19 AM, Chris Dumoulin wrote:> Could this error be related to using GNU ld? This thread: > http://mail.opensolaris.org/pipermail/dtrace-discuss/2006-March/001199.html > indicates that DTrace USDT might not work with GNU ld, but that > posting was over two years ago. > > Should this work with GNU ld? Why would it work on x86 and not on a > Sparc system? Perhaps it''s related to the difference in object code > that dtrace emits for these two platforms. Anybody have any comments?Have you verified that the probes are actually firing when enabled on x86? It may be that you are just getting lucky that things link on x86, but they aren''t actually working. I would try with the Solaris toolchain and see if things work correctly. If they still do not, you''ve likely got a real bug. James M
On Wed, May 07, 2008 at 10:51:41AM -0700, James McIlree wrote:> > On May 7, 2008, at 6:19 AM, Chris Dumoulin wrote: > > Could this error be related to using GNU ld? This thread: > > http://mail.opensolaris.org/pipermail/dtrace-discuss/2006-March/001199.html > > indicates that DTrace USDT might not work with GNU ld, but that > > posting was over two years ago. > > > > Should this work with GNU ld? Why would it work on x86 and not on a > > Sparc system? Perhaps it''s related to the difference in object code > > that dtrace emits for these two platforms. Anybody have any comments? > > Have you verified that the probes are actually firing when enabled on > x86? > > It may be that you are just getting lucky that things link on x86, > but they aren''t actually working. > > I would try with the Solaris toolchain and see if things work > correctly. If they still do not, you''ve likely got a real bug.As James knows, we made some non-trivial linker changes to accommodate USDT. The GNU linker will not work properly (though if anyone has any pull with the GNU linker team, it''s certainly something I''d like to see added). Adam -- Adam Leventhal, Fishworks http://blogs.sun.com/ahl