This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
This is on HP/UX 11.00. Compile the following little program: #include <stdio.h> #include <dl.h> int main (void) { void * o = shl_load ("/usr/lib/libnss_files.1", BIND_IMMEDIATE, 0L); printf ("Got o = %p\n", o); shl_unload (o); return 0; } With this command: % gcc -g -o dl dl.c /opt/langtools/lib/end.o Now try to run the program under the debugger: % gdb dl (gdb) run Starting program: /[...]/dl Program received signal SIGSEGV, Segmentation fault. 0xc08ee090 in ?? () The expected behavior is: (gdb) run Starting program: /[...]/dl Got o = 7b03d180 Program exited normally. The problem is in solib-som.c:som_solib_create_inferior_hook(): We're looking up the address of __d_trap, and end up finding the address of the function. But we need the stub, not the function. So we have the following code that tries to do that: /* Grrr, this might not be an export symbol! We have to find the export stub. */ ALL_OBJFILES (objfile) { struct unwind_table_entry *u; struct minimal_symbol *msymbol2; /* What a crock. */ msymbol2 = lookup_minimal_symbol_solib_trampoline (SYMBOL_LINKAGE_NAME (msymbol), objfile); /* Found a symbol with the right name. */ if (msymbol2) { struct unwind_table_entry *u; /* It must be a shared library trampoline. */ if (SYMBOL_TYPE (msymbol2) != mst_solib_trampoline) continue; /* It must also be an export stub. */ u = find_unwind_entry (SYMBOL_VALUE (msymbol2)); if (!u || u->stub_unwind.stub_type != EXPORT) continue; /* OK. Looks like the correct import stub. */ anaddr = SYMBOL_VALUE (msymbol2); dld_cache.hook_stub.address = anaddr; } } Unfortunately for us, that doesnt' work for __d_trap, as that symbol lives in crt0. So lookup_minimal_symbol_solib_trampoline never returns any match, and we end up stuck with the non-stub address. I replaced the above block by a simply ALL_MSYMBOLS loop that simply matches the msymbol name before checking for the associated stub type. That fixes the problem. 2004-12-15 Joel Brobecker <brobecker@gnat.com> * solib-som.c (som_solib_create_inferior_hook): Extend stub msymbol search to all objfiles, not just shared libraries. Tested on HP/UX 11.00, no regression. OK to commit? Thanks, -- Joel
Attachment:
solib-som.c.diff
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |