Hi Lubomir, Thanks for the scripts. It is just what I was looking for. Meanwhile, since my last email, I have done something foolish. I've coded in grub's sources just the same algorithm you provide but I've clumbered the sources with new functions those purpose is only for debugging while you are doing all the job outside of the sources, and one might think it's better the way you do.
1) Got Ruby and change the makefiles just the way you do to get .elf files with debugging info. (I've setup for a different extension but I'll change for .elf) 2) Added a very few lines to grub_load_segments() to get the name of the section along with its load address in mod->segment. (You might want that to get ride of the readelf and perl script) 3) Build in a buffer, during build_load_core() and grub_load_segments() processing, the string "filename.elf load_addr -s .text 0x23888 ... " print it on the screen with grub_dprintf. 4) Call a function with that string argument to be caught by a .gdbinit script to launch the add-symbol-file command before the call to (mod->init(mod)). I first thought I could just get along with add-symbol-file command to gdb, but I was frustrated I could not set breakpoint ahead of time and then have it resolved when the module is loaded .... I was in the mood of doing C development so I've been overkilling again : Before I even finished the .gdbinit script, I've changed my mind and done "one" step further : 5) Added the "filename.elf -s .text 0x23234 ... " to the list of link_maps maintained by ld.so (actually ld.so complains a little but I'll fix that later) and do the call to _ld_debug_state() to generate a shlib event in gdb. 6) Changed the solib-svr4.c in gdb 6.1 so that it can handle loading ELF file with instructions to load each segment separately at the right place. So I am running with a modified gdb that understand grub's way of loading modules on the fly. If you think it can be of general interest, we can start from here to define a GDB interface to Grub 2. Otherwise, I'll use Ludomir external scripts since I don't want to maintain separate source files from the official delivery. Note that if we change somewhat the way grub load modules and allocate first the memory to contain all the segments, lying right one after another in memory, we won't have to change gdb anymore (step 6). Best regards, _________________________________________ Eric Salomé - Paris, France _______________________________________________ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel