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. Any line with ‘#’ as
42 the first character is a comment except if it starts with ‘#include’
43 (see section B<Using includes>).
44 Lines starting with ‘#MISSING:’ are special comments documenting
45 symbols that have disappeared.
47 =head2 Using #PACKAGE# substitution
49 In some rare cases, the name of the library varies between architectures.
50 To avoid hardcoding the name of the package in the symbols file, you can
51 use the marker I<#PACKAGE#>. It will be replaced by the real package
52 name during installation of the symbols files. Contrary to the
53 I<#MINVER#> marker, I<#PACKAGE#> will never appear in a symbols file
54 inside a binary package.
56 =head2 Using symbol tags
58 Symbol tagging is useful for marking symbols that are special in some way. Any
59 symbol can have an arbitrary number of tags associated with it. While all tags are
60 parsed and stored, only some of them are understood by
61 B<dpkg-gensymbols> and trigger special handling of the symbols. See
62 subsection B<Standard symbol tags> for reference of these tags.
64 Tag specification comes right before the symbol name (no whitespace is allowed
65 in between). It always starts with an opening bracket B<(>, ends with a
66 closing bracket B<)> and must contain at least one tag. Multiple tags are
67 separated by the B<|> character. Each tag can optionally have a value which
68 is separated form the tag name by the B<=> character. Tag names and values
69 can be arbitrary strings except they cannot contain any of the special B<)>
70 B<|> B<=> characters. Symbol names following a tag specification can
71 optionally be quoted with either B<'> or B<"> characters to allow
72 whitespaces in them. However, if there are no tags specified for the symbol,
73 quotes are treated as part of the symbol name which continues up until the
76 (tag1=i am marked|tag name with space)"tagged quoted symbol"@Base 1.0
77 (optional)tagged_unquoted_symbol@Base 1.0 1
78 untagged_symbol@Base 1.0
80 The first symbol in the example is named I<tagged quoted symbol> and has two
81 tags: I<tag1> with value I<i am marked> and I<tag name with space>
82 that has no value. The second symbol named I<tagged_unquoted_symbol> is
83 only tagged with the tag named I<optional>. The last symbol is an
84 example of the normal untagged symbol.
86 Since symbol tags are an extension of the B<deb-symbols>(5) format, they
87 can only be part of the symbols files used in source packages (those files
88 should then be seen as templates used to build the symbols files that are
89 embedded in binary packages). When
90 B<dpkg-gensymbols> is called without the B<-t> option, it will
91 output symbols files compatible to the B<deb-symbols>(5) format:
92 it fully processes symbols according to the requirements of their standard tags
93 and strips all tags from the output. On the contrary, in template mode
94 (B<-t>) all symbols and their tags (both standard and unknown ones)
95 are kept in the output and are written in their original form as they were
98 =head2 Standard symbol tags
104 A symbol marked as optional can disappear from the library at any time and that
105 will never cause B<dpkg-gensymbols> to fail. However, disappeared optional
106 symbols will continuously appear as MISSING in the diff in each new package
107 revision. This behavior serves as a reminder for the maintainer that such a
108 symbol needs to be removed from the symbol file or readded to the library. When
109 the optional symbol, which was previously declared as MISSING, suddenly
110 reappears in the next revision, it will be upgraded back to the “existing”
111 status with its minimum version unchanged.
113 This tag is useful for symbols which are private where their disappearance do
114 not cause ABI breakage. For example, most of C++ template instantiations fall
115 into this category. Like any other tag, this one may also have an arbitrary
116 value: it could be used to indicate why the symbol is considered optional.
118 =item B<arch=>I<architecture-list>
120 =item B<arch-bits=>I<architecture-bits>
122 =item B<arch-endian=>I<architecture-endianness>
124 These tags allow one to restrict the set of architectures where the symbol
125 is supposed to exist. The B<arch-bits> and B<arch-endian> tags
126 are supported since dpkg 1.18.0. When the symbols list is updated with
128 discovered in the library, all arch-specific symbols which do not concern
129 the current host architecture are treated as if they did not exist. If an
130 arch-specific symbol matching the current host architecture does not exist
131 in the library, normal procedures for missing symbols apply and it may
132 cause B<dpkg-gensymbols> to fail. On the other hand, if the
133 arch-specific symbol is found when it was not supposed to exist (because
134 the current host architecture is not listed in the tag or does not match
135 the endianness and bits), it is made arch neutral (i.e. the arch, arch-bits
136 and arch-endian tags are dropped and the symbol will appear in the diff due
137 to this change), but it is not considered as new.
139 When operating in the default non-template mode, among arch-specific symbols
140 only those that match the current host architecture are written to the
141 symbols file. On the contrary, all arch-specific symbols (including those
142 from foreign arches) are always written to the symbol file when operating
145 The format of I<architecture-list> is the same as the one used in the
146 B<Build-Depends> field of I<debian/control> (except the enclosing
147 square brackets []). For example, the first symbol from the list below
148 will be considered only on alpha, any-amd64 and ia64 architectures,
149 the second only on linux architectures, while the third one anywhere
152 (arch=alpha any-amd64 ia64)64bit_specific_symbol@Base 1.0
153 (arch=linux-any)linux_specific_symbol@Base 1.0
154 (arch=!armel)symbol_armel_does_not_have@Base 1.0
156 The I<architecture-bits> is either B<32> or B<64>.
158 (arch-bits=32)32bit_specific_symbol@Base 1.0
159 (arch-bits=64)64bit_specific_symbol@Base 1.0
161 The I<architecture-endianness> is either B<little> or B<big>.
163 (arch-endian=little)little_endian_specific_symbol@Base 1.0
164 (arch-endian=big)big_endian_specific_symbol@Base 1.0
166 Multiple restrictions can be chained.
168 (arch-bits=32|arch-endian=little)32bit_le_symbol@Base 1.0
170 =item B<allow-internal>
172 dpkg-gensymbols has a list of internal symbols that should not
173 appear in symbols files as they are usually only side-effects of
174 implementation details of the toolchain (since dpkg 1.20.1).
175 If for some reason, you really want one of those symbols to be included in
176 the symbols file, you should tag the symbol with B<allow-internal>.
177 It can be necessary for some low level toolchain libraries like “libgcc”.
179 =item B<ignore-blacklist>
181 A deprecated alias for B<allow-internal> (since dpkg 1.20.1,
182 supported since dpkg 1.15.3).
186 Denotes I<c++> symbol pattern. See B<Using symbol patterns> subsection
191 Denotes I<symver> (symbol version) symbol pattern. See B<Using symbol
192 patterns> subsection below.
196 Denotes I<regex> symbol pattern. See B<Using symbol patterns> subsection
201 =head2 Using symbol patterns
203 Unlike a standard symbol specification, a pattern may cover multiple real
204 symbols from the library. B<dpkg-gensymbols> will attempt to match each
205 pattern against each real symbol that does I<not> have a specific symbol
206 counterpart defined in the symbol file. Whenever the first matching pattern is
207 found, all its tags and properties will be used as a basis specification of the
208 symbol. If none of the patterns matches, the symbol will be considered as new.
210 A pattern is considered lost if it does not match any symbol in the library. By
211 default this will trigger a B<dpkg-gensymbols> failure under B<-c1> or
212 higher level. However, if the failure is undesired, the pattern may be marked
213 with the I<optional> tag. Then if the pattern does not match anything, it
214 will only appear in the diff as MISSING. Moreover, like any symbol, the pattern
215 may be limited to the specific architectures with the I<arch> tag. Please
216 refer to B<Standard symbol tags> subsection above for more information.
218 Patterns are an extension of the B<deb-symbols>(5) format hence they are
219 only valid in symbol file templates. Pattern specification syntax is not any
220 different from the one of a specific symbol. However, symbol name part of the
221 specification serves as an expression to be matched against I<name@version>
222 of the real symbol. In order to distinguish among different pattern types, a
223 pattern will typically be tagged with a special tag.
225 At the moment, B<dpkg-gensymbols> supports three basic pattern types:
231 This pattern is denoted by the I<c++> tag. It matches only C++ symbols by
232 their demangled symbol name (as emitted by B<c++filt>(1) utility). This
233 pattern is very handy for matching symbols which mangled names might vary
234 across different architectures while their demangled names remain the same. One
235 group of such symbols is I<non-virtual thunks> which have architecture
236 specific offsets embedded in their mangled names. A common instance of this
237 case is a virtual destructor which under diamond inheritance needs a
238 non-virtual thunk symbol. For example, even if _ZThn8_N3NSB6ClassDD1Ev@Base on
239 32bit architectures will probably be _ZThn16_N3NSB6ClassDD1Ev@Base on 64bit
240 ones, it can be matched with a single I<c++> pattern:
242 libdummy.so.1 libdummy1 #MINVER#
244 (c++)"non-virtual thunk to NSB::ClassD::~ClassD()@Base" 1.0
247 The demangled name above can be obtained by executing the following command:
249 $ echo '_ZThn8_N3NSB6ClassDD1Ev@Base' | c++filt
251 Please note that while mangled name is unique in the library by definition,
252 this is not necessarily true for demangled names. A couple of distinct real
253 symbols may have the same demangled name. For example, that's the case with
254 non-virtual thunk symbols in complex inheritance configurations or with most
255 constructors and destructors (since g++ typically generates two real symbols
256 for them). However, as these collisions happen on the ABI level, they should
257 not degrade quality of the symbol file.
261 This pattern is denoted by the I<symver> tag. Well maintained libraries have
262 versioned symbols where each version corresponds to the upstream version where
263 the symbol got added. If that's the case, you can use a I<symver> pattern to
264 match any symbol associated to the specific version. For example:
266 libc.so.6 libc6 #MINVER#
267 (symver)GLIBC_2.0 2.0
269 (symver)GLIBC_2.7 2.7
272 All symbols associated with versions GLIBC_2.0 and GLIBC_2.7 will lead to
273 minimal version of 2.0 and 2.7 respectively with the exception of the symbol
274 access@GLIBC_2.0. The latter will lead to a minimal dependency on libc6 version
275 2.2 despite being in the scope of the "(symver)GLIBC_2.0" pattern because
276 specific symbols take precedence over patterns.
278 Please note that while old style wildcard patterns (denoted by "*@version" in
279 the symbol name field) are still supported, they have been deprecated by new
280 style syntax "(symver|optional)version". For example, "*@GLIBC_2.0 2.0" should
281 be written as "(symver|optional)GLIBC_2.0 2.0" if the same behavior is needed.
285 Regular expression patterns are denoted by the I<regex> tag. They match by
286 the perl regular expression specified in the symbol name field. A regular
287 expression is matched as it is, therefore do not forget to start it with the
288 I<^> character or it may match any part of the real symbol
289 I<name@version> string. For example:
291 libdummy.so.1 libdummy1 #MINVER#
292 (regex)"^mystack_.*@Base$" 1.0
293 (regex|optional)"private" 1.0
295 Symbols like "mystack_new@Base", "mystack_push@Base", "mystack_pop@Base", etc.,
296 will be matched by the first pattern while "ng_mystack_new@Base" would not.
297 The second pattern will match all symbols having the string "private" in their
298 names and matches will inherit I<optional> tag from the pattern.
302 Basic patterns listed above can be combined where it makes sense. In that case,
303 they are processed in the order in which the tags are specified. For example,
306 (c++|regex)"^NSA::ClassA::Private::privmethod\d\(int\)@Base" 1.0
307 (regex|c++)N3NSA6ClassA7Private11privmethod\dEi@Base 1.0
309 will match symbols "_ZN3NSA6ClassA7Private11privmethod1Ei@Base" and
310 "_ZN3NSA6ClassA7Private11privmethod2Ei@Base". When matching the first pattern,
311 the raw symbol is first demangled as C++ symbol, then the demangled name is
312 matched against the regular expression. On the other hand, when matching the
313 second pattern, regular expression is matched against the raw symbol name, then
314 the symbol is tested if it is C++ one by attempting to demangle it. A failure
315 of any basic pattern will result in the failure of the whole pattern.
316 Therefore, for example, "__N3NSA6ClassA7Private11privmethod\dEi@Base" will not
317 match either of the patterns because it is not a valid C++ symbol.
319 In general, all patterns are divided into two groups: aliases (basic I<c++>
320 and I<symver>) and generic patterns (I<regex>, all combinations of
321 multiple basic patterns). Matching of basic alias-based patterns is fast (O(1))
322 while generic patterns are O(N) (N - generic pattern count) for each symbol.
323 Therefore, it is recommended not to overuse generic patterns.
325 When multiple patterns match the same real symbol, aliases (first I<c++>,
326 then I<symver>) are preferred over generic patterns. Generic patterns are
327 matched in the order they are found in the symbol file template until the first
328 success. Please note, however, that manual reordering of template file entries
329 is not recommended because B<dpkg-gensymbols> generates diffs based on the
330 alphanumerical order of their names.
332 =head2 Using includes
334 When the set of exported symbols differ between architectures, it may become
335 inefficient to use a single symbol file. In those cases, an include directive
336 may prove to be useful in a couple of ways:
342 You can factorize the common part in some external file
343 and include that file in your I<package>.symbols.I<arch> file by
344 using an include directive like this:
346 #include "I<packages>.symbols.common"
350 The include directive may also be tagged like any symbol:
352 (tag|...|tagN)#include "file-to-include"
354 As a result, all symbols included from I<file-to-include> will be considered
355 to be tagged with I<tag> ... I<tagN> by default. You can use this feature
356 to create a common I<package>.symbols file which includes architecture
357 specific symbol files:
359 common_symbol1@Base 1.0
360 (arch=amd64 ia64 alpha)#include "package.symbols.64bit"
361 (arch=!amd64 !ia64 !alpha)#include "package.symbols.32bit"
362 common_symbol2@Base 1.0
366 The symbols files are read line by line, and include directives are processed
367 as soon as they are encountered. This means that the content of the included
368 file can override any content that appeared before the include directive and
369 that any content after the directive can override anything contained in the
370 included file. Any symbol (or even another #include directive) in the included
371 file can specify additional tags or override values of the inherited tags in
372 its tag specification. However, there is no way for the symbol to remove
373 any of the inherited tags.
375 An included file can repeat the header line containing the SONAME of the
376 library. In that case, it overrides any header line previously read.
377 However, in general it's best to avoid duplicating header lines. One way
378 to do it is the following:
380 #include "libsomething1.symbols.common"
381 arch_specific_symbol@Base 1.0
386 B<dpkg-shlibdeps>(1),
387 B<dpkg-gensymbols>(1).