Here is my disas code:
Dump of assembler code for function main:
0x00000000000006b0 <+0>: push %rbp
0x00000000000006b1 <+1>: mov %rsp,%rbp
Dump of assembler code for function main: 0x00000000000006b0 <+0>: push %rbp 0x00000000000006b1 <+1>: mov %rsp,%rbp
You are looking at position-independent executable (a special kind of shared library). The code for main
gets relocated to a different address when the executable starts running.
Because there is no code at 0x6b4
once the executable is relocated, GDB complains that it can't set a breakpoint there.
but when I do it with b 4 and run the code ,it is working normal.
In this case, GDB understands that you want to set breakpoint on line 4, and inserts appropriate breakpoint after the executable has been relocated.
Use info break
to see what the relocated address is.