cancel
Showing results for 
Search instead for 
Did you mean: 

size and objdmp command output

tanmay patil
Occasional Advisor

size and objdmp command output

Hi ,

I am trying to analyse and reduce the memory taken by application
If i do size on object file a.o
it shows me
text data bss dec hex filename
675579 633574 0 1309153 13f9e1 a.o

I want to know what constitutes data
So i am using nm/objdump command
But if i sum the size i do not get to 633574.
How do i map data section with program variables . Even with objdmp i am not getting much info.

[charaka][FC102B2BT1]/users3/e51569> grep "OBJ.*GLOB" | grep data <
[82] | 0| 8|OBJT |GLOB |0| .data|_ZTI13ISerializable
[91] | 0| 8|OBJT |GLOB |0| .data|_ZTI15IHashListErrors
[93] | 0| 12|OBJT |GLOB |0| .data|_ZTI15IListCollection
[88] | 0| 32|OBJT |GLOB |0| .data|_ZTI20IPowerHashVectorList
[85] | 0| 12|OBJT |GLOB |0| .data|_ZTI9IHashable

3 REPLIES
Dennis Handly
Acclaimed Contributor

Re: size and objdmp command output

You should not be using foreign devil linker tools. Stick with the ones in /usr/ccs/bin.

>I want to know what constitutes data

Anything that is R/W and initialized.

>But if I sum the size I do not get to 633574.

Why would expect this? There is padding and alignment. And static variables with no names.

You may be able to get an estimate by:
nm -xv # -v to sort by value

elfdump has options to dump sections:
elfdump -S -h

>How do I map data section with program variables?

Just look at the symbols in the various data areas: .data, .sdata, etc.

.data 00000000 .data
.data 00000008 typeinfo X
.data 00000070 vtable for X
.data 0000000c typeinfo for Y

C++ class metadata.


tanmay patil
Occasional Advisor

Re: size and objdmp command output

On IBM platform same .o is occupying less size
size -f a.o
bauu9535.o: 20112(.text) + 45984(.data) + 0(.bss) = 66096

Dennis Handly
Acclaimed Contributor

Re: size and objdmp command output

>On IBM platform same .o is occupying less size

You can't compare object files, you must compare shlibs. (HP-UX has a lot of duplicate template info that is removed at link time.)