public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* readelf/objdump segment size doesn't match symbol table sizes
@ 2006-08-10 20:08 showard
  2006-08-10 21:02 ` Daniel Jacobowitz
  0 siblings, 1 reply; 9+ messages in thread
From: showard @ 2006-08-10 20:08 UTC (permalink / raw)
  To: binutils


Hello,

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:


.text   6060
.data        4
.bss     116 


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. 

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!
-- 
View this message in context: http://www.nabble.com/readelf-objdump-segment-size-doesn%27t-match-symbol-table-sizes-tf2086556.html#a5750717
Sent from the Sourceware - binutils list forum at Nabble.com.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: readelf/objdump segment size doesn't match symbol table sizes
  2006-08-10 20:08 readelf/objdump segment size doesn't match symbol table sizes showard
@ 2006-08-10 21:02 ` Daniel Jacobowitz
  2006-08-10 21:47   ` showard
  0 siblings, 1 reply; 9+ messages in thread
From: Daniel Jacobowitz @ 2006-08-10 21:02 UTC (permalink / raw)
  To: showard; +Cc: binutils

On Thu, Aug 10, 2006 at 12:19:16PM -0700, showard wrote:
> 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???

Alignment: empty padding space between symbols.  Also, potentially,
symbols whose sizes are not set; anything with st_size == 0 is somewhat
suspect.

-- 
Daniel Jacobowitz
CodeSourcery

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: readelf/objdump segment size doesn't match symbol table sizes
  2006-08-10 21:02 ` Daniel Jacobowitz
@ 2006-08-10 21:47   ` showard
  2006-08-11 12:43     ` Daniel Jacobowitz
  0 siblings, 1 reply; 9+ messages in thread
From: showard @ 2006-08-10 21:47 UTC (permalink / raw)
  To: binutils


>Alignment: empty padding space between symbols.

Is there any good way to account for this padding? I am trying to reconcile
the figures. What I want to know is that when readelf reports that a
particular function takes up x number of bytes of memory, then it indeed
uses that number of bytes, and not more.

>Also, potentially, symbols whose sizes are not set; anything with st_size
== 0 is somewhat
suspect.

Meaning that the sizes of these symbols will be determined at runtime?

Stefen Howard



-- 
View this message in context: http://www.nabble.com/readelf-objdump-segment-size-doesn%27t-match-symbol-table-sizes-tf2086556.html#a5753044
Sent from the Sourceware - binutils list forum at Nabble.com.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: readelf/objdump segment size doesn't match symbol table sizes
  2006-08-10 21:47   ` showard
@ 2006-08-11 12:43     ` Daniel Jacobowitz
  2006-08-11 19:41       ` showard
  0 siblings, 1 reply; 9+ messages in thread
From: Daniel Jacobowitz @ 2006-08-11 12:43 UTC (permalink / raw)
  To: showard; +Cc: binutils

On Thu, Aug 10, 2006 at 02:38:38PM -0700, showard wrote:
> 
> >Alignment: empty padding space between symbols.
> 
> Is there any good way to account for this padding? I am trying to reconcile
> the figures. What I want to know is that when readelf reports that a
> particular function takes up x number of bytes of memory, then it indeed
> uses that number of bytes, and not more.

Sorry, the question doesn't make any sense.  I think you don't have
enough context on what a symbol is, and what its size means - basically
nothing.  It's informative only.  You can use it for measurement, but
not to e.g. copy the code around.

> >Also, potentially, symbols whose sizes are not set; anything with st_size
> == 0 is somewhat
> suspect.
> 
> Meaning that the sizes of these symbols will be determined at runtime?

Symbol tables are never used at runtime and symbol sizes are almost
never needed at runtime.  Everything in the loading process is handled
by the program header table.

-- 
Daniel Jacobowitz
CodeSourcery

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: readelf/objdump segment size doesn't match symbol table sizes
  2006-08-11 12:43     ` Daniel Jacobowitz
@ 2006-08-11 19:41       ` showard
  2006-08-16 17:46         ` Daniel Jacobowitz
  0 siblings, 1 reply; 9+ messages in thread
From: showard @ 2006-08-11 19:41 UTC (permalink / raw)
  To: binutils



Daniel Jacobowitz-2 wrote:
> 
> On Thu, Aug 10, 2006 at 02:38:38PM -0700, showard wrote:
>> 
>> >Alignment: empty padding space between symbols.
>> 
>> Is there any good way to account for this padding? I am trying to
>> reconcile
>> the figures. What I want to know is that when readelf reports that a
>> particular function takes up x number of bytes of memory, then it indeed
>> uses that number of bytes, and not more.
> 
> Sorry, the question doesn't make any sense.  I think you don't have
> enough context on what a symbol is, and what its size means - basically
> nothing.  It's informative only.  You can use it for measurement, but
> not to e.g. copy the code around.
> 
> I'm not trying to copy the code around, but I do want to have an accurate
> picture of how much memory my functions use since I am programming for
> resource challenged telos sensor motes. Let's see if this question makes
> more sense:
> 
> If I write a function called 'xyz()' and the compiler does not optimize
> this function out by, say, inlining, then there will be a symbol table
> entry with the name 'xyz' right? If so, does the size reported by readelf
> for this symbol refer to the size of the generated code for the function
> 'xyz()'?
> 
>> >Also, potentially, symbols whose sizes are not set; anything with
>> st_size
>> == 0 is somewhat
>> suspect.
>> 
>> Meaning that the sizes of these symbols will be determined at runtime?
> 
> Symbol tables are never used at runtime and symbol sizes are almost
> never needed at runtime.  Everything in the loading process is handled
> by the program header table.
> 
> So, what was meant by saying that a symbol 'with st_size== 0 is somewhat
> suspect'?
> 
> Stefen Howard
> 

-- 
View this message in context: http://www.nabble.com/readelf-objdump-segment-size-doesn%27t-match-symbol-table-sizes-tf2086556.html#a5768316
Sent from the Sourceware - binutils list forum at Nabble.com.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: readelf/objdump segment size doesn't match symbol table sizes
  2006-08-11 19:41       ` showard
@ 2006-08-16 17:46         ` Daniel Jacobowitz
  2007-02-09  5:14           ` hssathya
  0 siblings, 1 reply; 9+ messages in thread
From: Daniel Jacobowitz @ 2006-08-16 17:46 UTC (permalink / raw)
  To: showard; +Cc: binutils

On Fri, Aug 11, 2006 at 12:39:33PM -0700, showard wrote:
> > If I write a function called 'xyz()' and the compiler does not optimize
> > this function out by, say, inlining, then there will be a symbol table
> > entry with the name 'xyz' right? If so, does the size reported by readelf
> > for this symbol refer to the size of the generated code for the function
> > 'xyz()'?

Generally yes.  It won't account for the fact that the function code is
aligned to some number of bytes, though.

> > So, what was meant by saying that a symbol 'with st_size== 0 is somewhat
> > suspect'?

Symbols generally don't have size zero.  That usually means nothing set
the size of the symbol to a useful value.

-- 
Daniel Jacobowitz
CodeSourcery

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: readelf/objdump segment size doesn't match symbol table sizes
  2006-08-16 17:46         ` Daniel Jacobowitz
@ 2007-02-09  5:14           ` hssathya
  2007-02-09 20:45             ` Khem Raj
  2007-02-14  9:49             ` Nick Clifton
  0 siblings, 2 replies; 9+ messages in thread
From: hssathya @ 2007-02-09  5:14 UTC (permalink / raw)
  To: binutils


Hi,

I have a doubt. I want to run a function through debugger. What exactly i
want to do is i want to point PC (Program counter ) to start of the function
and then put a break point at the end of the fucntion, so that when i say
"go" PC should start incrementing form that function and should break when
it reaches the break point. Form readelf i can get the starting address of
the function, but how to get the end address of a function.

Is the size in the readelf output is size of the function or what?

Is there any other way to know the size of the function?


-- 
View this message in context: http://www.nabble.com/readelf-objdump-segment-size-doesn%27t-match-symbol-table-sizes-tf2086556.html#a8880471
Sent from the Sourceware - binutils list mailing list archive at Nabble.com.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: readelf/objdump segment size doesn't match symbol table sizes
  2007-02-09  5:14           ` hssathya
@ 2007-02-09 20:45             ` Khem Raj
  2007-02-14  9:49             ` Nick Clifton
  1 sibling, 0 replies; 9+ messages in thread
From: Khem Raj @ 2007-02-09 20:45 UTC (permalink / raw)
  To: hssathya; +Cc: binutils

hssathya wrote:
> Hi,
>
> I have a doubt. I want to run a function through debugger. What exactly i
> want to do is i want to point PC (Program counter ) to start of the function
> and then put a break point at the end of the fucntion, so that when i say
> "go" PC should start incrementing form that function and should break when
> it reaches the break point. Form readelf i can get the starting address of
> the function, but how to get the end address of a function.
>
> Is the size in the readelf output is size of the function or what?
>
> Is there any other way to know the size of the function?
>
>
>   
when you dump symbol table readelf -s then the third column will show 
the size this added to your start address should give you end of 
function. You can also use objdump -d to disassemble your binary and 
then check for the function start and end addresses.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: readelf/objdump segment size doesn't match symbol table sizes
  2007-02-09  5:14           ` hssathya
  2007-02-09 20:45             ` Khem Raj
@ 2007-02-14  9:49             ` Nick Clifton
  1 sibling, 0 replies; 9+ messages in thread
From: Nick Clifton @ 2007-02-14  9:49 UTC (permalink / raw)
  To: hssathya; +Cc: binutils

Hi Hssathya,

> I have a doubt. I want to run a function through debugger. What exactly i
> want to do is i want to point PC (Program counter ) to start of the function
> and then put a break point at the end of the fucntion, so that when i say
> "go" PC should start incrementing form that function and should break when
> it reaches the break point.

If you are using GDB then you can use the "finish" command to execute 
until the end of the current function.  Alternative you can use the "up" 
command to go up one stack level and then the "break" command to set a 
break point in the parent function.

Cheers
   Nick


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2007-02-14  9:41 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-08-10 20:08 readelf/objdump segment size doesn't match symbol table sizes showard
2006-08-10 21:02 ` Daniel Jacobowitz
2006-08-10 21:47   ` showard
2006-08-11 12:43     ` Daniel Jacobowitz
2006-08-11 19:41       ` showard
2006-08-16 17:46         ` Daniel Jacobowitz
2007-02-09  5:14           ` hssathya
2007-02-09 20:45             ` Khem Raj
2007-02-14  9:49             ` Nick Clifton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).