Mail Archives: djgpp/1995/06/28/13:15:28
C++ program A.OUT size unstripped A.OUT size stripped
int x[10000]; main(){} 52269 44140
main(){} 15387 7276
(difference) 36882 36864
Why does declaring the array `x' add so much size to A.OUT? Surely there
is a more compact way of telling the loader to set the next 40000 bytes of
RAM to all zeros, than to write out 40000 zeros at length in the .EXE file?
Long ago in the CDC7600 mainframe's equivalent of .EXE files, there was a
special compact notation for "repeat the next n bytes p times". Why not in
PC's? (I know that the A.OUT from `int x[10000]; main(){}' contains 40000
consecutive ascii-zeros that aren't in the A.OUT from `main(){}': I just
looked!)
I agree. The global declaration, 'int x[10000]', is "uninitialized data".
This should be noted in the symbol table and the startup code should allocate
the space for all uninitialized data in a contiguous, virtual, block and null
it out.
Only initialized data should be written to the a.out (ie. int y[5] = {1, 2, 3,
4, 5};)
--
Art S. Kagel, kagel AT ts1 DOT bloomberg DOT com
Variety is the soul of pleasure. -- Aphra Behn
- Raw text -