libtool
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to get libb to export liba's symbols?


From: Neal H. Walfield
Subject: How to get libb to export liba's symbols?
Date: Tue, 10 May 2022 11:13:38 +0200
User-agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (Gojō) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO)

Hi libtool devs,

Historically, rpm has included its own OpenPGP implementation.  This
implementation is incomplete and buggy, and the maintainers of rpm
have decided that they would like to use a different OpenPGP
implementation.

There are two major constraints.  Because rpm's OpenPGP API is public,
it must be preserved until the next soname bump.  And, the OpenPGP
backend should be pluggable.

  https://github.com/rpm-software-management/rpm/issues/1935
  
https://github.com/rpm-software-management/rpm/issues/1978#issuecomment-1080606598

I've recently created an alternate OpenPGP backend for rpm based on
Sequoia PGP.  Sequoia is written in Rust.  I created a Rust shim
(rpm-sequoia), which implements rpm's OpenPGP API:

  https://gitlab.com/sequoia-pgp/rpm-sequoia

In other words, I've created a library called librpm_sequoia, which
provides symbols like pgpPubkeyKeyID, which were previously provided
by librpmio.so directly.  That is, using the internal OpenPGP
implementation, librpmio.so includes these symbols:

  $ objdump -T /usr/lib/x86_64-linux-gnu/librpmio.so.9.1.2  | grep pgp | head 
-n2
  0000000000018330 g    DF .text        0000000000000101  Base        
pgpValString
  0000000000019200 g    DF .text        000000000000005c  Base        
pgpPubkeyKeyID

When using my replacement backend, librpmio.so must continue to
provide these symbols.  In this way, some program foo that links
against librpmio (i.e., has a DT_NEEDED for librpmio) should be able
to use our Sequoia-based librpmio without relinking.  Similarly, a
program foo that is linked against the Sequoia variant of librpmio
should still be usable with a variant of librpmio that uses the
internal OpenPGP implementation.


Unfortunately, I can't figure out how to get librpmio to reexport
librpm_sequoia's symbols.  Currently, foo needs to be relinked
explicitly against librpm_sequoia.so.  For instance, here you can see
that rpmpgpcheck is now explicitly linked against librpmio.la *and*
librpm_sequoia.so:

  rpmpgpcheck_LDADD = ../rpmio/librpmio.la \
        @WITH_RPM_SEQUOIA_LIB@

  
https://github.com/rpm-software-management/rpm/blob/master/tests/Makefile.am#L15

Before it was enough to just link against librpmio.la.

Yes, librpmio is linked against librpm_sequoia:

  librpmio_la_LIBADD = \
        ... \
        @WITH_RPM_SEQUOIA_LIB@ \

  
https://github.com/rpm-software-management/rpm/blob/master/rpmio/Makefile.am#L39

And the resulting librpmio does have a DT_NEEDED on librpm_sequoia:

  $ objdump -p .libs/librpmio.so | grep sequoia
  NEEDED               librpm_sequoia.so

And the symbols are mentioned:

  $ objdump -T .libs/librpmio.so | grep pgp | head -n2
  0000000000000000      DF *UND*        0000000000000000  Base        
pgpSignatureType
  0000000000000000      DF *UND*        0000000000000000  Base        
pgpPubkeyKeyID

This appears to be sufficient to resolve librpmio's use of
librpm_sequoia's symbols.  But, when linking a program like
rpmpgpcheck against librpmio.la, the linker does not consider
librpm_sequoia.so's symbols unless it is explicitly linked against
against librpm_sequoia.so.  That is, changing rpmpgpcheck to only link
against librpmio:

  rpmpgpcheck_LDADD = ../rpmio/librpmio.la

results in the following errors:

  libtool: link: cc -shared  -fPIC -DPIC  .libs/argv.o .libs/more....o  
-Wl,--whole-archive ../misc/.libs/libmisc.a -Wl,--no-whole-archive  
-L/tmp/rpm-sequoia/release -lrpm_sequoia -lbz2 -lz -lpopt -llzma -llua5.4 -ldl 
-lpthread  -g -O2   -Wl,-soname -Wl,librpmio.so.9 -o .libs/librpmio.so.9.3.0
  ...
  libtool: link: cc -Wall -Wpointer-arith -Wmissing-prototypes 
-Wstrict-prototypes -fno-strict-aliasing -fno-strict-overflow 
-fno-delete-null-pointer-checks -Wempty-body -g -O2 -o .libs/rpmpgpcheck 
rpmpgpcheck.o  ../rpmio/.libs/librpmio.so -ldl -lpthread -Wl,-rpath 
-Wl,/home/us/neal/work/pep/rpm/b/../i/lib
  /usr/bin/ld: rpmpgpcheck.o: undefined reference to symbol 'pgpDigParamsFree'
  /usr/bin/ld: /tmp/rpm-sequoia/release/librpm_sequoia.so: error adding 
symbols: DSO missing from command line

My understanding is that this error message means: the symbol
pgpDigParamsFree is needed, it was not found in any of the mentioned
libraries, but it is present in librpm_sequoia.so, so link to that.


My conclusion is that I somehow need to get librpmio to reexport
librpm_sequoia's symbols.  Despite spending hours searching, I haven't
figured out how to do that.  I'd appreciate any hints that might lead
me to a solution.

Thanks,

:) Neal



reply via email to

[Prev in Thread] Current Thread [Next in Thread]