gdb에서 코드를 실행할 때 선언 된 변수에 대해 동일한 주소를 얻지 만 이진을 실행하는 동안 동일한 주소를 얻지 못하는 이유는 무엇입니까?GDB로 디버깅 할 때 로컬 변수의 주소가 여러 번 실행되는 이유는 무엇입니까?
#include<stdio.h>
void main()
{
int *x,q;
//I saw the address of the variable q in this program through gdb during the __1st__ execution.
//I re-compiled the program to make x to point to this address.
x=0x7fffffffe2bc;
*x=3;
printf("%d",(*x));
}
나는 gdb를 통해 프로그램을 실행했지만 결코 Segfaulted되지 않았습니다.
$ gdb -q ./a.out
Reading symbols from /home/eknath/needed2/a.out...done.
(gdb) r
Starting program: /home/eknath/needed2/a.out
3
Program exited normally.
(gdb) q
$
그러나 프로그램을 정상적으로 실행하면 항상 SEGFAULT가 생성됩니다.
$ ./a.out
Segmentation fault
이 질문은 Is this always the address for GDB debug program?
주의 중복인지 모르겠어요 : 나는 ASLR을 꺼하지 않은
위대한 답변, 고마워요 Logged –