This is the mail archive of the ecos-discuss@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: where is my memory (.bss) used ? size vs. nm


"Neundorf, Alexander" <Alexander.Neundorf@jenoptik.com> writes:

> Hi,
> 
> I thought I'd check the memory requirements of a small application:
> 
> $ arm-elf-size smallapp
>    text    data     bss     dec     hex filename
>  172171    3032   16940  192143   2ee8f Project
> 
> Ok, bss is 16940 bytes. So who uses them ?
> 
> $ arm-elf-nm -S -C -r --size-sort smallapp
> 0004bd8c 00002000 B stack
> 000387b8 00001010 T vfnprintf
> 00024138 00000e7c t _vprintf(void (*)(char, void**), void**, ...
> 0003b658 00000b50 t construct_converter(Cyg_Clock::converter*,...
> 00041960 0000099c T Cyg_Mempool_dlmalloc_Implementation::resize_alloc(...
> 00037728 0000090c T Cyg_Condition_Variable::wait_inner(Cyg_Mutex*)
> 000336dc 000005f0 T Cyg_Mbox::put(void*, unsigned long long)
> 0003f334 000005d8 T realloc
> ...
> 
> This gave me a long list of information, so I wrote a small script (in ruby, you can find it in the attachement) to add all the sizes which go in the .bss section, marked with a "B":
> 
> $ arm-elf-nm -S -C -r --size-sort Project | ruby add.rb
> bss size: 10120
> 
> Hmm, the sum of all sizes which go to .bss is 6000 bytes less then the size reported by arm-elf-size. 
> Can you enlighten me how to interpret these data ?


Not everything that goes into BSS has a size in the nm output. For
example:

$ arm-elf-size null 
   text    data     bss     dec     hex filename
  36068    2736    8772   47576    b9d8 null

$ arm-elf-nm -Sn null

...
0004979c A __bss_start
000497a0 b __exception_stack_base
00049820 b __exception_stack
000498a0 B cyg_interrupt_stack_base
000498a0 b __interrupt_stack_base
000498a0 b __undef_exception_stack
0004a8a0 B cyg_interrupt_stack
0004a8a0 b __interrupt_stack
0004a8a0 b irq_level
0004a8b0 b __GDB_stack_base
0004a8b0 b __startup_stack_base
0004aab0 b __GDB_stack
0004aab0 b __startup_stack
0004aab0 0000000c b tty_private_info_diag
0004aabc 00000004 b _no_data
0004aac0 00000004 B __mem_fault_handler
0004aac4 00000004 b period
0004aac8 00000004 B hal_saved_interrupt_state
0004aacc 00000004 B _cyg_hal_compiler_dummy
0004aad0 00000064 b _ZZ9trim_filePKcE5fbuf2
0004ab34 00000078 b _ZZ9trim_funcPKcE4fbuf
0004abac 00000064 b _ZZ9trim_funcPKcE4fbuf
0004ac10 00000004 b cyg_kapi_check_structure_sizes
0004ac14 00000004 B idle_thread_loops
0004ac18 00000800 b idle_thread_stack
0004b418 000000a0 B idle_thread
0004b4b8 00000008 B _ZN10Cyg_Thread17exception_controlE
0004b4c0 00000004 B _ZN13Cyg_Interrupt26interrupt_disable_spinlockE
0004b4c4 00000004 B _ZN13Cyg_Interrupt8dsr_listE
0004b4c8 00000004 B _ZN28Cyg_Scheduler_Implementation15timeslice_countE
0004b4cc 00000004 B _ZN18Cyg_Scheduler_Base14current_threadE
0004b4d0 00000004 B _ZN18Cyg_Scheduler_Base15need_rescheduleE
0004b4d4 00000084 B _ZN13Cyg_Scheduler9schedulerE
0004b558 00000004 B _ZN18Cyg_Scheduler_Base15thread_switchesE
0004b55c 0000003c b _ZZ14dbg_threadinfoE8statebuf
0004b598 00000414 B cygmem_pool_heap1
0004b9ac 00000034 B _ZN17Cyg_RealTimeClock3rtcE
0004b9e0 A __bss_end
0004b9e0 A _end
0004b9e0 A __heap1


The sizes even add up correctly:

0x0004b9e0 - 0x0004979c = 0x2244 = 8772

The things missing sizes are those things defined in
assembler. Presumably extra directives are needed to define the sizes
in the debug info or symbol table.

-- 
Nick Garnett                                          eCos Kernel Architect
http://www.ecoscentric.com                     The eCos and RedBoot experts
Besuchen Sie uns vom 14.-16.02.06 auf der Embedded World 2006, Stand 11-222
Visit us at Embedded World 2006, NÃrnberg, Germany, 14-16 Feb, Stand 11-222


--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]