[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: error with rpm 4.0.3 libs
- From: Ian Peters <itp ximian com>
- To: rpm-list redhat com
- Subject: Re: error with rpm 4.0.3 libs
- Date: 15 Dec 2001 13:32:47 -0500
Jeff is right, you are insane. FWIW, however, we're insane too and
we've had to do the same thing. What you have to do is create another
shared object that links against all of the RPM libraries you need to
dlopen at the same time. Since we're trying to produce a binary that
will work with multiple versions of the rpm shared libraries, we
actually need to create multiple objects, and then attempt to dlopen
each of them until one works (since the different shared libraries
change from release to release).
The trick here is that by setting the soname correctly on some temp
files, we can build these objects on systems that don't even have the
shared libraries we're linking against installed.
Here's the little script I wrote to do this (save as make-stub.sh):
---
#!/bin/sh
rm -f libstub-*.so
myid=0
stub=$1
shift
line="ld -L. -shared -o $stub"
while [ $# -gt 0 ]
do
myid=`expr $myid + 1`
lib=stub-$myid
ld -soname $1 -shared -o lib$lib.so -lc
remove="$remove lib$lib.so"
line="$line -l$lib"
shift
done
$line
rm $remove
---
Now, let's take your example, of needing librpm.so and librpmdb.so
symbols resolved concurrently:
make-stub.sh my_stub.so librpm.so librpmdb.so
(Note that librpm.so and librpmdb.so don't need to be real files, these
are just names.)
This produces a file called my_stub.so, which is a shared object with no
code segment with the following neat property:
[itp@flux src]$ ldd my_stub.so
/lib/libNoVersion.so.1 => /lib/libNoVersion.so.1 (0x40003000)
librpm.so => /usr/lib/librpm.so (0x40014000)
librpmdb.so => /usr/lib/librpmdb.so (0x40056000)
libc.so.6 => /lib/i686/libc.so.6 (0x400f5000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x80000000)
Now, in your application, just dlopen the my_stub.so file, and it'll
pull in librpm.so and librpmdb.so if they're installed in a standard
path (such as /usr/lib).
Hope this is of some help, feel free to contact me if you need more
info.
On Fri, 2001-12-14 at 19:57, Jeff Johnson wrote:
> On Thu, Dec 13, 2001 at 07:06:18PM -0200, root wrote:
> > Hi,
> >
> > I'm trying to use the APIs from the rpmlib, with dlopen call.
> > my problem is that in the 4.0.3 release there is a cross reference
> > between librpm.so and
> > librpmdb.so (librpm.so uses an symbol called chroot_prefix that is
> > defined in librpmdb.so and librpmdb.so
> > uses the symbol _noDirTokens defined in librpm.so). Because of that
> > dlopen cant load these libs, even when using the RTLD_LAZY option.
>
> Nasty loops are known, actually fixed in rpm-4.1, but that code
> ain't even close to being cooked yet.
>
> Meanwhile you're *insane* to attempt anything sophisticated with
> rpm shared libraries. Don't even think about it, roll your own
> modules if you must. Better yet, figger a way to statically
> link.
>
> HTH
>
> 73 de Jeff
>
> --
> Jeff Johnson ARS N3NPQ
> jbj@jbj.org (jbj@redhat.com)
> Chapel Hill, NC
>
>
>
> _______________________________________________
> Rpm-list mailing list
> Rpm-list@redhat.com
> https://listman.redhat.com/mailman/listinfo/rpm-list
--
Ian Peters
itp@ximian.com
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
[]