From 19cd0c1f755dc0cfd40d91eb7c8997579ac1a2af Mon Sep 17 00:00:00 2001 From: Jeff Law Date: Wed, 30 Mar 1994 07:03:01 +0000 Subject: [PATCH] * hppa-tdep.c (hppa_fix_call_dummy): Use an alternate method for calling import stubs for functions in shared libraries. --- gdb/ChangeLog | 5 +++++ gdb/hppa-tdep.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index fa57970..22bdea4 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +Tue Mar 29 23:01:33 1994 Jeffrey A. Law (law@snake.cs.utah.edu) + + * hppa-tdep.c (hppa_fix_call_dummy): Use an alternate method for + calling import stubs for functions in shared libraries. + Tue Mar 29 21:14:04 1994 Per Bothner (bothner@kalessin.cygnus.com) * ch-exp.y: Implement SIZE(mode_name) and SIZE(expression). diff --git a/gdb/hppa-tdep.c b/gdb/hppa-tdep.c index 7001dec..9ec6a90 100644 --- a/gdb/hppa-tdep.c +++ b/gdb/hppa-tdep.c @@ -1056,6 +1056,7 @@ hppa_fix_call_dummy (dummy, pc, fun, nargs, args, type, gcc_p) CORE_ADDR dyncall_addr, sr4export_addr; struct minimal_symbol *msymbol; int flags = read_register (FLAGS_REGNUM); + struct unwind_table_entry *u; msymbol = lookup_minimal_symbol ("$$dyncall", (struct objfile *) NULL); if (msymbol == NULL) @@ -1063,6 +1064,35 @@ hppa_fix_call_dummy (dummy, pc, fun, nargs, args, type, gcc_p) dyncall_addr = SYMBOL_VALUE_ADDRESS (msymbol); + /* If we are calling an import stub (eg calling into a dynamic library) + then have sr4export call the magic __d_plt_call routine which is linked + in from end.o. (You can't use _sr4export to call the import stub as + the value in sp-24 will get fried and you end up returning to the + wrong location. You can't call the import stub directly as the code + to bind the PLT entry to a function can't return to a stack address.) */ + u = find_unwind_entry (fun); + if (u && u->stub_type == IMPORT) + { + CORE_ADDR new_fun; + msymbol = lookup_minimal_symbol ("__d_plt_call", (struct objfile *) NULL); + if (msymbol == NULL) + error ("Can't find an address for __d_plt_call trampoline"); + + /* This is where sr4export will jump to. */ + new_fun = SYMBOL_VALUE_ADDRESS (msymbol); + + /* We have to store the address of the stub in __shlib_funcptr. */ + msymbol = lookup_minimal_symbol ("__shlib_funcptr", + (struct objfile *)NULL); + if (msymbol == NULL) + error ("Can't find an address for __shlib_funcptr"); + + target_write_memory (SYMBOL_VALUE_ADDRESS (msymbol), (char *)&fun, 4); + fun = new_fun; + + } + + /* We still need sr4export's address too. */ msymbol = lookup_minimal_symbol ("_sr4export", (struct objfile *) NULL); if (msymbol == NULL) error ("Can't find an address for _sr4export trampoline"); -- 2.7.4