Darwin: Handle unrelocated dyld.
On Darwin, debugging an helloworld program with GDB does
not work and ends with:
(gdb) set startup-with-shell off
(gdb) start
Temporary breakpoint 1 at 0x100000fb4: file /tmp/helloworld.c, line 1.
Starting program: /private/tmp/helloworld
[New Thread 0x2703 of process 18906]
[New Thread 0x2603 of process 18906]
[1]+ Stopped ./gdb/gdb /tmp/helloworld
When debugging with lldb, instead of having the STOP signal, we can
see that a breakpoint is not set to a proper location:
Warning:
Cannot insert breakpoint -1.
Cannot access memory at address 0xf726
Command aborted.
The inserted breakpoint is the one used when GDB has to stop the target
when a shared library is loaded or unloaded. The notifier address used
for adding the breakpoint is wrong thus the above failure.
This notifier address is an offset relative to dyld base address, so
the value calculation has to be updated to reflect this.
This was tested on High Sierra by trying to run a simple "hello world"
program.
gdb/ChangeLog:
PR gdb/20981:
* solib-darwin.c (darwin_get_dyld_bfd): New function.
(darwin_solib_get_all_image_info_addr_at_init): Update call.
(darwin_handle_solib_event): New function.
(darwin_solib_create_inferior_hook): Handle unrelocated dyld.
Change-Id: I7dde5008c9158f17b78dc89bd7f4bd8a12d4a6e1