metz@iamsm.iam.unibe.ch (Igor Metz) (02/23/90)
>Config: > gcc 1.37 + gas 1.34 on Sparcstation-1 > gcc 1.37 + as on Sun-3 > SunOS 4.0.3c Problem: executing a program (compiled with -a) either removes the source code (on Sun-3) or dumps core (on Sun-4). Consider the following (famous) program ( = gaga.c): ------------------------------------------- main() { printf("Hello World\n); } ------------------------------------------- Its initial size is 35 Bytes. bolek:/tmp% l gaga.c -rw-r----- 1 metz staff 35 Feb 22 17:58 gaga.c We compile with -a and dynamic linkage. bolek:/tmp% gcc -v -a -o gaga gaga.c gcc -v -a -o gaga gaga.c gcc version 1.37 /usr/local/lib/gcc-cpp -v -undef -D__GNUC__ -Dsparc -Dsun -Dunix -D__sparc__ -D__sun__ -D__unix__ gaga.c /usr/tmp/cca00255.cpp GNU CPP version 1.37 /usr/local/lib/gcc-cc1 /usr/tmp/cca00255.cpp -quiet -dumpbase gaga.c -a -version -o /usr/tmp/cca00255.s GNU C version 1.37 (sparc) compiled by GNU C version 1.37. default target switches: -mfpu -mepilogue /usr/local/lib/gcc-as -o gaga.o /usr/tmp/cca00255.s ld -o gaga -e start -dc -dp /lib/crt0.o gaga.o /usr/local/lib/gcc-gnulib /usr/lib/bb_link.o -lc /usr/local/lib/gcc-gnulib We execute the program and it will dump core. bolek:/tmp% gaga Segmentation fault (core dumped) We recompile the code with -static and execute it again. bolek:/tmp% gcc -a -o gaga gaga.c -static bolek:/tmp% gaga Hello World count: Could not open (null), errno 0 It seemed to work, but gaga.c has suddenly 1 Byte more... bolek:/tmp% l gaga.c -rw-r----- 1 metz staff 36 Feb 22 17:58 gaga.c Let's do the same on Sun-3: siam:/tmp% gcc -v -a -o gaga gaga.c gcc version 1.37 /usr/local/lib/gcc-cpp -v -undef -D__GNUC__ -Dmc68000 -Dsun -Dunix -D__mc68000__ -D__sun__ -D__unix__ -D__HAVE_68881__ -Dmc68020 gaga.c /usr/tmp/cca20996.cpp GNU CPP version 1.37 /usr/local/lib/gcc-cc1 /usr/tmp/cca20996.cpp -quiet -dumpbase gaga.c -a -version -o /usr/tmp/cca20996.s GNU C version 1.37 (68k, MIT syntax) compiled by GNU C version 1.37. default target switches: -m68020 -mc68020 -m68881 -mbitfield as -mc68020 -o gaga.o /usr/tmp/cca20996.s ld -o gaga -e start -dc -dp /lib/crt0.o /lib/Mcrt1.o gaga.o /usr/local/lib/gcc-gnulib -lc /usr/lib/bb_link.o -L/usr/lib/f68881 /usr/local/lib/gcc-gnulib We execute the code. siam:/tmp% gaga Hello World gaga.c: Corrupt file: 1 blocks left And suddenly the source file is empty. siam:/tmp% l gaga.c -rw-r----- 1 metz fcg 0 Feb 22 18:14 gaga.c Igor Metz X400: metz@iamsm.iam.unibe.ch Institut fuer Informatik ARPA: metz%iamsm.iam.unibe.ch@relay.cs.net und angewandte Mathematik UUCP: ..!uunet!mcsun!iamsm.iam.unibe.ch!metz Universitaet Bern Phone: (0041) 31 65 49 90 Switzerland Fax: (0041) 31 65 39 65