#include <stdio.h>
func2()
{
printf("func2 add:%p\n",func2);
int *p=0;*p=0;
}
func1()
{
printf("func1 add:%p\n",func1);
func2();
}
int main()
{
printf("main add:%p\n",main);
int a;
int b;
printf("&a:%p &b:%p\n", &a, &b);
func1();
}
./1
main add:0x8048413
&a:0xbfcfcc2c &b:0xbfcfcc28
func1 add:0x80483f1
func2 add:0x80483c4
core dumped
PC:~/Desktop/ctest$ readelf -s 1 | grep main
65: 08048413 66 FUNC GLOBAL DEFAULT 14 main
PC:~/Desktop/ctest$ readelf -s 1 | grep func
56: 080483c4 45 FUNC GLOBAL DEFAULT 14 func2
61: 080483f1 34 FUNC GLOBAL DEFAULT 14 func1
[436911.689947] 1[17715]: segfault at 0 ip 080483e9 sp bfcfcbc0 error 6 in 1[8048000+1000]
Program terminated with signal 11, Segmentation fault.
#0 0x080483e9 in func2 ()
(gdb) bt
#0 0x080483e9 in func2 ()
#1 0x08048411 in func1 ()
#2 0x08048453 in main ()
(gdb) q
[436911.689947] 1[17715]: segfault at 0 ip 080483e9 sp bfcfcbc0 error 6 in 1[8048000+1000]
~/Desktop/ctest$ gdb 1 core_1.17762
GNU gdb (GDB) 7.0.1-debian
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i486-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from Desktop/ctest/1...(no debugging symbols found)...done.
warning: Can't read pathname for load map: Input/output error.
Reading symbols from /lib/i686/cmov/libc.so.6...(no debugging symbols found)...done.
Loaded symbols for /lib/i686/cmov/libc.so.6
Reading symbols from /lib/ld-linux.so.2...(no debugging symbols found)...done.
Loaded symbols for /lib/ld-linux.so.2
Core was generated by `./1'.
Program terminated with signal 11, Segmentation fault.
#0 0x080483e9 in func2 ()
(gdb) bt
#0 0x080483e9 in func2 ()
#1 0x08048411 in func1 ()
#2 0x08048453 in main ()