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