Re: Why does my executable size not change?

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

 



richardcavell@xxxxxxxx writes:

> I'm compiling using gcc -std=c99 -pedantic -Wall -Wextra, no
> optimization, on Ubuntu 10.10 32-bit.  Currently my executable size is
> 54956 bytes.
>
> Occasionally I change a small bit of code, and recompile.  My
> executable file size doesn't change, even when the code definitely
> does something different.  However, I would like to know what changes
> are made.  Occasionally I could code thing one way or another, and if
> I could shave off a few bytes doing it the other way, I'd like to do
> it.
>
> Why does the executable size not change?  Is there some type of
> rounding-up going on?

How are you measuring the size?  If you are using ls -l, then, yes,
there are various sorts of rounding to page boundaries going on.  Since
you are interested in code size, a better approach would be to run the
"size" program and look at the "text" field.

I don't know what you care about, but note that as a general rule the
size of a program running on GNU/Linux does not correlate very well to
runtime performance.

If you just want to see what changed, use objdump -d and examine the
generated assembler code.  Or use the --save-temps option with gcc and
examine the generated .s file.

You can ask gcc to optimize for reduced code size using the -Os option.

Ian


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux