OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gcc-4.5.1/] [libstdc++-v3/] [doc/] [xml/] [manual/] [abi.xml] - Blame information for rev 424

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 424 jeremybenn
2
3
 
4
5
  
6
    
7
      C++
8
    
9
    
10
      ABI
11
    
12
    
13
      version
14
    
15
    
16
      dynamic
17
    
18
    
19
      shared
20
    
21
    
22
      compatibility
23
    
24
  
25
26
 
27
ABI Policy and Guidelines
28
 
29
30
31
 
32
33
The C++ Interface
34
 
35
36
  C++ applications often dependent on specific language support
37
  routines, say for throwing exceptions, or catching exceptions, and
38
  perhaps also dependent on features in the C++ Standard Library.
39
40
 
41
42
  The C++ Standard Library has many include files, types defined in
43
  those include files, specific named functions, and other
44
  behavior. The text of these behaviors, as written in source include
45
  files, is called the Application Programing Interface, or API.
46
47
 
48
49
  Furthermore, C++ source that is compiled into object files is
50
  transformed by the compiler: it arranges objects with specific
51
  alignment and in a particular layout, mangling names according to a
52
  well-defined algorithm, has specific arrangements for the support of
53
  virtual functions, etc. These details are defined as the compiler
54
  Application Binary Interface, or ABI. The GNU C++ compiler uses an
55
  industry-standard C++ ABI starting with version 3. Details can be
56
  found in the 
57
  url="http://www.codesourcery.com/cxx-abi/abi.html"> ABI
58
  specification.
59
60
 
61
62
 The GNU C++ compiler, g++, has a compiler command line option to
63
  switch between various different C++ ABIs. This explicit version
64
  switch is the flag -fabi-version. In addition, some
65
  g++ command line options may change the ABI as a side-effect of
66
  use. Such flags include -fpack-struct and
67
  -fno-exceptions, but include others: see the complete
68
  list in the GCC manual under the heading Options
69
  for Code Generation Conventions.
70
71
 
72
73
  The configure options used when building a specific libstdc++
74
  version may also impact the resulting library ABI. The available
75
  configure options, and their impact on the library ABI, are
76
  documented
77
here.
78
79
 
80
 Putting all of these ideas together results in the C++ Standard
81
library ABI, which is the compilation of a given library API by a
82
given compiler ABI. In a nutshell:
83
84
 
85
86
  
87
    library API + compiler ABI = library ABI
88
  
89
90
 
91
92
 The library ABI is mostly of interest for end-users who have
93
 unresolved symbols and are linking dynamically to the C++ Standard
94
 library, and who thus must be careful to compile their application
95
 with a compiler that is compatible with the available C++ Standard
96
 library binary. In this case, compatible is defined with the equation
97
 above: given an application compiled with a given compiler ABI and
98
 library API, it will work correctly with a Standard C++ Library
99
 created with the same constraints.
100
101
 
102
103
  To use a specific version of the C++ ABI, one must use a
104
  corresponding GNU C++ toolchain (i.e., g++ and libstdc++) that
105
  implements the C++ ABI in question.
106
107
 
108
109
 
110
111
Versioning
112
 
113
 The C++ interface has evolved throughout the history of the GNU
114
C++ toolchain. With each release, various details have been changed so
115
as to give distinct versions to the C++ interface.
116
117
 
118
  
119
    Goals
120
 
121
Extending existing, stable ABIs. Versioning gives subsequent
122
releases of library binaries the ability to add new symbols and add
123
functionality, all the while retaining compatibility with the previous
124
releases in the series. Thus, program binaries linked with the initial
125
release of a library binary will still link correctly if the library
126
binary is replaced by carefully-managed subsequent library
127
binaries. This is called forward compatibility.
128
129
130
The reverse (backwards compatibility) is not true. It is not possible
131
to take program binaries linked with the latest version of a library
132
binary in a release series (with additional symbols added), substitute
133
in the initial release of the library binary, and remain link
134
compatible.
135
136
 
137
Allows multiple, incompatible ABIs to coexist at the same time.
138
139
  
140
 
141
  
142
    History
143
 
144
145
 How can this complexity be managed? What does C++ versioning mean?
146
  Because library and compiler changes often make binaries compiled
147
  with one version of the GNU tools incompatible with binaries
148
  compiled with other (either newer or older) versions of the same GNU
149
  tools, specific techniques are used to make managing this complexity
150
  easier.
151
152
 
153
154
  The following techniques are used:
155
156
 
157
  
158
 
159
    Release versioning on the libgcc_s.so binary. 
160
 
161
    This is implemented via file names and the ELF
162
    DT_SONAME mechanism (at least on ELF
163
    systems). It is versioned as follows:
164
    
165
 
166
    
167
    gcc-3.0.0: libgcc_s.so.1
168
    gcc-3.0.1: libgcc_s.so.1
169
    gcc-3.0.2: libgcc_s.so.1
170
    gcc-3.0.3: libgcc_s.so.1
171
    gcc-3.0.4: libgcc_s.so.1
172
    gcc-3.1.0: libgcc_s.so.1
173
    gcc-3.1.1: libgcc_s.so.1
174
    gcc-3.2.0: libgcc_s.so.1
175
    gcc-3.2.1: libgcc_s.so.1
176
    gcc-3.2.2: libgcc_s.so.1
177
    gcc-3.2.3: libgcc_s.so.1
178
    gcc-3.3.0: libgcc_s.so.1
179
    gcc-3.3.1: libgcc_s.so.1
180
    gcc-3.3.2: libgcc_s.so.1
181
    gcc-3.3.3: libgcc_s.so.1
182
    gcc-3.4.x, gcc-4.[0-5].x: on m68k-linux and
183
    hppa-linux this is either libgcc_s.so.1 (when configuring
184
    --with-sjlj-exceptions) or libgcc_s.so.2. For all
185
    others, this is libgcc_s.so.1.  
186
    
187
    
188
 
189
  
190
 
191
    Symbol versioning on the libgcc_s.so binary.
192
 
193
    It is versioned with the following labels and version
194
   definitions, where the version definition is the maximum for a
195
   particular release. Labels are cumulative. If a particular release
196
   is not listed, it has the same version labels as the preceding
197
   release.
198
 
199
    This corresponds to the mapfile: gcc/libgcc-std.ver
200
    
201
    gcc-3.0.0: GCC_3.0
202
    gcc-3.3.0: GCC_3.3
203
    gcc-3.3.1: GCC_3.3.1
204
    gcc-3.3.2: GCC_3.3.2
205
    gcc-3.3.4: GCC_3.3.4
206
    gcc-3.4.0: GCC_3.4
207
    gcc-3.4.2: GCC_3.4.2
208
    gcc-3.4.4: GCC_3.4.4
209
    gcc-4.0.0: GCC_4.0.0
210
    gcc-4.1.0: GCC_4.1.0
211
    gcc-4.2.0: GCC_4.2.0
212
    gcc-4.3.0: GCC_4.3.0
213
    gcc-4.4.0: GCC_4.4.0
214
    
215
    
216
 
217
    
218
      
219
        Release versioning on the libstdc++.so binary, implemented in
220
        the same was as the libgcc_s.so binary above. Listed is the
221
        filename: DT_SONAME can be deduced from
222
        the filename by removing the last two period-delimited numbers. For
223
        example, filename libstdc++.so.5.0.4
224
        corresponds to a DT_SONAME of
225
        libstdc++.so.5. Binaries with equivalent
226
        DT_SONAMEs are forward-compatibile: in
227
        the table below, releases incompatible with the previous
228
        one are explicitly noted.
229
      
230
 
231
    It is versioned as follows:
232
    
233
    
234
    gcc-3.0.0: libstdc++.so.3.0.0
235
    gcc-3.0.1: libstdc++.so.3.0.1
236
    gcc-3.0.2: libstdc++.so.3.0.2
237
    gcc-3.0.3: libstdc++.so.3.0.2 (See Note 1)
238
    gcc-3.0.4: libstdc++.so.3.0.4
239
    gcc-3.1.0: libstdc++.so.4.0.0 (Incompatible with previous)
240
    gcc-3.1.1: libstdc++.so.4.0.1
241
    gcc-3.2.0: libstdc++.so.5.0.0 (Incompatible with previous)
242
    gcc-3.2.1: libstdc++.so.5.0.1
243
    gcc-3.2.2: libstdc++.so.5.0.2
244
    gcc-3.2.3: libstdc++.so.5.0.3 (See Note 2)
245
    gcc-3.3.0: libstdc++.so.5.0.4
246
    gcc-3.3.1: libstdc++.so.5.0.5
247
    gcc-3.3.2: libstdc++.so.5.0.5
248
    gcc-3.3.3: libstdc++.so.5.0.5
249
    gcc-3.4.0: libstdc++.so.6.0.0 (Incompatible with previous)
250
    gcc-3.4.1: libstdc++.so.6.0.1
251
    gcc-3.4.2: libstdc++.so.6.0.2
252
    gcc-3.4.3: libstdc++.so.6.0.3
253
    gcc-3.4.4: libstdc++.so.6.0.3
254
    gcc-3.4.5: libstdc++.so.6.0.3
255
    gcc-3.4.6: libstdc++.so.6.0.3
256
    gcc-4.0.0: libstdc++.so.6.0.4
257
    gcc-4.0.1: libstdc++.so.6.0.5
258
    gcc-4.0.2: libstdc++.so.6.0.6
259
    gcc-4.0.3: libstdc++.so.6.0.7
260
    gcc-4.1.0: libstdc++.so.6.0.7
261
    gcc-4.1.1: libstdc++.so.6.0.8
262
    gcc-4.1.2: libstdc++.so.6.0.8
263
    gcc-4.2.0: libstdc++.so.6.0.9
264
    gcc-4.2.1: libstdc++.so.6.0.9 (See Note 3)
265
    gcc-4.2.2: libstdc++.so.6.0.9
266
    gcc-4.2.3: libstdc++.so.6.0.9
267
    gcc-4.2.4: libstdc++.so.6.0.9
268
    gcc-4.3.0: libstdc++.so.6.0.10
269
    gcc-4.3.1: libstdc++.so.6.0.10
270
    gcc-4.3.2: libstdc++.so.6.0.10
271
    gcc-4.3.3: libstdc++.so.6.0.10
272
    gcc-4.3.4: libstdc++.so.6.0.10
273
    gcc-4.4.0: libstdc++.so.6.0.11
274
    gcc-4.4.1: libstdc++.so.6.0.12
275
    gcc-4.4.2: libstdc++.so.6.0.13
276
    gcc-4.5.0: libstdc++.so.6.0.14
277
    
278
    
279
      Note 1: Error should be libstdc++.so.3.0.3.
280
    
281
    
282
      Note 2: Not strictly required.
283
    
284
    
285
      Note 3: This release (but not previous or subsequent) has one
286
      known incompatibility, see 
287
      url="http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33678">33678
288
      in the GCC bug database.
289
    
290
    
291
 
292
    Symbol versioning on the libstdc++.so binary.
293
 
294
    mapfile: libstdc++/config/linker-map.gnu
295
    It is versioned with the following labels and version
296
   definitions, where the version definition is the maximum for a
297
   particular release. Note, only symbol which are newly introduced
298
   will use the maximum version definition. Thus, for release series
299
   with the same label, but incremented version definitions, the later
300
   release has both versions. (An example of this would be the
301
   gcc-3.2.1 release, which has GLIBCPP_3.2.1 for new symbols and
302
   GLIBCPP_3.2 for symbols that were introduced in the gcc-3.2.0
303
   release.) If a particular release is not listed, it has the same
304
   version labels as the preceding release.
305
   
306
    
307
    gcc-3.0.0: (Error, not versioned)
308
    gcc-3.0.1: (Error, not versioned)
309
    gcc-3.0.2: (Error, not versioned)
310
    gcc-3.0.3: (Error, not versioned)
311
    gcc-3.0.4: (Error, not versioned)
312
    gcc-3.1.0: GLIBCPP_3.1, CXXABI_1
313
    gcc-3.1.1: GLIBCPP_3.1, CXXABI_1
314
    gcc-3.2.0: GLIBCPP_3.2, CXXABI_1.2
315
    gcc-3.2.1: GLIBCPP_3.2.1, CXXABI_1.2
316
    gcc-3.2.2: GLIBCPP_3.2.2, CXXABI_1.2
317
    gcc-3.2.3: GLIBCPP_3.2.2, CXXABI_1.2
318
    gcc-3.3.0: GLIBCPP_3.2.2, CXXABI_1.2.1
319
    gcc-3.3.1: GLIBCPP_3.2.3, CXXABI_1.2.1
320
    gcc-3.3.2: GLIBCPP_3.2.3, CXXABI_1.2.1
321
    gcc-3.3.3: GLIBCPP_3.2.3, CXXABI_1.2.1
322
    gcc-3.4.0: GLIBCXX_3.4, CXXABI_1.3
323
    gcc-3.4.1: GLIBCXX_3.4.1, CXXABI_1.3
324
    gcc-3.4.2: GLIBCXX_3.4.2
325
    gcc-3.4.3: GLIBCXX_3.4.3
326
    gcc-4.0.0: GLIBCXX_3.4.4, CXXABI_1.3.1
327
    gcc-4.0.1: GLIBCXX_3.4.5
328
    gcc-4.0.2: GLIBCXX_3.4.6
329
    gcc-4.0.3: GLIBCXX_3.4.7
330
    gcc-4.1.1: GLIBCXX_3.4.8
331
    gcc-4.2.0: GLIBCXX_3.4.9
332
    gcc-4.3.0: GLIBCXX_3.4.10, CXXABI_1.3.2
333
    gcc-4.4.0: GLIBCXX_3.4.11, CXXABI_1.3.3
334
    gcc-4.4.1: GLIBCXX_3.4.12, CXXABI_1.3.3
335
    gcc-4.4.2: GLIBCXX_3.4.13, CXXABI_1.3.3
336
    gcc-4.5.0: GLIBCXX_3.4.14, CXXABI_1.3.4
337
    
338
    
339
 
340
    
341
    Incremental bumping of a compiler pre-defined macro,
342
    __GXX_ABI_VERSION. This macro is defined as the version of the
343
    compiler v3 ABI, with g++ 3.0.x being version 100. This macro will
344
    be automatically defined whenever g++ is used (the curious can
345
    test this by invoking g++ with the '-v' flag.)
346
    
347
 
348
    
349
    This macro was defined in the file "lang-specs.h" in the gcc/cp directory.
350
    Later versions defined it in "c-common.c" in the gcc directory, and from
351
    G++ 3.4 it is defined in c-cppbuiltin.c and its value determined by the
352
    '-fabi-version' command line option.
353
    
354
 
355
    
356
    It is versioned as follows, where 'n' is given by '-fabi-version=n':
357
    
358
    
359
    gcc-3.0.x: 100
360
    gcc-3.1.x: 100 (Error, should be 101)
361
    gcc-3.2.x: 102
362
    gcc-3.3.x: 102
363
    gcc-3.4.x, gcc-4.[0-5].x: 102 (when n=1)
364
    gcc-3.4.x, gcc-4.[0-5].x: 1000 + n (when n>1) 
365
    gcc-3.4.x, gcc-4.[0-5].x: 999999 (when n=0)
366
    
367
    
368
    
369
 
370
    
371
    Changes to the default compiler option for
372
    -fabi-version.
373
    
374
   
375
    It is versioned as follows:
376
    
377
    
378
    gcc-3.0.x: (Error, not versioned) 
379
    gcc-3.1.x: (Error, not versioned) 
380
    gcc-3.2.x: -fabi-version=1
381
    gcc-3.3.x: -fabi-version=1
382
    gcc-3.4.x, gcc-4.[0-5].x: -fabi-version=2 (Incompatible with previous)
383
    
384
    
385
    
386
 
387
   
388
    Incremental bumping of a library pre-defined macro. For releases
389
    before 3.4.0, the macro is __GLIBCPP__. For later releases, it's
390
    __GLIBCXX__. (The libstdc++ project generously changed from CPP to
391
    CXX throughout its source to allow the "C" pre-processor the CPP
392
    macro namespace.) These macros are defined as the date the library
393
    was released, in compressed ISO date format, as an unsigned long.
394
    
395
 
396
    
397
    This macro is defined in the file "c++config" in the
398
    "libstdc++/include/bits" directory. (Up to gcc-4.1.0, it was
399
    changed every night by an automated script. Since gcc-4.1.0, it is
400
    the same value as gcc/DATESTAMP.)
401
    
402
    
403
    It is versioned as follows:
404
    
405
    
406
    gcc-3.0.0: 20010615
407
    gcc-3.0.1: 20010819
408
    gcc-3.0.2: 20011023
409
    gcc-3.0.3: 20011220
410
    gcc-3.0.4: 20020220
411
    gcc-3.1.0: 20020514
412
    gcc-3.1.1: 20020725
413
    gcc-3.2.0: 20020814
414
    gcc-3.2.1: 20021119
415
    gcc-3.2.2: 20030205
416
    gcc-3.2.3: 20030422
417
    gcc-3.3.0: 20030513
418
    gcc-3.3.1: 20030804
419
    gcc-3.3.2: 20031016
420
    gcc-3.3.3: 20040214
421
    gcc-3.4.0: 20040419
422
    gcc-3.4.1: 20040701
423
    gcc-3.4.2: 20040906
424
    gcc-3.4.3: 20041105
425
    gcc-3.4.4: 20050519
426
    gcc-3.4.5: 20051201
427
    gcc-3.4.6: 20060306
428
    gcc-4.0.0: 20050421
429
    gcc-4.0.1: 20050707
430
    gcc-4.0.2: 20050921
431
    gcc-4.0.3: 20060309
432
    gcc-4.1.0: 20060228
433
    gcc-4.1.1: 20060524
434
    gcc-4.1.2: 20070214
435
    gcc-4.2.0: 20070514
436
    gcc-4.2.1: 20070719
437
    gcc-4.2.2: 20071007
438
    gcc-4.2.3: 20080201
439
    gcc-4.2.4: 20080519
440
    gcc-4.3.0: 20080306
441
    gcc-4.3.1: 20080606
442
    gcc-4.3.2: 20080827
443
    gcc-4.3.3: 20090124
444
    gcc-4.4.0: 20090421
445
    gcc-4.4.1: 20090722
446
    gcc-4.4.2: 20091015
447
    
448
    
449
    
450
 
451
    
452
    
453
    Incremental bumping of a library pre-defined macro,
454
    _GLIBCPP_VERSION. This macro is defined as the released version of
455
    the library, as a string literal. This is only implemented in
456
    gcc-3.1.0 releases and higher, and is deprecated in 3.4 (where it
457
    is called _GLIBCXX_VERSION).
458
    
459
 
460
    
461
    This macro is defined in the file "c++config" in the
462
    "libstdc++/include/bits" directory and is generated
463
    automatically by autoconf as part of the configure-time generation
464
    of config.h.
465
    
466
 
467
    
468
    It is versioned as follows:
469
    
470
    
471
    gcc-3.0.0: "3.0.0"
472
    gcc-3.0.1: "3.0.0" (Error, should be "3.0.1")
473
    gcc-3.0.2: "3.0.0" (Error, should be "3.0.2")
474
    gcc-3.0.3: "3.0.0" (Error, should be "3.0.3")
475
    gcc-3.0.4: "3.0.0" (Error, should be "3.0.4")
476
    gcc-3.1.0: "3.1.0"
477
    gcc-3.1.1: "3.1.1"
478
    gcc-3.2.0: "3.2"
479
    gcc-3.2.1: "3.2.1"
480
    gcc-3.2.2: "3.2.2"
481
    gcc-3.2.3: "3.2.3"
482
    gcc-3.3.0: "3.3"
483
    gcc-3.3.1: "3.3.1"
484
    gcc-3.3.2: "3.3.2"
485
    gcc-3.3.3: "3.3.3"
486
    gcc-3.4.x: "version-unused"
487
    gcc-4.[0-5].x: "version-unused"
488
    
489
    
490
    
491
 
492
    
493
    
494
    Matching each specific C++ compiler release to a specific set of
495
    C++ include files. This is only implemented in gcc-3.1.1 releases
496
    and higher.
497
    
498
    
499
    All C++ includes are installed in include/c++, then nest in a
500
    directory hierarchy corresponding to the C++ compiler's released
501
    version. This version corresponds to the variable "gcc_version" in
502
    "libstdc++/acinclude.m4," and more details can be found in that
503
    file's macro GLIBCXX_CONFIGURE (GLIBCPP_CONFIGURE before gcc-3.4.0).
504
    
505
    
506
    C++ includes are versioned as follows:
507
    
508
    
509
    gcc-3.0.0: include/g++-v3
510
    gcc-3.0.1: include/g++-v3
511
    gcc-3.0.2: include/g++-v3
512
    gcc-3.0.3: include/g++-v3
513
    gcc-3.0.4: include/g++-v3
514
    gcc-3.1.0: include/g++-v3
515
    gcc-3.1.1: include/c++/3.1.1
516
    gcc-3.2.0: include/c++/3.2
517
    gcc-3.2.1: include/c++/3.2.1
518
    gcc-3.2.2: include/c++/3.2.2
519
    gcc-3.2.3: include/c++/3.2.3
520
    gcc-3.3.0: include/c++/3.3
521
    gcc-3.3.1: include/c++/3.3.1
522
    gcc-3.3.2: include/c++/3.3.2
523
    gcc-3.3.3: include/c++/3.3.3
524
    gcc-3.4.0: include/c++/3.4.0
525
    gcc-3.4.1: include/c++/3.4.1
526
    gcc-3.4.2: include/c++/3.4.2
527
    gcc-3.4.3: include/c++/3.4.3
528
    gcc-3.4.4: include/c++/3.4.4
529
    gcc-3.4.5: include/c++/3.4.5
530
    gcc-3.4.6: include/c++/3.4.6
531
    gcc-4.0.0: include/c++/4.0.0
532
    gcc-4.0.1: include/c++/4.0.1
533
    gcc-4.0.2: include/c++/4.0.2
534
    gcc-4.0.3: include/c++/4.0.3
535
    gcc-4.1.0: include/c++/4.1.0
536
    gcc-4.1.1: include/c++/4.1.1
537
    gcc-4.1.2: include/c++/4.1.2
538
    gcc-4.2.0: include/c++/4.2.0
539
    gcc-4.2.1: include/c++/4.2.1
540
    gcc-4.2.2: include/c++/4.2.2
541
    gcc-4.2.3: include/c++/4.2.3
542
    gcc-4.2.4: include/c++/4.2.4
543
    gcc-4.3.0: include/c++/4.3.0
544
    gcc-4.3.1: include/c++/4.3.1
545
    gcc-4.3.3: include/c++/4.3.3
546
    gcc-4.3.4: include/c++/4.3.4
547
    gcc-4.4.0: include/c++/4.4.0
548
    gcc-4.4.1: include/c++/4.4.1
549
    gcc-4.4.2: include/c++/4.4.2
550
    gcc-4.5.0: include/c++/4.5.0
551
    
552
    
553
    
554
  
555
 
556
557
  Taken together, these techniques can accurately specify interface
558
  and implementation changes in the GNU C++ tools themselves. Used
559
  properly, they allow both the GNU C++ tools implementation, and
560
  programs using them, an evolving yet controlled development that
561
  maintains backward compatibility.
562
563
 
564
 
565
  
566
 
567
  
568
    Prerequisites
569
    
570
      Minimum environment that supports a versioned ABI: A supported
571
      dynamic linker, a GNU linker of sufficient vintage to understand
572
      demangled C++ name globbing (ld), a shared executable compiled
573
      with g++, and shared libraries (libgcc_s, libstdc++) compiled by
574
      a compiler (g++) with a compatible ABI. Phew.
575
    
576
 
577
    
578
      On top of all that, an additional constraint: libstdc++ did not
579
      attempt to version symbols (or age gracefully, really) until
580
      version 3.1.0.
581
    
582
 
583
    
584
      Most modern Linux and BSD versions, particularly ones using
585
      gcc-3.1.x tools and more recent vintages, will meet the
586
      requirements above.
587
    
588
  
589
 
590
  
591
    Configuring
592
 
593
    
594
      It turns out that most of the configure options that change
595
      default behavior will impact the mangled names of exported
596
      symbols, and thus impact versioning and compatibility.
597
    
598
 
599
    
600
      For more information on configure options, including ABI
601
      impacts, see:
602
      http://gcc.gnu.org/onlinedocs/libstdc++/configopts.html
603
    
604
 
605
    
606
      There is one flag that explicitly deals with symbol versioning:
607
      --enable-symvers.
608
    
609
 
610
    
611
      In particular, libstdc++/acinclude.m4 has a macro called
612
      GLIBCXX_ENABLE_SYMVERS that defaults to yes (or the argument
613
      passed in via --enable-symvers=foo). At that point, the macro
614
      attempts to make sure that all the requirement for symbol
615
      versioning are in place. For more information, please consult
616
      acinclude.m4.
617
    
618
  
619
 
620
  
621
    Checking Active
622
 
623
    
624
      When the GNU C++ library is being built with symbol versioning
625
      on, you should see the following at configure time for
626
      libstdc++:
627
    
628
 
629
630
631
  checking versioning on shared library symbols... gnu
632
633
634
 
635
636
  If you don't see this line in the configure output, or if this line
637
  appears but the last word is 'no', then you are out of luck.
638
639
 
640
641
  If the compiler is pre-installed, a quick way to test is to compile
642
  the following (or any) simple C++ file and link it to the shared
643
  libstdc++ library:
644
645
 
646
647
#include <iostream>
648
 
649
int main()
650
{ std::cout << "hello" << std::endl; return 0; }
651
 
652
%g++ hello.cc -o hello.out
653
 
654
%ldd hello.out
655
        libstdc++.so.5 => /usr/lib/libstdc++.so.5 (0x00764000)
656
        libm.so.6 => /lib/tls/libm.so.6 (0x004a8000)
657
        libgcc_s.so.1 => /mnt/hd/bld/gcc/gcc/libgcc_s.so.1 (0x40016000)
658
        libc.so.6 => /lib/tls/libc.so.6 (0x0036d000)
659
        /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x00355000)
660
 
661
%nm hello.out
662
663
 
664
665
If you see symbols in the resulting output with "GLIBCXX_3" as part
666
of the name, then the executable is versioned. Here's an example:
667
668
 
669
670
   U _ZNSt8ios_base4InitC1Ev@@GLIBCXX_3.4
671
672
 
673
  
674
675
 
676
677
Allowed Changes
678
 
679
680
The following will cause the library minor version number to
681
increase, say from "libstdc++.so.3.0.4" to "libstdc++.so.3.0.5".
682
683
684
 Adding an exported global or static data member
685
 Adding an exported function, static or non-virtual member function
686
 Adding an exported symbol or symbols by additional instantiations
687
688
689
Other allowed changes are possible.
690
691
 
692
693
 
694
695
Prohibited Changes
696
 
697
698
The following non-exhaustive list will cause the library major version
699
number to increase, say from "libstdc++.so.3.0.4" to
700
"libstdc++.so.4.0.0".
701
702
 
703
704
 Changes in the gcc/g++ compiler ABI
705
Changing size of an exported symbol
706
Changing alignment of an exported symbol
707
Changing the layout of an exported symbol
708
Changing mangling on an exported symbol
709
Deleting an exported symbol
710
Changing the inheritance properties of a type by adding or removing
711
    base classes
712
713
  Changing the size, alignment, or layout of types
714
  specified in the C++ standard. These may not necessarily be
715
  instantiated or otherwise exported in the library binary, and
716
  include all the required locale facets, as well as things like
717
  std::basic_streambuf, et al.
718
719
 
720
 Adding an explicit copy constructor or destructor to a
721
class that would otherwise have implicit versions. This will change
722
the way the compiler deals with this class in by-value return
723
statements or parameters: instead of being passing instances of this
724
class in registers, the compiler will be forced to use memory. See  this part
725
 of the C++ ABI documentation for further details.
726
 
727
 
728
729
 
730
731
 
732
 
733
 
734
735
Implementation
736
 
737
738
 
739
   
740
     Separation of interface and implementation
741
   
742
   
743
     This is accomplished by two techniques that separate the API from
744
     the ABI: forcing undefined references to link against a library
745
     binary for definitions.
746
   
747
 
748
749
  
750
    Include files have declarations, source files have defines
751
 
752
    
753
      
754
        For non-templatized types, such as much of class
755
        locale, the appropriate standard C++ include, say
756
        locale, can contain full declarations, while
757
        various source files (say  locale.cc, locale_init.cc,
758
        localename.cc) contain definitions.
759
      
760
    
761
  
762
 
763
  
764
  Extern template on required types
765
 
766
   
767
     
768
       For parts of the standard that have an explicit list of
769
       required instantiations, the GNU extension syntax  extern
770
       template  can be used to control where template
771
       definitions reside. By marking required instantiations as
772
        extern template  in include files, and providing
773
       explicit instantiations in the appropriate instantiation files,
774
       non-inlined template functions can be versioned. This technique
775
       is mostly used on parts of the standard that require 
776
       char and  wchar_t instantiations, and
777
       includes  basic_string, the locale facets, and the
778
       types in  iostreams.
779
     
780
   
781
  
782
 
783
 
784
 
785
 
786
   In addition, these techniques have the additional benefit that they
787
   reduce binary size, which can increase runtime performance.
788
 
789
 
790
 
791
 
792
   
793
     Namespaces linking symbol definitions to export mapfiles
794
   
795
   
796
     All symbols in the shared library binary are processed by a
797
     linker script at build time that either allows or disallows
798
     external linkage. Because of this, some symbols, regardless of
799
     normal C/C++ linkage, are not visible. Symbols that are internal
800
     have several appealing characteristics: by not exporting the
801
     symbols, there are no relocations when the shared library is
802
     started and thus this makes for faster runtime loading
803
     performance by the underlying dynamic loading mechanism. In
804
     addition, they have the possibility of changing without impacting
805
     ABI compatibility.
806
   
807
 
808
The following namespaces are transformed by the mapfile:
809
 
810
811
 
812
  
813
namespace std
814
 Defaults to exporting all symbols in label
815
GLIBCXX that do not begin with an underscore, i.e.,
816
__test_func would not be exported by default. Select
817
exceptional symbols are allowed to be visible.
818
  
819
 
820
  
821
namespace __gnu_cxx
822
 Defaults to not exporting any symbols in label
823
GLIBCXX, select items are allowed to be visible.
824
  
825
 
826
  
827
namespace __gnu_internal
828
 Defaults to not exported, no items are allowed to be visible.
829
  
830
 
831
  
832
namespace __cxxabiv1, aliased to  namespace abi
833
 Defaults to not exporting any symbols in label
834
CXXABI, select items are allowed to be visible.
835
  
836
 
837
838
839
840
841
 
842
 Freezing the API
843
 Disallowed changes, as above, are not made on a stable release
844
branch. Enforcement tends to be less strict with GNU extensions that
845
standard includes.
846
847
848
 
849
850
 
851
852
Testing
853
 
854
  
855
    Single ABI Testing
856
 
857
    
858
      Testing for GNU C++ ABI changes is composed of two distinct
859
      areas: testing the C++ compiler (g++) for compiler changes, and
860
      testing the C++ library (libstdc++) for library changes.
861
    
862
 
863
    
864
      Testing the C++ compiler ABI can be done various ways.
865
    
866
 
867
    
868
      One.  Intel ABI checker.
869
    
870
 
871
872
Two.
873
The second is yet unreleased, but has been announced on the gcc
874
mailing list. It is yet unspecified if these tools will be freely
875
available, and able to be included in a GNU project. Please contact
876
Mark Mitchell (mark@codesourcery.com) for more details, and current
877
status.
878
879
 
880
881
Three.
882
Involves using the vlad.consistency test framework. This has also been
883
discussed on the gcc mailing lists.
884
885
 
886
887
Testing the C++ library ABI can also be done various ways.
888
889
 
890
891
One.
892
(Brendan Kehoe, Jeff Law suggestion to run 'make check-c++' two ways,
893
one with a new compiler and an old library, and the other with an old
894
compiler and a new library, and look for testsuite regressions)
895
896
 
897
898
Details on how to set this kind of test up can be found here:
899
http://gcc.gnu.org/ml/gcc/2002-08/msg00142.html
900
901
 
902
903
Two.
904
Use the 'make check-abi' rule in the libstdc++ Makefile.
905
906
 
907
908
This is a proactive check the library ABI. Currently, exported symbol
909
names that are either weak or defined are checked against a last known
910
good baseline. Currently, this baseline is keyed off of 3.4.0
911
binaries, as this was the last time the .so number was incremented. In
912
addition, all exported names are demangled, and the exported objects
913
are checked to make sure they are the same size as the same object in
914
the baseline.
915
 
916
Notice that each baseline is relative to a default
917
configured library and compiler: in particular, if options such as
918
--enable-clocale, or --with-cpu, in case of multilibs, are used at
919
configure time, the check may fail, either because of substantive
920
differences or because of limitations of the current checking
921
machinery.
922
923
 
924
925
This dataset is insufficient, yet a start. Also needed is a
926
comprehensive check for all user-visible types part of the standard
927
library for sizeof() and alignof() changes.
928
929
 
930
931
Verifying compatible layouts of objects is not even attempted.  It
932
should be possible to use sizeof, alignof, and offsetof to compute
933
offsets for each structure and type in the standard library, saving to
934
another datafile. Then, compute this in a similar way for new
935
binaries, and look for differences.
936
937
 
938
939
Another approach might be to use the -fdump-class-hierarchy flag to
940
get information. However, currently this approach gives insufficient
941
data for use in library testing, as class data members, their offsets,
942
and other detailed data is not displayed with this flag.
943
(See g++/7470 on how this was used to find bugs.)
944
945
 
946
947
Perhaps there are other C++ ABI checkers. If so, please notify
948
us. We'd like to know about them!
949
950
 
951
  
952
  
953
    Multiple ABI Testing
954
955
A "C" application, dynamically linked to two shared libraries, liba,
956
libb. The dependent library liba is C++ shared library compiled with
957
gcc-3.3.x, and uses io, exceptions, locale, etc. The dependent library
958
libb is a C++ shared library compiled with gcc-3.4.x, and also uses io,
959
exceptions, locale, etc.
960
961
 
962
 As above, libone is constructed as follows: 
963
964
%$bld/H-x86-gcc-3.4.0/bin/g++ -fPIC -DPIC -c a.cc
965
 
966
%$bld/H-x86-gcc-3.4.0/bin/g++ -shared -Wl,-soname -Wl,libone.so.1 -Wl,-O1 -Wl,-z,defs a.o -o libone.so.1.0.0
967
 
968
%ln -s libone.so.1.0.0 libone.so
969
 
970
%$bld/H-x86-gcc-3.4.0/bin/g++ -c a.cc
971
 
972
%ar cru libone.a a.o
973
974
 
975
 And, libtwo is constructed as follows: 
976
 
977
978
%$bld/H-x86-gcc-3.3.3/bin/g++ -fPIC -DPIC -c b.cc
979
 
980
%$bld/H-x86-gcc-3.3.3/bin/g++ -shared -Wl,-soname -Wl,libtwo.so.1 -Wl,-O1 -Wl,-z,defs b.o -o libtwo.so.1.0.0
981
 
982
%ln -s libtwo.so.1.0.0 libtwo.so
983
 
984
%$bld/H-x86-gcc-3.3.3/bin/g++ -c b.cc
985
 
986
%ar cru libtwo.a b.o
987
988
 
989
 ...with the resulting libraries looking like 
990
 
991
992
993
%ldd libone.so.1.0.0
994
        libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x40016000)
995
        libm.so.6 => /lib/tls/libm.so.6 (0x400fa000)
996
        libgcc_s.so.1 => /mnt/hd/bld/gcc/gcc/libgcc_s.so.1 (0x4011c000)
997
        libc.so.6 => /lib/tls/libc.so.6 (0x40125000)
998
        /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x00355000)
999
 
1000
%ldd libtwo.so.1.0.0
1001
        libstdc++.so.5 => /usr/lib/libstdc++.so.5 (0x40027000)
1002
        libm.so.6 => /lib/tls/libm.so.6 (0x400e1000)
1003
        libgcc_s.so.1 => /mnt/hd/bld/gcc/gcc/libgcc_s.so.1 (0x40103000)
1004
        libc.so.6 => /lib/tls/libc.so.6 (0x4010c000)
1005
        /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x00355000)
1006
1007
1008
 
1009
1010
  Then, the "C" compiler is used to compile a source file that uses
1011
  functions from each library.
1012
1013
1014
gcc test.c -g -O2 -L. -lone -ltwo /usr/lib/libstdc++.so.5 /usr/lib/libstdc++.so.6
1015
1016
 
1017
1018
  Which gives the expected:
1019
1020
 
1021
1022
1023
%ldd a.out
1024
        libstdc++.so.5 => /usr/lib/libstdc++.so.5 (0x00764000)
1025
        libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x40015000)
1026
        libc.so.6 => /lib/tls/libc.so.6 (0x0036d000)
1027
        libm.so.6 => /lib/tls/libm.so.6 (0x004a8000)
1028
        libgcc_s.so.1 => /mnt/hd/bld/gcc/gcc/libgcc_s.so.1 (0x400e5000)
1029
        /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x00355000)
1030
1031
1032
 
1033
1034
  This resulting binary, when executed, will be able to safely use
1035
  code from both liba, and the dependent libstdc++.so.6, and libb,
1036
  with the dependent libstdc++.so.5.
1037
1038
  
1039
1040
 
1041
1042
Outstanding Issues
1043
 
1044
1045
  Some features in the C++ language make versioning especially
1046
  difficult. In particular, compiler generated constructs such as
1047
  implicit instantiations for templates, typeinfo information, and
1048
  virtual tables all may cause ABI leakage across shared library
1049
  boundaries. Because of this, mixing C++ ABIs is not recommended at
1050
  this time.
1051
1052
 
1053
1054
  For more background on this issue, see these bugzilla entries:
1055
1056
 
1057
1058
24660: versioning weak symbols in libstdc++
1059
1060
 
1061
1062
19664: libstdc++ headers should have pop/push of the visibility around the declarations
1063
1064
 
1065
1066
 
1067
1068
Bibliography
1069
 
1070
  
1071
    
1072
      
1073
        
1074
          ABIcheck, a vague idea of checking ABI compatibility
1075
        
1076
      
1077
    
1078
  
1079
 
1080
  
1081
    
1082
      
1083
        
1084
          C++ ABI Reference
1085
        
1086
      
1087
    
1088
  
1089
 
1090
  
1091
    
1092
      
1093
        
1094
          Intel Compilers for Linux Compatibility with the GNU Compilers
1095
        
1096
      
1097
    
1098
  
1099
 
1100
  
1101
    
1102
      
1103
        
1104
          Sun Solaris 2.9 : Linker and Libraries Guide (document 816-1386)
1105
        
1106
      
1107
    
1108
  
1109
 
1110
 
1111
  
1112
    
1113
      
1114
        
1115
          Sun Solaris 2.9 : C++ Migration Guide (document 816-2459)
1116
        
1117
      
1118
    
1119
  
1120
 
1121
  
1122
    
1123
      
1124
        
1125
          How to Write Shared Libraries
1126
        
1127
      
1128
    
1129
 
1130
    
1131
      Ulrich
1132
      Drepper
1133
    
1134
  
1135
 
1136
  
1137
    
1138
      
1139
        
1140
          C++ ABI for the ARM Architecture
1141
        
1142
      
1143
    
1144
  
1145
 
1146
  
1147
    
1148
      
1149
        
1150
          Dynamic Shared Objects: Survey and Issues
1151
        
1152
      
1153
    
1154
    
1155
      ISO C++ J16/06-0046
1156
    
1157
    
1158
      Benjamin
1159
      Kosnik
1160
    
1161
  
1162
 
1163
  
1164
    
1165
      
1166
        
1167
          Versioning With Namespaces
1168
        
1169
      
1170
    
1171
    
1172
      ISO C++ J16/06-0083
1173
    
1174
    
1175
      Benjamin
1176
      Kosnik
1177
    
1178
  
1179
 
1180
  
1181
    
1182
      
1183
        
1184
          Binary Compatibility of Shared Libraries Implemented in C++
1185
          on GNU/Linux Systems
1186
        
1187
      
1188
    
1189
    
1190
      SYRCoSE 2009
1191
    
1192
    
1193
      Pavel
1194
      Shved
1195
    
1196
    
1197
      Denis
1198
      Silakov
1199
    
1200
  
1201
1202
 
1203

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.