1.3.30 and core files.

Michael H. Price II (mhp1@Ra.MsState.Edu)
Tue, 3 Oct 1995 03:34:02 -0500


Someone recently pointed out some problems with core files and gdb on this
list. Unfortunately I forgot his name and lost his email address (sorry).
However, I did some testing and got some weird results.

With 1.3.30, libc 5.2.9, ld.so 1.7.8, binutils 2.5-950822, and gcc 2.7.0,
gdb 4.14 with H.J.'s patch does not load the shared libraries as the docs
say it should when you examine a core file generated by a dynamically
linked elf executable. Basically you get no useful information from
"gdb a.out core". If you statically link the elf executable then you get
useful information.

On the other hand, if you modify 1.3.30 to generate elf core dumps instead
of a.out, then gdb does load the shared libraries upon execution of
"gdb a.out core". If you link the elf executable statically though, then
gdb complains about the "core" not being a valid core file (truncated).

Transcripts of what I did (using script) are below. Can anyone shed light
on what is happening?

Thank you.

Michael
-------
Script started on Tue Oct 3 03:10:12 1995
mhp1@Sitrom ~/code/misc> cat crash.c
#include <string.h>

int
main (void)
{
(void) strcpy (0, "crash"); /* This will crash */

return 0;
}
mhp1@Sitrom ~/code/misc> gcc -Wall -g crash.c
mhp1@Sitrom ~/code/misc> file a.out
a.out: ELF 32-bit LSB executable, Intel 80386, version 1
mhp1@Sitrom ~/code/misc> ./a.out
Segmentation fault (core dumped)
mhp1@Sitrom ~/code/misc> gdb a.out core
GDB is free software and you are welcome to distribute copies of it
under certain conditions; type "show copying" to see the conditions.
There is absolutely no warranty for GDB; type "show warranty" for details.
GDB 4.14 (i486-linux), Copyright 1995 Free Software Foundation, Inc...
Core was generated by `a.out'.
Cannot access memory at address 0x40006138.
#0 0x4005c1ff in __fpu_control ()
(gdb) bt
#0 0x4005c1ff in __fpu_control ()
#1 0x40001f20 in __fpu_control ()
#2 0x8000424 in ___crt_dummy__ ()
(gdb) quit
mhp1@Sitrom ~/code/misc> gcc -Wall -g -static crash.c
mhp1@Sitrom ~/code/misc> file a.out
a.out: ELF 32-bit LSB executable, Intel 80386, version 1
mhp1@Sitrom ~/code/misc> ./a.out
Segmentation fault (core dumped)
mhp1@Sitrom ~/code/misc> gdb a.out core
GDB is free software and you are welcome to distribute copies of it
under certain conditions; type "show copying" to see the conditions.
There is absolutely no warranty for GDB; type "show warranty" for details.
GDB 4.14 (i486-linux), Copyright 1995 Free Software Foundation, Inc...
Core was generated by `a.out'.
#0 0x8000153 in strcpy ()
(gdb) bt
#0 0x8000153 in strcpy ()
#1 0x8000133 in main () at crash.c:6
#2 0x80000e4 in ___crt_dummy__ ()
(gdb) quit
mhp1@Sitrom ~/code/misc> exit
Script done on Tue Oct 3 03:11:20 1995
-------
Script started on Tue Oct 3 03:13:58 1995
mhp1@Sitrom ~/code/misc> cat crash.c
#include <string.h>

int
main (void)
{
(void) strcpy (0, "crash"); /* This will crash */

return 0;
}
mhp1@Sitrom ~/code/misc> gcc -Wall -g crash.c
mhp1@Sitrom ~/code/misc> file a.out
a.out: ELF 32-bit LSB executable, Intel 80386, version 1
mhp1@Sitrom ~/code/misc> ./a.out
Segmentation fault (core dumped)
mhp1@Sitrom ~/code/misc> gdb a.out core
GDB is free software and you are welcome to distribute copies of it
under certain conditions; type "show copying" to see the conditions.
There is absolutely no warranty for GDB; type "show warranty" for details.
GDB 4.14 (i486-linux), Copyright 1995 Free Software Foundation, Inc...
Core was generated by `./a.out'.
Program terminated with signal 11, Segmentation fault.
Reading symbols from /lib/libc.so.5.2.9...done.
Reading symbols from /lib/ld-linux.so.1...done.
#0 0x4005c1ff in strcpy ()
(gdb) bt
#0 0x4005c1ff in strcpy ()
#1 0x40001f20 in _dl_interpreter_exit ()
#2 0x8000424 in ___crt_dummy__ ()
(gdb) quit
mhp1@Sitrom ~/code/misc> gcc -Wall -g -static crash.c
mhp1@Sitrom ~/code/misc> file a.out
a.out: ELF 32-bit LSB executable, Intel 80386, version 1
mhp1@Sitrom ~/code/misc> ./a.out
Segmentation fault (core dumped)
mhp1@Sitrom ~/code/misc> gdb a.out core
GDB is free software and you are welcome to distribute copies of it
under certain conditions; type "show copying" to see the conditions.
There is absolutely no warranty for GDB; type "show warranty" for details.
GDB 4.14 (i486-linux), Copyright 1995 Free Software Foundation, Inc...

"/home/mhp1/code/misc/core" is not a core dump: File truncated
(gdb) quit
mhp1@Sitrom ~/code/misc> exit
Script done on Tue Oct 3 03:15:26 1995