1

There is something strange with GDB. I am working on a ELF Linux executable. I am putting a breakpoint on the program entry point. The program crashes before reaching the breakpoint. I want to run my program step by step from the beginning. If i type "step" command in GDB, i got an error message because the program is not in run mode. Can you tell me how i can reach the very first instruction of the program ? I think it is the dynamic loader but i don t know where it is...

Bob5421
  • 7,757
  • 14
  • 81
  • 175
  • Possible duplicate of [how to force gdb to stop right after the start of program execution?](http://stackoverflow.com/questions/18694620/how-to-force-gdb-to-stop-right-after-the-start-of-program-execution) – dbrank0 Jun 21 '16 at 15:20
  • No it is not the samething. I think a code is run before – Bob5421 Jun 21 '16 at 15:21
  • So if you put a breakpoint on entry point (not main), and do run, it crashes before hitting a breakpoint? – dbrank0 Jun 21 '16 at 15:23
  • Yes it crashé before – Bob5421 Jun 21 '16 at 15:39

1 Answers1

1

I want to run my program step by step from the beginning.

This is exceptionally hard for the debugger to do: execution starts in unrelocated ld-linux.so.2, which self-relocates, initializes libc.so.6, then any other directly-linked libraries, and finally passes control to the a.out entry point.

The fact that the debugger has to deal with both before and after self-relocation addresses is what makes it difficult / confusing.

Fortunately, it is also not usually necessary, even for ld-linux developers. You should probably abandon the idea that you will be able to step through ld-linux execution, and figure out how to debug whatever problem you actually have by other means (including asking for help with your actual problem here).

Employed Russian
  • 199,314
  • 34
  • 295
  • 362
  • I think this is the OS that do something with ld-linux in order to load libraries. Maybe i do not have the good library, i will look in this direction thanks – Bob5421 Jun 21 '16 at 20:20