|
From: Nicholas N. <nj...@ca...> - 2003-09-25 08:26:24
|
On Wed, 24 Sep 2003, Steve G wrote:
> Remember a month or two ago someone asked about linking valgrind
> to their application? I bet that valgind would work for static
> applications if they link with valgrind. May have to create .a
> files instead of .so for valgrind's libs. But this would help
> people who only have static libraries.
I just tried this, but failed -- not because it can't be done, but because
I didn't know how. I have very little experience with building .a files,
can someone explain how to create .a files for valgrind.so and skin .so
files? I've included what I tried below, if that's any use.
I'm particularly interested in this because I'm wondering if it would be
possibly to run a program-linked-statically-with-Valgrind under another
copy of Valgrind, and thus valgrind Valgrind. Maybe the 2nd Valgrind
would need to have different names for all its symbols to avoid clashes,
but that would be easy to achieve because of the VG_, SK_ and other
prefixes used. There are probably other problems with my idea too, but it
would be great if it could be done...
N
----
In memcheck/Makefile I put this target:
vgskin_memcheck.a: $(vgskin_memcheck_so_OBJECTS) $(vgskin_memcheck_so_DEPENDENCIES)
@rm -f vgskin_memcheck.so$(EXEEXT)
ar crs vgskin_memcheck.a $(vgskin_memcheck_so_OBJECTS)
ranlib vgskin_memcheck.a
And in coregrind/Makefile this target:
valgrind.a: $(valgrind_so_OBJECTS) $(valgrind_so_DEPENDENCIES)
@rm -f valgrind.so
ar crs valgrind.a $(valgrind_so_OBJECTS)
ranlib valgrind.a
Then I ran "make vgskin_memcheck.a" in memcheck/, and "make valgrind.a" in
coregrind/, making the two .a files.
I then linked them with the object file of a test program, null.o:
ld -Lmemcheck -lmemcheck -Lcoregrind -lvalgrind null.o
ld warned:
ld: warning: cannot find entry symbol _start; defaulting to 08048074
When I tried running the resulting program, I got an instant seg fault.
GDB's diagnosis:
[~/grind/head6] gdb a.out core
GNU gdb Red Hat Linux (5.3post-0.20021129.18rh)
Copyright 2003 Free Software Foundation, Inc.
[snip copyright msg]
This GDB was configured as "i386-redhat-linux-gnu"...
Core was generated by `a.out'.
Program terminated with signal 11, Segmentation fault.
#0 0x00000001 in ?? ()
(gdb)
|