From 9d52de1442728faf6277abef2d00f4dd7db78922 Mon Sep 17 00:00:00 2001 From: Ulrich Weigand Date: Sat, 3 May 2008 00:37:35 +0000 Subject: * linespec.c: Include "target.h". (minsym_found): Handle minimal symbols pointing to function descriptors. Use find_function_start_pc. * minsyms.c (msymbol_objfile): New function. * parse.c (write_exp_msymbol): Handle minimal symbols pointing to function descriptors. * symtab.c (fixup_section): Only use minimal symbol at the same address to determine section of a symbol. (find_function_start_pc): New function. (find_function_start_sal): Use it. * symtab.h (msymbol_objfile): Add prototype. (find_function_start_pc): Likewise. * value.c: Include "objfiles.h". (value_fn_field): Handle minimal symbols pointing to function descriptors. * Makefile.in (linespec.o): Update dependencies. (value.o): Likewise. --- gdb/parse.c | 43 +++++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 18 deletions(-) (limited to 'gdb/parse.c') diff --git a/gdb/parse.c b/gdb/parse.c index 09ef1dfcebd..734739afea8 100644 --- a/gdb/parse.c +++ b/gdb/parse.c @@ -400,39 +400,46 @@ write_exp_msymbol (struct minimal_symbol *msymbol, struct type *text_symbol_type, struct type *data_symbol_type) { - struct gdbarch *gdbarch = current_gdbarch; - CORE_ADDR addr; + struct objfile *objfile = msymbol_objfile (msymbol); + struct gdbarch *gdbarch = get_objfile_arch (objfile); + + CORE_ADDR addr = SYMBOL_VALUE_ADDRESS (msymbol); + asection *bfd_section = SYMBOL_BFD_SECTION (msymbol); + enum minimal_symbol_type type = msymbol->type; + CORE_ADDR pc; + + /* The minimal symbol might point to a function descriptor; + resolve it to the actual code address instead. */ + pc = gdbarch_convert_from_func_ptr_addr (gdbarch, addr, ¤t_target); + if (pc != addr) + { + /* In this case, assume we have a code symbol instead of + a data symbol. */ + type = mst_text; + bfd_section = NULL; + addr = pc; + } + + if (overlay_debugging) + addr = symbol_overlayed_address (addr, bfd_section); write_exp_elt_opcode (OP_LONG); /* Let's make the type big enough to hold a 64-bit address. */ write_exp_elt_type (builtin_type_CORE_ADDR); - - addr = SYMBOL_VALUE_ADDRESS (msymbol); - if (overlay_debugging) - addr = symbol_overlayed_address (addr, SYMBOL_BFD_SECTION (msymbol)); write_exp_elt_longcst ((LONGEST) addr); - write_exp_elt_opcode (OP_LONG); - if (SYMBOL_BFD_SECTION (msymbol) - && SYMBOL_BFD_SECTION (msymbol)->flags & SEC_THREAD_LOCAL) + if (bfd_section && bfd_section->flags & SEC_THREAD_LOCAL) { - bfd *bfd = SYMBOL_BFD_SECTION (msymbol)->owner; - struct objfile *ofp; - - ALL_OBJFILES (ofp) - if (ofp->obfd == bfd) - break; - write_exp_elt_opcode (UNOP_MEMVAL_TLS); - write_exp_elt_objfile (ofp); + write_exp_elt_objfile (objfile); write_exp_elt_type (builtin_type (gdbarch)->nodebug_tls_symbol); write_exp_elt_opcode (UNOP_MEMVAL_TLS); return; } write_exp_elt_opcode (UNOP_MEMVAL); - switch (msymbol->type) + switch (type) { case mst_text: case mst_file_text: -- cgit v1.2.1