16615 ena assertion failure in ena_tx_intr_work()
[illumos-gate.git] / usr / src / lib / README.mapfiles
blob16878de6b793129838119950689fb83d0c0ea789
2 # CDDL HEADER START
4 # The contents of this file are subject to the terms of the
5 # Common Development and Distribution License (the "License").
6 # You may not use this file except in compliance with the License.
8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 # or http://www.opensolaris.org/os/licensing.
10 # See the License for the specific language governing permissions
11 # and limitations under the License.
13 # When distributing Covered Code, include this CDDL HEADER in each
14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 # If applicable, add the following below this CDDL HEADER, with the
16 # fields enclosed by brackets "[]" replaced with your own identifying
17 # information: Portions Copyright [yyyy] [name of copyright owner]
19 # CDDL HEADER END
22 # Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
25 Mapfiles and versioning in illumos
26 ==================================
28 1.0 Objective of this README
30 This README describes the engineering practices of creating and updating
31 visible library interfaces.  It describes various kinds of actions that
32 typically occur as libraries are evolved, and shows how interface
33 specifications are affected or updated in accordance.  It tells you what
34 you must do as a shared library developer if you:
36         1. Make interface additions to an existing library
37                 - add a Public interface
38                 - add a Private interface
39         2. Update an interface in an existing library
40                 - remove an existing interface
41                 - promote a Private interface to Public
42                 - scope a Private interface to local
43                 - move an interface from one library to another
44                 - copy interfaces which are part of the standard to a new or
45                   existing library
46         3. Introduce a new library
47                 - source directory hierarchy
48                 - creation of the "mapfile-vers" file
49                 - Makefiles
50         4. Make an entire library obsolete before end-of-life
51                 - introduce SUNWobsolete to the "mapfile-vers" file
53 -------------------------------------------------------------------------------
55 2.0 What's a mapfile?
57 Mapfiles are used to tell the link-editor ("ld") all sorts of things about
58 how to generate an executable file or a shared object from a collection of
59 relocatable objects, such as generated by a compiler.  For all the gory
60 details, see the Solaris Linker and Libraries Guide.
62 There are two versions of the mapfile language accepted by the link-editor.
63 Version 1 derives from AT&T System V Release 4 Unix. Version 2 is a newer
64 syntax specific to Solaris and derivatives.  All mapfiles in illumos are
65 required to use version 2 syntax. Note that every mapfile using version 2
66 syntax must start with the line:
68         $mapfile_version 2
70 Here, we are only concerned with specifying externally-visible interfaces
71 for shared libraries (shared objects) and with specifying their versions
72 for ABI (Application Binary Interface) purposes.  For these purposes, we
73 only need to deal with a subset of the mapfile language.
75 There should be a "mapfile-vers" file associated with every shared library
76 and it should reside in the common source directory for that library, most
77 often in a "common" directory.  This is the usual layout of a library's
78 top-level directory (usr/src/lib/libwombat):
79         Makefile       amd64/         i386/          sparcv9/
80         Makefile.com   common/        sparc/
82 The "common" directory contains the source files and other common files
83 for the library:
84         bat.c              libwombat_impl.h   mapfile-vers       wom.c
85         libwombat.h        llib-lwombat       util.c             wombat.c
87 The mapfile's name is, by convention, "mapfile-vers" because it is used
88 for only two purposes: to specify externally-visible interface names while
89 suppressing visibility of all other names, and to specify their respective
90 unique version names.
92 -------------------------------------------------------------------------------
94 3.0 Contents of mapfile-vers
96 The structure of mapfile-vers is best explained by an example
97 (the license notification and copyright notice is omitted here
98 for brevity):
100 $mapfile_version 2
102 SYMBOL_VERSION ILLUMOS_0.2 {    # Second interface change in illumos
103     global:
104         wb_notify;
105 } ILLUMOS_0.1;
107 SYMBOL_VERSION ILLUMOS_0.1 {    # First interface change in illumos
108     global:
109         wb_poll;
110 } SUNW_1.2;
112 SYMBOL_VERSION SUNW_1.2 {       # update to libwombat, Solaris 10
113     global:
114         wb_readv;
115         wb_stat;
116         wb_writev;
117 } SUNW_1.1;
119 SYMBOL_VERSION SUNW_1.1 {       # first release of libwombat, Solaris 9
120     global:
121         wb_read;
122         wb_write;
125 SYMBOL_VERSION SUNWprivate {    # private libwombat symbols
126     global:
127         wb_add;
128         wb_delete;
129         wb_search;
130     local:
131         *;
134 Each of these sections is a version declaration describing an ABI version of
135 the library containing the set of symbols exposed by the library to
136 external callers.
138 ABI versions must be constant, that is version ILLUMOS_0.2 in a given
139 library must always describe the same interface such that applications may
140 safely state their dependencies in terms of these versions and have a
141 constant and predictable ABI be exposed.  This in effect means that once a
142 version is publicly visible, it may never be removed or have symbols added
143 to or removed from it.
145 ABI versions with the same major number should be upward compatible, that is
146 ILLUMOS_0.3 of a given library must contain all the interfaces in
147 ILLUMOS_0.2, and they must be compatible.
149 The private version, however, is special, and describes any private yet
150 exposed symbols within a library, and may change at any time (and without
151 notice).  It exists purely to allow certain symbols to be of global scope
152 but not Public.  Similarly, any symbols scoped local are private and may
153 change safely, even if the local statement happens to be within a public
154 version.
156 Interface changes made in illumos should be done with ILLUMOS_0.* versions,
157 introducing one version per interface change.  In illumos, unlike Solaris,
158 symbol versions are not release-specific because of the requirement that
159 each be constant.  No change should be made to add or remove symbols from
160 any pre-existing Public version.
162 The SUNW_*.* names were the Public version names of the library in Solaris.
163 There should be at most one version name for each release of Solaris, with
164 the minor number incremented by one over the previous version.  No changes
165 should ever be made to SUNW_1.* versions.
167 So, for example, to add a new interface to libwombat in illumos one would add:
169 SYMBOL_VERSION ILLUMOS_0.3 {    # Third update to libwombat in illumos
170     global:
171         wb_lseek;
172 } ILLUMOS_0.2;
174 Each version must inherit all symbols from its preceding version, specified at
175 the ending "}" for each version. The initial public version does not inherit
176 any symbols.  The private version named either "SUNWprivate" for libraries
177 with private symbols pre-existing illumos, or "ILLUMOSprivate" otherwise
178 stands alone, inheriting nothing and being inherited by nothing.
180 The two lines in SUNWprivate:
181     local:
182         *;
183 ensure that no symbols other than those listed in the mapfile are visible to
184 clients of the library.  If there is no private version, these two lines should
185 appear in the first public version.
187 For maintainability, the list of names in each version block should
188 be sorted in dictionary order (sort -d).  Please comply.
190 The version 2 mapfile language supports a simple mechanism for conditional
191 input, in which lines in the mapfile apply only to a specific platform or
192 ELFCLASS (32/64-bit). This mechanism works very much like the #if/#endif
193 feature of the C preprocessor. For instance, the following mapfile declares
194 a version SUNW_1.1 that always exports a symbol foo, and also exports
195 the symbol bar on 32-bit sparc platforms:
197 $mapfile_version 2
198 SYMBOL_VERSION SUNW_1.1 {
199         foo;
200 $if _sparc && _ELF32
201         bar;
202 $endif
205 Conditional input can be used if there are ISA-specific library interfaces
206 not common to all instances of the library. It is the preferred method for
207 expressing platform specific items, as long as the differences are simple
208 (which is almost always the case).  For example, see libproc, or, if you
209 are masochistic, libc or libnsl.  In general, use of this feature should be
210 minimal.
212 In addition to conditional input, there is a second heavier weight mechanism
213 for expressing ISA-specific differences. In addition to the common mapfile:
214         common/mapfile-vers
215 some libraries may have ISA-specific supplemental mapfiles, one in each
216 of the ISA directories:
217         amd64/mapfile-vers
218         i386/mapfile-vers
219         sparc/mapfile-vers
220         sparcv9/mapfile-vers
221 The ISA-specific mapfiles look like the common mapfile, except that only
222 the ISA-specific names appear.  The version names are the same as those
223 in the common mapfile, but only non-empty version instances are present
224 and no inheritance specification is present. The link-editor reads the
225 information from the common and ISA-specific mapfiles and merges them
226 in memory into a single description used to create the resulting object.
228 ISA-specific mapfiles were used with the version 1 mapfile language, which
229 lacked conditional input. Their use is rare now, as conditional input is
230 generally preferred. However, it is important to use conditional input
231 carefully, or the resulting mapfile can be extremly difficult to read.
233 -------------------------------------------------------------------------------
235 4.0 Making interface additions to an existing library
237 4.1 Adding a Public interface
239 Public interfaces should be added to a new ILLUMOS_ symbol version, with the
240 minor number incremented by one from the current highest version name. If
241 this is the first Public interface in the shared object, a new ILLUMOS_0.1
242 version name must be introduced.
244 The major revision number is incremented whenever an incompatible change is
245 made to an interface.  This could be the case if an API changes so
246 dramatically as to invalidate dependencies.  This should almost never occur
247 in practice.  It also requires changing the suffix of the shared object
248 from, say, .so.1 to .so.2 and introducing code to continue to ship the .so.1
249 version of the library.
251 The minor revision number is incremented whenever one or more new interfaces
252 is added to a library.  Once a version comes to exist in illumos, it is from
253 that point onward considered to be immutable.
255 While strongly discouraged, if it is necessary to add global data symbols to a
256 library (which become part of the ABI), an assertion that specifies the size
257 of the object must be added.
259 4.2 Adding a Private interface
261 Private interfaces are the non-ABI interfaces of the library.  Unlike
262 introducing a Public interface, a new entry is simply added to the
263 private version.  No minor number increment is necessary.
265 If this interface happens to be the first Private interface introduced into
266 the library, the private version must be created (with no major.minor
267 version numbers).  It inherits nothing, nothing inherits from it and it
268 should be named ILLUMOSprivate.
270 If the library already has Private interfaces in a SUNWprivate version, you
271 should use that.  They may have numbered version names like SUNWprivate_m.n
272 (due to errors of the past).  If so, just use the highest numbered private
273 version name to version the new interface.  There is no need to introduce a
274 new private version name.  Be careful not to use a lower numbered private
275 version name; doing so can cause runtime errors (as opposed to load time
276 errors) when running an application with older versions of the library.
278 There are also libraries in illumos that contain only private interfaces. In
279 such libraries, the private versions maybe legitimately be versioned and
280 they may be incremented to ensure that the programs that depend on them are
281 built and delivered as a integrated unit. A notable example of this is
282 libld.so (usr/src/cmd/sgs/libld), which contains the implementation of the
283 link-editor, the public interface to which is provided by the ld
284 command. When making a modification to the interface of such a library, you
285 should follow the convention already in place.
287 As with public interfaces, the size of global objects must be asserted in
288 private versions (though it will be less problematic to change them later).
290 4.3 Historical handling of Solaris update releases.
292 To aid the understanding of our existing mapfiles, it is useful to note how
293 interface versions were handled as they interacted with update releases of
294 Solaris.  Solaris update releases required careful coordination with the full
295 release currently under development to keep symbol versions constant between
296 releases.
298 Multiple update releases were generally shipped during the development of the
299 next full release of Solaris.  It was impossible to know in advance the full
300 set of new interfaces in the next full release until it was complete.  Some,
301 though not all, new interfaces were included in the intervening update
302 releases between full releases.
304 Consequently, the new version number for an update cannot be a minor
305 increment, but must be a micro increment to ensure that was a distinct version
306 between the two releases.  For example, if Release N had version number
307 SUNW_1.3 and Release N+1 had SUNW_1.4, then interfaces added to an update of
308 Release N must have micro numbers such as SUNW_1.3.1, SUNW_1.3.2, etc.  (note
309 that the micro number is not directly tied to the update number: SUNW_1.3.1
310 may have appeared in Update 2).  The micro versions form an inheritance chain
311 that is inserted between two successive minor versions.  For example, the
312 mapfile-vers file for minor release "N+1" to reflect its inclusion of micro
313 releases will look like the following:
315 $mapfile_version 2
317 SYMBOL_VERSION SUNW_1.4 {       # release N+1
318     global:
319         ...
320 } SUNW_1.3.2;
322 SYMBOL_VERSION SUNW_1.3.2 {     # micro release 2 (e.g., release NU3)
323     global:
324         ...
325 } SUNW_1.3.1;
327 SYMBOL_VERSION SUNW_1.3.1 {     # micro release 1 (e.g., release NU2)
328     global:
329         ...
330 } SUNW_1.3;
332 SYMBOL_VERSION SUNW_1.3 {       # release N
333     global:
334         ...
335 } SUNW_1.2;
337 SYMBOL_VERSION SUNW_1.2 {       # release N-1
338     global:
339         ...
340 } SUNW_1.1;
342 SYMBOL_VERSION SUNW_1.1 {       # first release
343     global:
344         ...
347 SYMBOL_VERSION SUNW_private {   # same in all releases
348     global:
349         ...
350     local:
351         *;
354 The corresponding update/patch mapfile-vers file will be identical
355 except for the exclusion of SUNW_1.4.
357 Those interfaces which are only present in Release N+1 are always put
358 into the next minor version set, SUNW_1.4.
360 Thus when adding a new Public interface to an update release, both the mapfiles
361 of the update release and next full release should have been modified to be
362 consistent.
364 There have been several cases of accidental deviation from this scheme, and
365 existing mapfiles sometimes reflect this unfortunate state of affairs.
367 -------------------------------------------------------------------------------
369 5.0 How to update an interface in an existing library
371 5.1 Removing an existing interface
373 5.1.1 Moving a Public interface
375 No Public interfaces should ever be removed from any mapfile, as this will
376 break all existing consumers of that interface.
378 To move an interface from one library to (say) libc, the code has to be
379 deleted from the library and added to libc, then the mapfile for the
380 library has to have the interface's entry changed from:
381         getfoobar;
383         getfoobar       { TYPE = FUNCTION; FILTER = libc.so.1 };
384 This is an exception to the immutability of public symbol versions.  See,
385 for example, libnsl's common/mapfile-vers file.
387 Follow the rules for adding a new interface for the necessary changes
388 to libc's mapfile to accommodate the moved interface, including creating a
389 new version in libc for the symbol.
391 When merging an entire library into libc, the mapfile is changed to specify
392 the type of each public symbol similarly to the above:
393         getfoobar;
395         getfoobar       { TYPE = FUNCTION };
397 But rather than specifying the library on which we filter for each symbol,
398 the link-editor is invoked with '-F libc.so.1' to specify that our entire
399 symbol table is a filter on libc.  For examples, see libaio and librt.
401 5.1.2 Removing a Private interface
403 Deletion of Private interfaces is allowed, but caution should be taken;
404 it should first be established that the interface is not being used.
405 To remove a Private interface, simply delete the corresponding entry
406 for that symbol from the mapfile's private version section.
408 Do not forget to delete these Public or Private interfaces from the library's
409 header files as well as from the code that implements the interfaces.
411 5.2 Promoting a Private interface to Public
413 This is similar to what's done when adding a Public interface.  Promoting an
414 existing Private interface to a Public one only requires a change to the
415 existing interface definition.  Private interfaces have the symbol version
416 name "ILLUMOSprivate" or "SUNWprivate" associated with them.  To make the
417 interface a Public one, the interface must be added as if it were a new
418 public symbol, following those same rules and removed from the private
419 version.
421 As an example, if we were modifying libwombat.so.1 and its existing latest
422 version were ILLUMOS_0.3, any new ABI would be put into a version called
423 ILLUMOS_0.4.  Therefore, whether you wish to promote an existing Private
424 interface to Public, or to introduce a new Public interface, this (next
425 successive minor numbered version level) would be the version that it would
426 be associated with.
428 5.3 Scoping a Private interface local
430 Any interfaces not present in the mapfile-vers file will be scoped local
431 due to the presence of the
432     local:
433         *;
434 lines discussed earlier. This ensures that such interfaces will not be visible
435 outside the library.  To move an interface from Private to local scope, simply
436 remove the Private interface from the mapfile-vers file and the header file
437 to prevent it from being exported.  This may require moving the Private
438 interface into a library-private header file.  Scope reduction of Public
439 interfaces is forbidden.
441 For the interface to be used in more than one file within the library, it
442 should be in a header file that can be included by each file in the library
443 that uses the interface.  For example:
445         #include "libprivate.h"
447 5.4 How to copy interfaces which are part of a standard to a new or existing
448     library
450 SYSVABI and SISCD are reserved version names for interfaces listed in the
451 System V Interface Definition and the Sparc Compliance Definition.  Avoid
452 using these version names when copying the implementation of standard
453 interfaces to another library.  Instead, use ILLUMOS_0.1 for a new library,
454 and ILLUMOS_m.n for an existing library (where m.n is the next version; i.e.,
455 if the last version was ILLUMOS_0.8, then you should version the interfaces
456 with ILLUMOS_0.9).
458 -------------------------------------------------------------------------------
460 6.0 Introducing a new library
462 6.1 Directories
464 The normal discipline for introducing a new library in illumos is to create a
465 new subdirectory of usr/src/lib.  The interface definition discipline is to
466 create a common/mapfile-vers file for the new library.  If we were introducing
467 a new foo library, libfoo, we'd create usr/src/lib/libfoo containing:
468         Makefile       amd64/         i386/          sparcv9/
469         Makefile.com   common/        sparc/
470 The common subdirectory would contain the normal source files plus the
471 mapfile-vers file.  See usr/src/lib/README.Makefiles for directions on
472 how to organize the Makefiles.
474 6.2 The mapfile
476 The new common/mapfile-vers file would contain:
478 $mapfile_version 2
480 SYMBOL_VERSION ILLUMOS_0.1 {    # first release of libfoo
481     global:
482         ...
485 SYMBOL_VERSION ILLUMOSprivate {
486     global:
487         ...
488     local:
489         *;
492 If there are no Public interfaces, the ILLUMOS_0.1 section would be omitted.
493 If there are no Private interfaces, the ILLUMOSprivate section would be
494 omitted and the two lines:
495     local:
496         *;
497 would be moved into ILLUMOS_0.1.
499 To decide which interfaces are Public (part of the ABI) and which are
500 Private (unstable interfaces not intended to be used by third parties), the
501 heuristic which works to a first approximation is that if it has a man page
502 then it's Public.
504 For maintainability, the list of names in each version block should
505 be sorted in dictionary order (sort -d).  Please comply.
507 -------------------------------------------------------------------------------
509 7.0 Make an entire library obsolete
511 7.1 Introduce SUNWobsolete version
513 Use this version name not for specific interfaces but for marking an entire
514 library as obsolete.  The existing public/private version names are left
515 unchanged, but a new SUNWobsolete version is created with no symbols in it.
516 This becomes a tag by which the obsolescence of the library can be recognized.
517 There is no numbering of this version name.
519 $mapfile_version 2
521 SYMBOL_VERSION SUNWobsolete {
522     global:
523         SUNWobsolete;   # This is the only way to do it.
524 } SUNW_1.2;
526 SYMBOL_VERSION ILLUMOS_0.2 {
529 You should continue to use the name SUNWobsolete even in illumos.
531 -------------------------------------------------------------------------------
533 8.0 Documentation
535 For further information, please refer to the following documents:
537         "Solaris Linker and Libraries Guide"