avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [avr-gcc-list] 'avr-size' strange thing...


From: Dave Hylands
Subject: RE: [avr-gcc-list] 'avr-size' strange thing...
Date: Wed, 17 Mar 2004 14:41:48 -0800

Hi John,

The size of .text in a.out = the size of .text from each of your .o
files + the size of the .text from your .a's (including the C run time
library).

To see the detailed breakdown, print a map file.

For example: I created a hello.c file with:
----- Start of hello.c -----
#include <stdio.h>

int main()
{
   printf( "Hello World\nn" );
   return 0;
}
----- End of hello.c -----

avr-gcc -o hello.o -c hello.c
avr-gcc -o hello.out -Wl,-Map,hello.map hello.o

avr-size hello.o    produces:
   text    data     bss     dec     hex filename
     28      14       0      42      2a hello.o

avr-size hello.out  produces:
   text    data     bss     dec     hex filename
   2638      20      10    2668     a6c hello.out

The difference of 2610 bytes all comes from the C runtime library (how
much is attributeed to what can be seen by looking at hello.map).

For example, here's a snippet from the .map file:

 .text          0x00000052       0x1c hello.o
                0x00000052                main
 .text          0x0000006e       0x2c
c:\WinAVR\bin\..\lib\gcc-lib\avr\3.3.1\..\..\..\..\avr\lib\libc.a(printf
.o)
                0x0000006e                printf
 .text          0x0000009a      0x596
c:\WinAVR\bin\..\lib\gcc-lib\avr\3.3.1\..\..\..\..\avr\lib\libc.a(vfprin
tf_std.o)
                0x0000009a                vfprintf

So we see that hello.o takes up 0x1c bytes (the 28 that avr-size
reported), printf takes up 0x2c bytes, vprintf takes up 0x596 bytes,
etc. When you add up all of the support stuff you get 2610 extra bytes.

--
Dave Hylands
Vancouver, BC, Canada
http://www.DaveHylands.com/


> -----Original Message-----
> From: address@hidden 
> [mailto:address@hidden On Behalf Of John Yannakopoulos
> Sent: Wednesday, March 17, 2004 5:42 AM
> To: Ned Konz
> Cc: address@hidden
> Subject: Re: [avr-gcc-list] 'avr-size' strange thing...
> 
> 
> 
> Hi Ned, thanks for your response.
> 
> I fixed the problem, but I still cannot have a confident explanation.
> 
> I was creating an archive (avr-ar, avr-ranlib) of a library 
> and then I was linking this archive against my main.c file. 
> In that case I was having the problem desribed in my previous e-mail.
> 
> E.g. I had:
> 1) avr-ar rcv libtrxdrv.a ADC_driver.o LCD_driver.o RF_driver.o
> 2) avr-ranlib libtrxdrv.a
> 3) avr-gcc $(FLAGS) main.c -L./ -ltrxdrv
> 
> This problem disappeared when I linked the object files 
> together with the object file of the main.c file (natively), e.g.:
> 
> avr-gcc $(FLAGS) ADC_driver.o LCD_driver.o RF_driver.o main.o
> 
> 
> What's going on here? Is it likely that at the executable 
> file the compiler fills in the Undefined symbols denoted in 
> your e-mail for each object file, and thus the final image's 
> size is almost twofold? Can you propose an explanation for this?
> 
> Best regards,
> 
> --
> John Yannakopoulos.


_______________________________________________
avr-gcc-list mailing list
address@hidden
http://www.avr1.org/mailman/listinfo/avr-gcc-list


reply via email to

[Prev in Thread] Current Thread [Next in Thread]