Skip to content
Browse files

a start at debugging details

stub for executable elf & coredump to be filled in
  • Loading branch information...
1 parent fa011d3 commit 68cb5dfea9512c8975f2d2d497c4f26dead60f53 @ianw committed Sep 13, 2011
Showing with 35 additions and 0 deletions.
  1. +25 −0 chapter07/code/core-gdb.txt
  2. +10 −0 chapter07/code/debuglink.txt
View
25 chapter07/code/core-gdb.txt
@@ -0,0 +1,25 @@
+$ cat coredump.c
+int main(void) {
+ char *foo = (char*)0x12345;
+ *foo = 'a';
+
+ return 0;
+}
+
+$ gcc -Wall -g -o coredump coredump.c
+
+$ ./coredump
+Segmentation fault (core dumped)
+
+$ file ./core
+./core: ELF 32-bit LSB core file Intel 80386, version 1 (SYSV), SVR4-style, from './coredump'
+
+$ gdb ./coredump
+...
+(gdb) core core
+[New LWP 31614]
+Core was generated by `./coredump'.
+Program terminated with signal 11, Segmentation fault.
+#0 0x080483c4 in main () at coredump.c:3
+3 *foo = 'a';
+(gdb)
View
10 chapter07/code/debuglink.txt
@@ -0,0 +1,10 @@
+$ gcc -g -shared -o libtest.so libtest.c
+$ objcopy --only-keep-debug libtest.so libtest.debug
+$ objcopy --add-gnu-debuglink=libtest.debug libtest.so
+$ objdump -s -j .gnu_debuglink libtest.so
+
+libtest.so: file format elf32-i386
+
+Contents of section .gnu_debuglink:
+ 0000 6c696274 6573742e 64656275 67000000 libtest.debug...
+ 0010 52a7fd0a R...

0 comments on commit 68cb5df

Please sign in to comment.
Something went wrong with that request. Please try again.