If I have a simple program...

#include <stdio.h>
   
int main(void)
{
   printf("hello world\n");
   return 0;
}

and compile it to object (gcc -c...) then run size and
objdump on them

$ gcc -W -Wall -c hello_world-1.c
$ gcc -o hello_world-1  hello_world-1.o

$ size hello_world-1 hello_world-1.o 
   text   data   bss    dec   hex   filename
    916    256     4   1176   498   hello_world-1
     48      0     0     48    30   hello_world-1.o

and

$ objdump -h hello_world-1.o 
   
   hello_world-1.o:     file format elf32-i386
   
   Sections:
   Idx Name          Size      VMA       LMA      
File off  Algn
     0 .text         00000023  00000000  00000000 
00000034  2**2
                     CONTENTS, ALLOC, LOAD, RELOC,
READONLY, CODE
     1 .data         00000000  00000000  00000000 
00000058  2**2
                     CONTENTS, ALLOC, LOAD, DATA
     2 .bss          00000000  00000000  00000000 
00000058  2**2
                     ALLOC
     3 .rodata       0000000d  00000000  00000000 
00000058  2**0
                     CONTENTS, ALLOC, LOAD, READONLY,
DATA
     4 .note.GNU-stack 00000000  00000000  00000000 
00000065  2**0
                     CONTENTS, READONLY
     5 .comment      0000001b  00000000  00000000 
00000065  2**0
                     CONTENTS, READONLY


You see that objdump object file says text is size 23,
while size says it's 48. There's a 25 byte
discrepency. Why? It seems to be the exact size of the
entire printf... line in the code (plus a \0?). Any ideas?

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com