1 @c Copyright (C) 2002 Free Software Foundation, Inc.
2 @c This is part of the GCC manual.
3 @c For copying conditions, see the file gcc.texi.
6 @chapter Binary Compatibility
7 @cindex binary compatibility
9 @cindex application binary interface
11 Binary compatibility encompasses several related concepts:
14 @item application binary interface (ABI)
15 The set of runtime conventions followed by all of the tools that deal
16 with binary representations of a program, including compilers, assemblers,
17 linkers, and language runtime support.
18 Some ABIs are formal with a written specification, possibly designed
19 by multiple interested parties. Others are simply the way things are
20 actually done by a particular set of tools.
23 A compiler conforms to an ABI if it generates code that follows all of
24 the specifications enumerated by that ABI@.
25 A library conforms to an ABI if it is implemented according to that ABI@.
26 An application conforms to an ABI if it is built using tools that conform
27 to that ABI and does not contain source code that specifically changes
28 behavior specified by the ABI@.
30 @item calling conventions
31 Calling conventions are a subset of an ABI that specify of how arguments
32 are passed and function results are returned.
34 @item interoperability
35 Different sets of tools are interoperable if they generate files that
36 can be used in the same program. The set of tools includes compilers,
37 assemblers, linkers, libraries, header files, startup files, and debuggers.
38 Binaries produced by different sets of tools are not interoperable unless
39 they implement the same ABI@. This applies to different versions of the
40 same tools as well as tools from different vendors.
42 @item intercallability
43 Whether a function in a binary built by one set of tools can call a
44 function in a binary built by a different set of tools is a subset
47 @item implementation-defined features
48 Language standards include lists of implementation-defined features whose
49 behavior can vary from one implementation to another. Some of these
50 features are normally covered by a platform's ABI and others are not.
51 The features that are not covered by an ABI generally affect how a
52 program behaves, but not intercallability.
55 Conformance to the same ABI and the same behavior of implementation-defined
56 features are both relevant for compatibility.
59 The application binary interface implemented by a C or C++ compiler
60 affects code generation and runtime support for:
64 size and alignment of data types
66 layout of structured types
70 register usage conventions
72 interfaces for runtime arithmetic support
77 In addition, the application binary interface implemented by a C++ compiler
78 affects code generation and runtime support for:
85 invoking constructors and destructors
87 layout, alignment, and padding of classes
89 layout and alignment of virtual tables
92 Some GCC compilation options cause the compiler to generate code that
93 does not conform to the platform's default ABI@. Other options cause
94 different program behavior for implementation-defined features that are
95 not covered by an ABI@. These options are provided for consistency with
96 other compilers that do not follow the platform's default ABI or the
97 usual behavior of implementation-defined features for the platform.
98 Be very careful about using such options.
100 Most platforms have a well-defined ABI that covers C code, but ABIs
101 that cover C++ functionality are not yet common.
103 Starting with GCC 3.2, GCC binary conventions for C++ are based on a
104 written, vendor-neutral C++ ABI that was designed to be specific to
105 64-bit Itanium but also includes generic specifications that apply to
107 This C++ ABI is also implemented by other compiler vendors on some
108 platforms, notably GNU/Linux and BSD systems.
109 We have tried hard to provide a stable ABI that will be compatible with
110 future GCC releases, but it is possible that we will encounter problems
111 that make this difficult. Such problems could include different
112 interpretations of the C++ ABI by different vendors, bugs in the ABI, or
113 bugs in the implementation of the ABI in different compilers.
114 GCC's @code{-Wabi} switch warns when G++ generates code that is
115 probably not compatible with the C++ ABI@.