dpkg-gensymbols scans a temporary build tree (debian/tmp by default)
looking for libraries and generates a symbols file describing them.
This file, if non-empty, is then installed in the DEBIAN subdirectory
of the build tree so that it ends up included in the control informa-
tion of the package.
When generating those files, it uses as input some symbols files pro-
vided by the maintainer. It looks for the following files (and uses the
first that is found):
The main interest of those files is to provide the minimal version
associated to each symbol provided by the libraries. Usually it corre-
sponds to the first version of that package that provided the symbol,
but it can be manually incremented by the maintainer if the ABI of the
symbol is extended without breaking backwards compatibility. It's the
responsibility of the maintainer to keep those files up-to-date and
accurate, but dpkg-gensymbols helps with that.
When the generated symbols files differ from the maintainer supplied
one, dpkg-gensymbols will print a diff between the two versions. Fur-
thermore if the difference is too significant, it will even fail (you
can customize how much difference you can tolerate, see the -c option).
MAINTAINING SYMBOLS FILES
The symbols files are really useful only if they reflect the evolution
of the package through several releases. Thus the maintainer has to
update them every time that a new symbol is added so that its associ-
ated minimal version matches reality. To do this properly the diffs
contained in the build logs can be used. In most cases, the diff
applies directly to the debian/package.symbols file. That said, further
tweaks are usually needed: it's recommended for example to drop the
Debian revision from the minimal version so that backports with a lower
version number but the same upstream version still satisfy the gener-
ated dependencies. If the Debian revision can't be dropped because the
symbol really got added by the Debian specific change, then one should
suffix the version with "~".
Before applying any patch to the symbols file, the maintainer should
double-check that it's sane. Public symbols are not supposed to disap-
pear, so the patch should ideally only add new lines.
Using symbol tags
Symbol tagging is useful for marking symbols that are special in some
way. Any symbol can have an arbitrary number of tags associated with
it. While all tags are parsed and stored, only a some of them are
understood by dpkg-gensymbols and trigger special handling of the sym-
bols. See subsection Standard symbol tags for reference of these tags.
Tag specification comes right before the symbol name (no whitespace is
allowed in between). It always starts with an opening bracket (, ends
with a closing bracket ) and must contain at least one tag. Multiple
tags are separated by the | character. Each tag can optionally have a
value which is separated form the tag name by the = character. Tag
names and values can be arbitrary strings except they cannot contain
any of the special ) | = characters. Symbol names following a tag spec-
ification can optionally be quoted with either ' or " characters to
allow whitespaces in them. However, if there are no tags specified for
the symbol, quotes are treated as part of the symbol name which contin-
ues up until the first space.
(tag1=i am marked|tag name with space)"tagged quoted symbol"@Base 1.0
(optional)tagged_unquoted_symbol@Base 1.0 1
The first symbol in the example is named tagged quoted symbol and has
two tags: tag1 with value i am marked and tag name with space that has
no value. The second symbol named tagged_unquoted_symbol is only tagged
with the tag named optional. The last symbol is an example of the nor-
mal untagged symbol.
Since symbol tags are an extension of the deb-symbols(5) format, they
can only be part of the symbols files used in source packages (those
files should then be seen as templates used to build the symbols files
that are embedded in binary packages). When dpkg-gensymbols is called
without the -t option, it will output symbols files compatible to the
deb-symbols(5) format: it fully processes symbols according to the
requirements of their standard tags and strips all tags from the out-
put. On the contrary, in template mode (-t) all symbols and their tags
(both standard and unknown ones) are kept in the output and are written
in their original form as they were loaded.
Standard symbol tags
A symbol marked as optional can disappear from the library at
any time and that will never cause dpkg-gensymbols to fail. How-
ever, disappeared optional symbols will continuously appear as
MISSING in the diff in each new package revision. This behav-
iour serves as a reminder for the maintainer that such a symbol
needs to be removed from the symbol file or readded to the
library. When the optional symbol, which was previously declared
as MISSING, suddenly reappears in the next revision, it will be
upgraded back to the "existing" status with its minimum version
ture are treated as if they did not exist. If an arch-specific
symbol matching the current host architecture does not exist in
the library, normal procedures for missing symbols apply and it
may cause dpkg-gensymbols to fail. On the other hand, if the
arch-specific symbol is found when it was not supposed to exist
(because the current host architecture is not listed in the
tag), it is made arch neutral (i.e. the arch tag is dropped and
the symbol will appear in the diff due to this change), but it
is not considered as new.
When operating in the default non-template mode, among arch-spe-
cific symbols only those that match the current host architec-
ture are written to the symbols file. On the contrary, all arch-
specific symbols (including those from foreign arches) are
always written to the symbol file when operating in template
The format of architecture list is the same as the one used in
the Build-Depends field of debian/control (except the enclosing
square brackets ). For example, the first symbol from the list
below will be considered only on alpha, any-amd64 and ia64
architectures, the second only on linux architectures, while the
third one anywhere except on armel.
(arch=alpha any-amd64 ia64)a_64bit_specific_symbol@Base 1.0
dpkg-gensymbols has an internal blacklist of symbols that should
not appear in symbols files as they are usually only side-
effects of implementation details of the toolchain. If for some
reason, you really want one of those symbols to be included in
the symbols file, you should tag the symbol with ignore-black-
list. It can be necessary for some low level toolchain libraries
c++ Denotes c++ symbol pattern. See Using symbol patterns subsection
symver Denotes symver (symbol version) symbol pattern. See Using symbol
patterns subsection below.
regex Denotes regex symbol pattern. See Using symbol patterns subsec-
Using symbol patterns
Unlike a standard symbol specification, a pattern may cover multiple
real symbols from the library. dpkg-gensymbols will attempt to match
each pattern against each real symbol that does not have a specific
symbol counterpart defined in the symbol file. Whenever the first
matching pattern is found, all its tags and properties will be used as
a basis specification of the symbol. If none of the patterns matches,
the symbol will be considered as new.
not any different from the one of a specific symbol. However, symbol
name part of the specification serves as an expression to be matched
against name@version of the real symbol. In order to distinguish among
different pattern types, a pattern will typically be tagged with a spe-
At the moment, dpkg-gensymbols supports three basic pattern types:
This pattern is denoted by the c++ tag. It matches only C++ symbols
by their demangled symbol name (as emitted by c++filt(1) utility).
This pattern is very handy for matching symbols which mangled names
might vary across different architectures while their demangled
names remain the same. One group of such symbols is non-virtual
thunks which have architecture specific offsets embedded in their
mangled names. A common instance of this case is a virtual destruc-
tor which under diamond inheritance needs a non-virtual thunk sym-
bol. For example, even if _ZThn8_N3NSB6ClassDD1Ev@Base on 32bit
architectures will probably be _ZThn16_N3NSB6ClassDD1Ev@Base on
64bit ones, it can be matched with a single c++ pattern:
libdummy.so.1 libdummy1 #MINVER#
(c++)"non-virtual thunk to NSB::ClassD::~ClassD()@Base" 1.0
The demangled name above can be obtained by executing the following
$ echo '_ZThn8_N3NSB6ClassDD1Ev@Base' | c++filt
Please note that while mangled name is unique in the library by def-
inition, this is not necessarily true for demangled names. A couple
of distinct real symbols may have the same demangled name. For exam-
ple, that's the case with non-virtual thunk symbols in complex
inheritance configurations or with most constructors and destructors
(since g++ typically generates two real symbols for them). However,
as these collisions happen on the ABI level, they should not degrade
quality of the symbol file.
This pattern is denoted by the symver tag. Well maintained libraries
have versioned symbols where each version corresponds to the
upstream version where the symbol got added. If that's the case, you
can use a symver pattern to match any symbol associated to the spe-
cific version. For example:
libc.so.6 libc6 #MINVER#
All symbols associated with versions GLIBC_2.0 and GLIBC_2.7 will
Regular expression patterns are denoted by the regex tag. They match
by the perl regular expression specified in the symbol name field. A
regular expression is matched as it is, therefore do not forget to
start it with the ^ character or it may match any part of the real
symbol name@version string. For example:
libdummy.so.1 libdummy1 #MINVER#
Symbols like "mystack_new@Base", "mystack_push@Base", "mys-
tack_pop@Base" etc. will be matched by the first pattern while e.g.
"ng_mystack_new@Base" won't. The second pattern will match all sym-
bols having the string "private" in their names and matches will
inherit optional tag from the pattern.
Basic patterns listed above can be combined where it makes sense. In
that case, they are processed in the order in which the tags are speci-
fied. For example, both
will match symbols "_ZN3NSA6ClassA7Private11privmethod1Ei@Base" and
"_ZN3NSA6ClassA7Private11privmethod2Ei@Base". When matching the first
pattern, the raw symbol is first demangled as C++ symbol, then the
demangled name is matched against the regular expression. On the other
hand, when matching the second pattern, regular expression is matched
against the raw symbol name, then the symbol is tested if it is C++ one
by attempting to demangle it. A failure of any basic pattern will
result in the failure of the whole pattern. Therefore, for example,
"__N3NSA6ClassA7Private11privmethod\dEi@Base" will not match either of
the patterns because it is not a valid C++ symbol.
In general, all patterns are divided into two groups: aliases (basic
c++ and symver) and generic patterns (regex, all combinations of multi-
ple basic patterns). Matching of basic alias-based patterns is fast
(O(1)) while generic patterns are O(N) (N - generic pattern count) for
each symbol. Therefore, it is recommended not to overuse generic pat-
When multiple patterns match the same real symbol, aliases (first c++,
then symver) are preferred over generic patterns. Generic patterns are
matched in the order they are found in the symbol file template until
the first success. Please note, however, that manual reordering of
template file entries is not recommended because dpkg-gensymbols gener-
ates diffs based on the alphanumerical order of their names.
When the set of exported symbols differ between architectures, it may
become inefficient to use a single symbol file. In those cases, an
include directive may prove to be useful in a couple of ways:
feature to create a common package.symbols file which includes
architecture specific symbol files:
(arch=amd64 ia64 alpha)#include "package.symbols.64bit"
(arch=!amd64 !ia64 !alpha)#include "package.symbols.32bit"
The symbols files are read line by line, and include directives are
processed as soon as they are encountered. This means that the content
of the included file can override any content that appeared before the
include directive and that any content after the directive can override
anything contained in the included file. Any symbol (or even another
#include directive) in the included file can specify additional tags or
override values of the inherited tags in its tag specification. How-
ever, there is no way for the symbol to remove any of the inherited
An included file can repeat the header line containing the SONAME of
the library. In that case, it overrides any header line previously
read. However, in general it's best to avoid duplicating header lines.
One way to do it is the following:
Good library management
A well-maintained library has the following features:
o its API is stable (public symbols are never dropped, only new pub-
lic symbols are added) and changes in incompatible ways only when
the SONAME changes;
o ideally, it uses symbol versioning to achieve ABI stability despite
internal changes and API extension;
o it doesn't export private symbols (such symbols can be tagged
optional as workaround).
While maintaining the symbols file, it's easy to notice appearance and
disappearance of symbols. But it's more difficult to catch incompatible
API and ABI change. Thus the maintainer should read thoroughly the
upstream changelog looking for cases where the rules of good library
management have been broken. If potential problems are discovered, the
upstream author should be notified as an upstream fix is always better
than a Debian specific work-around.
Scan package-build-dir instead of debian/tmp.
Define the package name. Required if more than one binary pack-
age is listed in debian/control (or if there's no debian/control
ment (otherwise you need multiple -e).
Use filename as reference file to generate the symbols file that
is integrated in the package itself.
Print the generated symbols file to standard output or to file-
name if specified, rather than to debian/tmp/DEBIAN/symbols (or
package-build-dir/DEBIAN/symbols if -P was used). If filename is
pre-existing, its contents are used as basis for the generated
symbols file. You can use this feature to update a symbols file
so that it matches a newer upstream version of your library.
-t Write the symbol file in template mode rather than the format
compatible with deb-symbols(5). The main difference is that in
the template mode symbol names and tags are written in their
original form contrary to the post-processed symbol names with
tags stripped in the compatibility mode. Moreover, some symbols
might be omitted when writing a standard deb-symbols(5) file
(according to the tag processing rules) while all symbols are
always written to the symbol file template.
Define the checks to do when comparing the generated symbols
file with the template file used as starting point. By default
the level is 1. Increasing levels do more checks and include all
checks of lower levels. Level 0 never fails. Level 1 fails if
some symbols have disappeared. Level 2 fails if some new symbols
have been introduced. Level 3 fails if some libraries have dis-
appeared. Level 4 fails if some libraries have been introduced.
This value can be overridden by the environment variable
-q Keep quiet and never generate a diff between generated symbols
file and the template file used as starting point or show any
warnings about new/lost libraries or new/lost symbols. This
option only disables informational output but not the checks
themselves (see -c option).
-aarch Assume arch as host architecture when processing symbol files.
Use this option to generate a symbol file or diff for any archi-
tecture provided its binaries are already available.
-d Enable debug mode. Numerous messages are displayed to explain
what dpkg-gensymbols does.
-V Enable verbose mode. The generated symbols file contains depre-
cated symbols as comments. Furthermore in template mode, pattern
symbols are followed by comments listing real symbols that have
matched the pattern.
Debian Project 2013-09-06 dpkg-gensymbols(1)
Man Pages Copyright Respective Owners. Site Copyright (C) 1994 - 2019
All Rights Reserved.