From 38b90473602f5c7295242ec0cce8f804d171bcbf Mon Sep 17 00:00:00 2001 From: Peter Schauer Date: Fri, 1 Apr 1994 08:50:03 +0000 Subject: [PATCH] For SVR4 targets, enable gdb to set breakpoints in shared library functions before the executable is run. * elfread.c (elf_symtab_read): Handle symbols for shared library functions. * sparc-tdep.c (in_solib_trampoline): Renamed to in_plt_section and moved to objfiles.c. * objfiles.c (in_plt_section): Moved to here from sparc-tdep. * config/tm-sysv4.h (IN_SOLIB_TRAMPOLINE): Use new in_plt_section. * config/sparc/tm-sun4sol2.h (IN_SOLIB_TRAMPOLINE): Removed, the new generic definition from tm-sysv4.h works for Solaris. --- gdb/ChangeLog | 13 +++++++++++++ gdb/elfread.c | 24 +++++++++++++++++++++++- gdb/objfiles.c | 20 ++++++++++++++++++++ 3 files changed, 56 insertions(+), 1 deletion(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index da77cffa480..da0b01051fd 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,16 @@ +Fri Apr 1 00:44:00 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de) + + For SVR4 targets, enable gdb to set breakpoints in shared + library functions before the executable is run. + * elfread.c (elf_symtab_read): Handle symbols for shared library + functions. + * sparc-tdep.c (in_solib_trampoline): Renamed to in_plt_section + and moved to objfiles.c. + * objfiles.c (in_plt_section): Moved to here from sparc-tdep. + * config/tm-sysv4.h (IN_SOLIB_TRAMPOLINE): Use new in_plt_section. + * config/sparc/tm-sun4sol2.h (IN_SOLIB_TRAMPOLINE): Removed, + the new generic definition from tm-sysv4.h works for Solaris. + Wed Mar 30 16:14:27 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) * elfread.c (elf_symtab_read): Change storage_needed, diff --git a/gdb/elfread.c b/gdb/elfread.c index 89df794af2c..11d4b7e0c02 100644 --- a/gdb/elfread.c +++ b/gdb/elfread.c @@ -311,7 +311,29 @@ elf_symtab_read (abfd, addr, objfile) /* For non-absolute symbols, use the type of the section they are relative to, to intuit text/data. Bfd provides no way of figuring this out for absolute symbols. */ - if (sym -> section == &bfd_abs_section) + if (sym -> section == &bfd_und_section + && (sym -> flags & BSF_GLOBAL) + && (sym -> flags & BSF_FUNCTION)) + { + /* Symbol is a reference to a function defined in + a shared library. + If its value is non zero then it is usually the + absolute address of the corresponding entry in + the procedure linkage table. + If its value is zero then the dynamic linker has to + resolve the symbol. We are unable to find any + meaningful address for this symbol in the + executable file, so we skip it. + Irix 5 has a zero value for all shared library functions + in the main symbol table. The dynamic symbol table + would provide the right values, but BFD currently + cannot handle dynamic ELF symbol tables. */ + ms_type = mst_solib_trampoline; + symaddr = sym -> value; + if (symaddr == 0) + continue; + } + else if (sym -> section == &bfd_abs_section) { ms_type = mst_abs; } diff --git a/gdb/objfiles.c b/gdb/objfiles.c index 4f0dfd6d939..530e19b054b 100644 --- a/gdb/objfiles.c +++ b/gdb/objfiles.c @@ -825,3 +825,23 @@ find_pc_section(pc) return(NULL); } + +/* In SVR4, we recognize a trampoline by it's section name. + That is, if the pc is in a section named ".plt" then we are in + a trampoline. */ + +int +in_plt_section(pc, name) + CORE_ADDR pc; + char *name; +{ + struct obj_section *s; + int retval = 0; + + s = find_pc_section(pc); + + retval = (s != NULL + && s->the_bfd_section->name != NULL + && STREQ (s->the_bfd_section->name, ".plt")); + return(retval); +} -- 2.30.2