total size of segments reported by Readelf/Objdump doesn't match symbol table sizes
I am sorry about the length of this post, but my problem takes a good bit of explanation.
I am using msp430-readelf and msp430-objdump to get information about the sizes of functions and global variables from the executable generated by compiling a tinyOS application. But, I am having trouble reconciling the segment sizes (.text, .bss, and .data) reported by readelf and objdump with the sizes of the individual objects as reported by 'readelf -s'
For example, I have an executable called 'main.exe'. objdump and readelf both report the following segment sizes:
when I have readelf display the symbol table entries with 'msp430-readelf -s main.exe', I get something like this fragment below. A '1' in the 'Ndx' column indicates that this belongs to the .text section while '2' and '6' indicate .data and .bss sections, respectively.
(obviously, this is not HTML code, but I couldn't get it formatted right without doing this)
Symbol table '.symtab' contains 336 entries:
Num: Value Size Type Bind Vis Ndx Name
255: 00004e3e 76 FUNC LOCAL DEFAULT 1 SenseTaskM$processData
256: 00001104 2 OBJECT LOCAL DEFAULT 6 i.0
257: 00001102 2 OBJECT LOCAL DEFAULT 2 sum.1
258: 00001106 2 OBJECT LOCAL DEFAULT 6 sum.2
259: 0000547e 182 FUNC LOCAL DEFAULT 1 SenseTaskM$display
260: 00004e8a 14 FUNC LOCAL DEFAULT 1 InternalTempM$MSP430ADC12Multiple..
261: 0000556a 272 FUNC LOCAL DEFAULT 1 ADCM$triggerConversion
262: 00005778 24 FUNC LOCAL DEFAULT 1 RefVoltM$switchOffDelay
263: 00005790 24 FUNC LOCAL DEFAULT 1 RefVoltM$switchOffRetry
264: 00000000 0 FILE LOCAL DEFAULT ABS /home/showard/research/tos/....
265: 00001108 1 OBJECT GLOBAL DEFAULT 6 SenseTaskM$head
266: 0000110a 2 OBJECT GLOBAL DEFAULT 6 MSP430DCOCalibM$m_prev
267: 0000110c 24 OBJECT GLOBAL DEFAULT 6 TimerM$m_timers
When I sum the numbers in the 'size' column that also have a '1' in the 'Ndx' column, I get 5960 instead of 6060. Also, when I sum the 'size' column figures that have a '2' in the 'Ndx' column, I get 3 instead of 4, and for the 'Ndx' column value of '6', I get 112 instead of 116.
I have generated these sums automatically using a simple program I wrote and, to verify the values, I summed them by hand. In both cases, I got the same values. This seems to say that there is "stuff" in these sections that contribute to the size which is not in the symbol table. But, I can't find any information about this anywhere. However, for some applications, some of the values match.
Does anybody have any idea why these figures don't match???
I don't think that the fact that I am working with tinyOS and nesC is important, but I mention it just in case.
Thanks for any help that can be provided!