help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Explicit Template Instantiation


From: Garrett Kajmowicz
Subject: Re: Explicit Template Instantiation
Date: Wed, 01 Dec 2004 12:26:48 -0500
User-agent: Pan/0.14.2 (This is not a psychotic episode. It's a cleansing moment of clarity.)

> Post a better explanation of what you are trying to do, preferably
> a minimal test case. Do mention your target platform as well.

Long version:

I am attempting to implement the standard C++ library for embedded systems
(cxx.uclibc.org).  So far so good.  Most of the code is in templates.  As
such, I'm trying to instantiate as much of the likely code (such as
std::string) into the library itself so that there is less code
duplication.  This works for much, but not all, of the code.

For example, in a test piece of code that I have, I have a version in the
library and a version compiled into the executable after linking.  There
are also minor differences in the assembler code which I cannot account
for.

The following code is for
std::basic_ios<char, std::char_traits<char> >::~basic_ios()
on AMD Athlon x86 architecture.

C++ code:

virtual ~basic_ios(){ }
~ios_base() { }
~Init() is forced into the library (by me) because it isn't a template

Library code version:
00007bc8 <_ZNSt9basic_iosIcSt11char_traitsIcEED1Ev>:
    7bc8:       55                      push   %ebp
    7bc9:       89 e5                   mov    %esp,%ebp
    7bcb:       8b 45 08                mov    0x8(%ebp),%eax
    7bce:       53                      push   %ebx
    7bcf:       e8 20 f3 ff ff          call   6ef4 <__i686.get_pc_thunk.bx>
    7bd4:       81 c3 14 fc 00 00       add    $0xfc14,%ebx
    7bda:       8b 93 d4 ff ff ff       mov    0xffffffd4(%ebx),%edx
    7be0:       83 c2 08                add    $0x8,%edx
    7be3:       89 10                   mov    %edx,(%eax)
    7be5:       83 c0 14                add    $0x14,%eax
    7be8:       50                      push   %eax
    7be9:       e8 b2 f0 ff ff          call   6ca0 
<_ZNSt8ios_base4InitD1Ev@plt>
    7bee:       5a                      pop    %edx
    7bef:       8b 5d fc                mov    0xfffffffc(%ebp),%ebx
    7bf2:       c9                      leave
    7bf3:       c3                      ret


Application code version:
0804ad5c <_ZNSt9basic_iosIcSt11char_traitsIcEED1Ev>:
 804ad5c:       55                      push   %ebp
 804ad5d:       89 e5                   mov    %esp,%ebp
 804ad5f:       8b 45 08                mov    0x8(%ebp),%eax
 804ad62:       53                      push   %ebx
 804ad63:       e8 85 0f 00 00          call   804bced <__i686.get_pc_thunk.bx>
 804ad68:       81 c3 d8 2a 00 00       add    $0x2ad8,%ebx
 804ad6e:       8b 93 f0 ff ff ff       mov    0xfffffff0(%ebx),%edx
 804ad74:       83 c2 08                add    $0x8,%edx
 804ad77:       89 10                   mov    %edx,(%eax)
 804ad79:       83 c0 14                add    $0x14,%eax
 804ad7c:       50                      push   %eax
 804ad7d:       e8 42 f0 ff ff          call   8049dc4 
<_ZNSt8ios_base4InitD1Ev@plt>
 804ad82:       eb 06                   jmp    804ad8a 
<_ZNSt9basic_iosIcSt11char_traitsIcEED1Ev+0x2e>
 804ad84:       50                      push   %eax
 804ad85:       e8 5a f0 ff ff          call   8049de4 <_Unwind_Resume@plt>
 804ad8a:       58                      pop    %eax
 804ad8b:       8b 5d fc                mov    0xfffffffc(%ebp),%ebx
 804ad8e:       c9                      leave
 804ad8f:       c3                      ret

Why is the version in the application actually there?  Why is it
different from the library code?
How do I get the application to use the library version?

Thank you for your help.

-       Garrett Kajmowicz





reply via email to

[Prev in Thread] Current Thread [Next in Thread]