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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libstdc++-v3/] [doc/] [xml/] [manual/] [abi.xml] - Blame information for rev 742

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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