1 # dpkg manual page - deb-src-symbols(5)
3 # Copyright © 2007-2011 Raphaël Hertzog <hertzog@debian.org>
4 # Copyright © 2009-2010 Modestas Vainius <modestas@vainius.eu>
5 # Copyright © 2012-2015 Guillem Jover <guillem@debian.org>
7 # This is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <https://www.gnu.org/licenses/>.
24 deb-src-symbols - Debian's extended shared library template file
28 B<debian/>I<package>B<.symbols.>I<arch>,
29 B<debian/symbols.>I<arch>,
30 B<debian/>I<package>B<.symbols>,
35 The symbol file templates are shipped in Debian source packages, and its
36 format is a superset of the symbols files shipped in binary packages,
37 see L<deb-symbols(5)>.
41 Comments are supported in template symbol files.
43 the first character is a comment except if it starts with ‘#include’
44 (see section L</Using includes>).
45 Lines starting with ‘#MISSING:’ are special comments documenting
46 symbols that have disappeared.
48 =head2 Using #PACKAGE# substitution
50 In some rare cases, the name of the library varies between architectures.
51 To avoid hardcoding the name of the package in the symbols file, you can
52 use the marker I<#PACKAGE#>.
53 It will be replaced by the real package name during installation of the
56 I<#MINVER#> marker, I<#PACKAGE#> will never appear in a symbols file
57 inside a binary package.
59 =head2 Using symbol tags
61 Symbol tagging is useful for marking symbols that are special in some way.
62 Any symbol can have an arbitrary number of tags associated with it.
64 parsed and stored, only some of them are understood by
65 B<dpkg-gensymbols> and trigger special handling of the symbols.
67 subsection L</Standard symbol tags> for reference of these tags.
69 Tag specification comes right before the symbol name (no whitespace is allowed
71 It always starts with an opening bracket B<(>,
72 ends with a closing bracket B<)> and must contain at least one tag.
73 Multiple tags are separated by the B<|> character.
74 Each tag can optionally have a value which is separated form the tag name
75 by the B<=> character.
77 can be arbitrary strings except they cannot contain any of the special B<)>
79 Symbol names following a tag specification can
80 optionally be quoted with either B<'> or B<"> characters to allow
82 However, if there are no tags specified for the symbol,
83 quotes are treated as part of the symbol name which continues up until the
86 (tag1=i am marked|tag name with space)"tagged quoted symbol"@Base 1.0
87 (optional)tagged_unquoted_symbol@Base 1.0 1
88 untagged_symbol@Base 1.0
90 The first symbol in the example is named I<tagged quoted symbol> and has two
91 tags: I<tag1> with value I<i am marked> and I<tag name with space>
93 The second symbol named I<tagged_unquoted_symbol> is only tagged with the
94 tag named I<optional>.
96 example of the normal untagged symbol.
98 Since symbol tags are an extension of the L<deb-symbols(5)> format, they
99 can only be part of the symbols files used in source packages (those files
100 should then be seen as templates used to build the symbols files that are
101 embedded in binary packages).
103 B<dpkg-gensymbols> is called without the B<-t> option, it will
104 output symbols files compatible to the L<deb-symbols(5)> format:
105 it fully processes symbols according to the requirements of their standard tags
106 and strips all tags from the output.
107 On the contrary, in template mode
108 (B<-t>) all symbols and their tags (both standard and unknown ones)
109 are kept in the output and are written in their original form as they were
112 =head2 Standard symbol tags
118 A symbol marked as optional can disappear from the library at any time and that
119 will never cause B<dpkg-gensymbols> to fail.
120 However, disappeared optional
121 symbols will continuously appear as MISSING in the diff in each new package
123 This behavior serves as a reminder for the maintainer that such a
124 symbol needs to be removed from the symbol file or readded to the library.
126 the optional symbol, which was previously declared as MISSING, suddenly
127 reappears in the next revision, it will be upgraded back to the “existing”
128 status with its minimum version unchanged.
130 This tag is useful for symbols which are private where their disappearance do
131 not cause ABI breakage.
132 For example, most of C++ template instantiations fall into this category.
133 Like any other tag, this one may also have an arbitrary
134 value: it could be used to indicate why the symbol is considered optional.
136 =item B<arch=>I<architecture-list>
138 =item B<arch-bits=>I<architecture-bits>
140 =item B<arch-endian=>I<architecture-endianness>
142 These tags allow one to restrict the set of architectures where the symbol
143 is supposed to exist.
144 The B<arch-bits> and B<arch-endian> tags are supported since dpkg 1.18.0.
145 When the symbols list is updated with
147 discovered in the library, all arch-specific symbols which do not concern
148 the current host architecture are treated as if they did not exist.
150 arch-specific symbol matching the current host architecture does not exist
151 in the library, normal procedures for missing symbols apply and it may
152 cause B<dpkg-gensymbols> to fail.
153 On the other hand, if the
154 arch-specific symbol is found when it was not supposed to exist (because
155 the current host architecture is not listed in the tag or does not match
156 the endianness and bits), it is made arch neutral (i.e. the arch, arch-bits
157 and arch-endian tags are dropped and the symbol will appear in the diff due
158 to this change), but it is not considered as new.
160 When operating in the default non-template mode, among arch-specific symbols
161 only those that match the current host architecture are written to the
163 On the contrary, all arch-specific symbols (including those
164 from foreign arches) are always written to the symbol file when operating
167 The format of I<architecture-list> is the same as the one used in the
168 B<Build-Depends> field of I<debian/control> (except the enclosing
170 For example, the first symbol from the list below
171 will be considered only on alpha, any-amd64 and ia64 architectures,
172 the second only on linux architectures, while the third one anywhere
175 (arch=alpha any-amd64 ia64)64bit_specific_symbol@Base 1.0
176 (arch=linux-any)linux_specific_symbol@Base 1.0
177 (arch=!armel)symbol_armel_does_not_have@Base 1.0
179 The I<architecture-bits> is either B<32> or B<64>.
181 (arch-bits=32)32bit_specific_symbol@Base 1.0
182 (arch-bits=64)64bit_specific_symbol@Base 1.0
184 The I<architecture-endianness> is either B<little> or B<big>.
186 (arch-endian=little)little_endian_specific_symbol@Base 1.0
187 (arch-endian=big)big_endian_specific_symbol@Base 1.0
189 Multiple restrictions can be chained.
191 (arch-bits=32|arch-endian=little)32bit_le_symbol@Base 1.0
193 =item B<allow-internal>
195 dpkg-gensymbols has a list of internal symbols that should not
196 appear in symbols files as they are usually only side-effects of
197 implementation details of the toolchain (since dpkg 1.20.1).
198 If for some reason, you really want one of those symbols to be included in
199 the symbols file, you should tag the symbol with B<allow-internal>.
200 It can be necessary for some low level toolchain libraries like “libgcc”.
202 =item B<ignore-blacklist>
204 A deprecated alias for B<allow-internal> (since dpkg 1.20.1,
205 supported since dpkg 1.15.3).
209 Denotes I<c++> symbol pattern.
210 See L</Using symbol patterns> subsection
215 Denotes I<symver> (symbol version) symbol pattern.
217 patterns> subsection below.
221 Denotes I<regex> symbol pattern.
222 See L</Using symbol patterns> subsection
227 =head2 Using symbol patterns
229 Unlike a standard symbol specification, a pattern may cover multiple real
230 symbols from the library.
231 B<dpkg-gensymbols> will attempt to match each
232 pattern against each real symbol that does I<not> have a specific symbol
233 counterpart defined in the symbol file.
234 Whenever the first matching pattern is
235 found, all its tags and properties will be used as a basis specification of the
237 If none of the patterns matches, the symbol will be considered as new.
239 A pattern is considered lost if it does not match any symbol in the library.
241 default this will trigger a B<dpkg-gensymbols> failure under B<-c1> or
243 However, if the failure is undesired, the pattern may be marked with the
245 Then if the pattern does not match anything,
246 it will only appear in the diff as MISSING.
247 Moreover, like any symbol,
248 the pattern may be limited to the specific architectures with the I<arch> tag.
250 refer to L</Standard symbol tags> subsection above for more information.
252 Patterns are an extension of the L<deb-symbols(5)> format hence they are
253 only valid in symbol file templates.
254 Pattern specification syntax is not any different from the one of a
256 However, symbol name part of the
257 specification serves as an expression to be matched against I<name@version>
259 In order to distinguish among different pattern types, a
260 pattern will typically be tagged with a special tag.
262 At the moment, B<dpkg-gensymbols> supports three basic pattern types:
268 This pattern is denoted by the I<c++> tag.
269 It matches only C++ symbols by their demangled symbol name
270 (as emitted by L<c++filt(1)> utility).
272 pattern is very handy for matching symbols which mangled names might vary
273 across different architectures while their demangled names remain the same.
275 group of such symbols is I<non-virtual thunks> which have architecture
276 specific offsets embedded in their mangled names.
277 A common instance of this
278 case is a virtual destructor which under diamond inheritance needs a
279 non-virtual thunk symbol.
280 For example, even if _ZThn8_N3NSB6ClassDD1Ev@Base on
281 32-bit architectures will probably be _ZThn16_N3NSB6ClassDD1Ev@Base on 64-bit
282 ones, it can be matched with a single I<c++> pattern:
284 libdummy.so.1 libdummy1 #MINVER#
286 (c++)"non-virtual thunk to NSB::ClassD::~ClassD()@Base" 1.0
289 The demangled name above can be obtained by executing the following command:
291 $ echo '_ZThn8_N3NSB6ClassDD1Ev@Base' | c++filt
293 Please note that while mangled name is unique in the library by definition,
294 this is not necessarily true for demangled names.
295 A couple of distinct real symbols may have the same demangled name.
296 For example, that's the case with
297 non-virtual thunk symbols in complex inheritance configurations or with most
298 constructors and destructors (since g++ typically generates two real symbols
300 However, as these collisions happen on the ABI level, they should
301 not degrade quality of the symbol file.
305 This pattern is denoted by the I<symver> tag.
306 Well maintained libraries have
307 versioned symbols where each version corresponds to the upstream version where
308 the symbol got added.
309 If that's the case, you can use a I<symver> pattern to
310 match any symbol associated to the specific version.
313 libc.so.6 libc6 #MINVER#
314 (symver)GLIBC_2.0 2.0
316 (symver)GLIBC_2.7 2.7
319 All symbols associated with versions GLIBC_2.0 and GLIBC_2.7 will lead to
320 minimal version of 2.0 and 2.7 respectively with the exception of the symbol
322 The latter will lead to a minimal dependency on libc6 version
323 2.2 despite being in the scope of the "(symver)GLIBC_2.0" pattern because
324 specific symbols take precedence over patterns.
326 Please note that while old style wildcard patterns (denoted by "*@version" in
327 the symbol name field) are still supported, they have been deprecated by new
328 style syntax "(symver|optional)version".
329 For example, "*@GLIBC_2.0 2.0" should
330 be written as "(symver|optional)GLIBC_2.0 2.0" if the same behavior is needed.
334 Regular expression patterns are denoted by the I<regex> tag.
335 They match by the perl regular expression specified in the symbol name field.
337 expression is matched as it is, therefore do not forget to start it with the
338 I<^> character or it may match any part of the real symbol
339 I<name@version> string.
342 libdummy.so.1 libdummy1 #MINVER#
343 (regex)"^mystack_.*@Base$" 1.0
344 (regex|optional)"private" 1.0
346 Symbols like "mystack_new@Base", "mystack_push@Base", "mystack_pop@Base", etc.,
347 will be matched by the first pattern while "ng_mystack_new@Base" would not.
348 The second pattern will match all symbols having the string "private" in their
349 names and matches will inherit I<optional> tag from the pattern.
353 Basic patterns listed above can be combined where it makes sense.
354 In that case, they are processed in the order in which the tags are specified.
358 (c++|regex)"^NSA::ClassA::Private::privmethod\d\(int\)@Base" 1.0
359 (regex|c++)N3NSA6ClassA7Private11privmethod\dEi@Base 1.0
361 will match symbols "_ZN3NSA6ClassA7Private11privmethod1Ei@Base" and
362 "_ZN3NSA6ClassA7Private11privmethod2Ei@Base".
363 When matching the first pattern,
364 the raw symbol is first demangled as C++ symbol, then the demangled name is
365 matched against the regular expression.
366 On the other hand, when matching the
367 second pattern, regular expression is matched against the raw symbol name, then
368 the symbol is tested if it is C++ one by attempting to demangle it.
370 of any basic pattern will result in the failure of the whole pattern.
371 Therefore, for example, "__N3NSA6ClassA7Private11privmethod\dEi@Base" will not
372 match either of the patterns because it is not a valid C++ symbol.
374 In general, all patterns are divided into two groups: aliases (basic I<c++>
375 and I<symver>) and generic patterns (I<regex>, all combinations of
376 multiple basic patterns).
377 Matching of basic alias-based patterns is fast (O(1))
378 while generic patterns are O(N) (N - generic pattern count) for each symbol.
379 Therefore, it is recommended not to overuse generic patterns.
381 When multiple patterns match the same real symbol, aliases (first I<c++>,
382 then I<symver>) are preferred over generic patterns.
384 matched in the order they are found in the symbol file template until the first
386 Please note, however, that manual reordering of template file entries
387 is not recommended because B<dpkg-gensymbols> generates diffs based on the
388 alphanumerical order of their names.
390 =head2 Using includes
392 When the set of exported symbols differ between architectures, it may become
393 inefficient to use a single symbol file.
394 In those cases, an include directive
395 may prove to be useful in a couple of ways:
401 You can factorize the common part in some external file
402 and include that file in your I<package>.symbols.I<arch> file by
403 using an include directive like this:
405 #include "I<packages>.symbols.common"
409 The include directive may also be tagged like any symbol:
411 (tag|...|tagN)#include "file-to-include"
413 As a result, all symbols included from I<file-to-include> will be considered
414 to be tagged with I<tag> ... I<tagN> by default.
415 You can use this feature
416 to create a common I<package>.symbols file which includes architecture
417 specific symbol files:
419 common_symbol1@Base 1.0
420 (arch=amd64 ia64 alpha)#include "package.symbols.64-bit"
421 (arch=!amd64 !ia64 !alpha)#include "package.symbols.32-bit"
422 common_symbol2@Base 1.0
426 The symbols files are read line by line, and include directives are processed
427 as soon as they are encountered.
428 This means that the content of the included
429 file can override any content that appeared before the include directive and
430 that any content after the directive can override anything contained in the
432 Any symbol (or even another #include directive) in the included
433 file can specify additional tags or override values of the inherited tags in
434 its tag specification.
435 However, there is no way for the symbol to remove
436 any of the inherited tags.
438 An included file can repeat the header line containing the SONAME of the
440 In that case, it overrides any header line previously read.
441 However, in general it's best to avoid duplicating header lines.
443 to do it is the following:
445 #include "libsomething1.symbols.common"
446 arch_specific_symbol@Base 1.0
451 L<dpkg-shlibdeps(1)>,
452 L<dpkg-gensymbols(1)>.