URL: <https://savannah.gnu.org/support/?111392>
Summary: libtool -export-symbols does not work for NetBSD
shared libraries
Group: GNU Libtool
Submitter: riastradh
Submitted: Tue 10 Mar 2026 04:31:51 AM UTC
Category: None
Priority: 5 - Normal
Severity: 3 - Normal
Status: None
Privacy: Public
Assigned to: None
Originator Email:
Open/Closed: Open
Discussion Lock: Unlocked
Operating System: *BSD
_______________________________________________________
Follow-up Comments:
-------------------------------------------------------
Date: Tue 10 Mar 2026 04:31:51 AM UTC By: Taylor R. Campbell <riastradh>
See attached reproducer to create a library with two symbols, foo and bar, of
which only foo is supposed to be exported.
Expected output, as observed with libtool 2.4.7 under Debian 12:
$ ./syms.sh
dynamic symbols:
D foo
symbols:
D foo
Actual output, as observed with libtool 2.4.7 under NetBSD 9:
$ ./syms.sh
dynamic symbols:
D _end
T _fini
T _init
D bar
D foo
symbols:
D foo
The reason is that libtool translates -export-symbols into
-Wl,-retain-symbols-file, a GNU ld(1) option that affects the .symtab section
but not the .dynsym section. So it doesn't change what symbols are exported
to clients of the shared library.
Instead, on NetBSD, for shared libraries, libtool should use the same version
script mechanism that it does on GNU/Linux platforms: a single anonymous
version with { global: foo; local: * }, fed into ld(1) with
-Wl,-version-script. (And -Wl,-retain-symbols-file probably isn't useful for
shared libraries either; it is less effective at saving space than stripping
symbols altogether, and less useful for diagnostics than not stripping them.)
Caveat: Since this changes the ABI of the resulting libraries by _deleting_
symbols, in principle it requires a shared library major bump for any
libraries built with -export-symbols.
_______________________________________________________
File Attachments:
Name: syms.sh Size: 593B
<https://file.savannah.gnu.org/file/syms.sh?file_id=58325>
AGPL NOTICE
These attachments are served by Savane. You can download the corresponding
source code of Savane at
https://savannah.gnu.org/source/savane-5479f0ac3e1f014845fd281c379bc3ccb7a72723.tar.gz
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/support/?111392>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
signature.asc
Description: PGP signature
