goddard@aic.hrl.hac.com (10/05/89)
I compile a program with a single global integer, and then run nm on
the .o file. The value that nm prints for the integer is 8, but the
size of an integer is reported to be 4. I thought the value printed
by nm was supposed to be the size of the data item. Am I wrong or is
there a bug in GCC?
Here is the program:
#include <stdio.h>
int i;
main()
{
fprintf(stdout, "int (%d) float (%d) double (%d) long (%d)\n",
sizeof(int), sizeof(float), sizeof(double), sizeof(long));
}
I compile it:
gcc -c temp.c
gcc temp.o -o temp
and run it:
virus% temp
int (4) float (4) double (8) long (4)
virus%
and then run nm:
virus% nm temp.o
U __iob
U _fprintf
-> 00000008 C _i
0000002c T _main
00000000 t gcc_compiled.
virus%
but if I use cc instead of GCC, I get:
virus% cc -c temp.c
virus% cc temp.o -o temp
virus% temp
int (4) float (4) double (8) long (4)
virus% nm temp.o
U __iob
U _fprintf
-> 00000004 C _i
00000000 T _main
virus%