C++ pure virtual base class memory consumption

Pedro Alves alves.ped@gmail.com
Mon Aug 27 14:34:00 GMT 2012


On 08/22/2012 08:28 AM, Sebastian Huber wrote:
> On 08/21/2012 08:39 PM, fueb wrote:
>>
>>
>> Sebastian Huber-4 wrote:
>>>
>>> Are you sure this code is from Newlib and not GCC?
>>>
>>
>> I think the code is being inserted by GCC and in turn many things from
>> newlib get linked in.
>> ../arm-none-eabi/lib/thumb2\libstdc++.a(pure.o)
>> ../arm-none-eabi/lib/thumb2\libstdc++.a(eh_terminate.o)
>> ../arm-none-eabi/lib/thumb2\libstdc++.a(eh_call.o)
>> ../arm-none-eabi/lib/thumb2\libstdc++.a(eh_exception.o)
>>
>> and may other things I cannot post here since the mapfile is quite large.
> 
> The libstdc++ is not from newlib.  It is provided by GCC.  You should produce two map files, with and without the pure virtual function.  Compare the two map files and look at the additional modules.  It is very likely the unwinder and the exception handling support code.

Back when I was doing embedded stuff eons ago, I used to trim all that by
providing my own lean implementation of __cxa_pure_virtual (and others I
don't recall right now -- look at the map file for hints), the hook libstdc++ calls
when a pure virtual is called.  The default one pulls in a lot of that stuff you
don't want.  Doing a web search on that function name finds other people doing
the same.  E.g.,

 http://f.osdev.org/viewtopic.php?f=1&t=10798

-- 
Pedro Alves



More information about the Newlib mailing list