I was trying to play around with gdb, and I'm especially interest in seeing how the Procedural Linkage Table(PLT) and the Global Offset Table (GOT) interact with each other. So I set some breakpoints and see how the process work step by step. Interestingly enough, when I set breakpoints at certain instruction, I got segmentation fault, and I could not understand why. I simply stop at that instruction. Why would my program give me a segmentation fault? I'm just curious about this behavior. I screenshot the behavior. The red line encloses where I insert a breakpoint, and the program start to receive segfault.
1 Answer
Your breakpoint probably overwrites a byte in the middle of an instruction instead of the first one. It can lead to, for example, an out of memory read. You should put breakpoint at known instructions (e.g. start of the function/stub) then step through the following ones.