[sf-lug] K & R errata
jim
jim at systemateka.com
Tue Jul 5 13:50:37 PDT 2011
on my 32-bit system, ints are 4 bytes (per sizeof)
compiled file with main with empty statement is 7102 bytes
main() { ; }
compiled file that declares 100 ints is 9099 bytes
int i1, i2...i100; main() { ; } // 7102+1997
compiled file that defines 100 ints is 9103 bytes
int i1=0, i2=0...i100=0; main() { ; } // 7102+2001
compiled file that declares an array of 100 ints is 7124 bytes
int is[100]; main { ; } // 7102+22
compiled file that defines an array of 100 ints is 7576 bytes
int is{100] = { 0,0,...0 }; main() { ; } // 7102+474 (452 bigger)
next step is to analyze the structure. later, time
for lunch.
On Tue, 2011-07-05 at 12:44 -0700, Alison Chaiken wrote:
> jim writes:
> > "They should both get initialized to zero, which means that they
> should
> > go into the .bss section of the ELF file...."
> > JS: This is Linux-specific behavior? I.e. not necessarily true
> > for non-Linux OSes?
>
> AFAIK all major Unices have migrated from older a.out to ELF:
>
> http://www.freebsd.org/doc/handbook/binary-formats.html
>
> By the way, binutils has lots of other useful stuff besides readelf,
> for example nm and objdump. You have hours of happy man-page
> reading ahead of you!
>
> If I didn't have a deadline, I'd make a .c file with
>
> int a1;
> int a2;
> . . .
> int a100;
>
>
> and compare it's size to
>
>
> int a[100];
>
>
> but I have a deadline right now. I don't know the answer to the
> earlier question about the function declarations and memory and would
> like to explore that too, but maybe I should try to get my
> presentation finished before my business trip instead . . .
>
> --
> Alison Chaiken
> (650) 279-5600 (cell)
> http://www.exerciseforthereader.org/
> Spend much time at the cutting edge and you're liable to get cut.
>
>
More information about the sf-lug
mailing list