aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2012-01-23 06:16:38 +0000
committerAlan Modra <amodra@gmail.com>2012-01-23 06:16:38 +0000
commit9f296da34f6b4357ce7528eeb2b29d9f8e50c71e (patch)
treeb030c6e6398786e9a3940724bf32fefe4738e057 /bfd/elf.c
parent2d6bdbd03f55a040894b631c5e82dbd8db8cf31c (diff)
downloadgdb-9f296da34f6b4357ce7528eeb2b29d9f8e50c71e.zip
gdb-9f296da34f6b4357ce7528eeb2b29d9f8e50c71e.tar.gz
gdb-9f296da34f6b4357ce7528eeb2b29d9f8e50c71e.tar.bz2
* elf-bfd.h: Formatting.
(struct elf_backend_data): Add "maybe_function_sym". (_bfd_elf_maybe_function_sym): Declare. * elfxx-target.h (elf_backend_maybe_function_sym): Define. (elfNN_bed): Init new field. * elf.c (elf_find_function): Use maybe_function_sym. (_bfd_elf_maybe_function_sym): New function. * elf64-ppc.c (elf_backend_maybe_function_sym): Define. (ppc64_elf_maybe_function_sym): New function.
Diffstat (limited to 'bfd/elf.c')
-rw-r--r--bfd/elf.c35
1 files changed, 27 insertions, 8 deletions
diff --git a/bfd/elf.c b/bfd/elf.c
index 35007cd..9c9ba75 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -1,7 +1,7 @@
/* ELF executable support for BFD.
Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
- 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
+ 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
Free Software Foundation, Inc.
This file is part of BFD, the Binary File Descriptor library.
@@ -7406,6 +7406,8 @@ elf_find_function (bfd *abfd,
{
elf_symbol_type *q;
unsigned int type;
+ asection *code_sec;
+ bfd_vma code_off;
q = (elf_symbol_type *) *p;
@@ -7418,15 +7420,13 @@ elf_find_function (bfd *abfd,
state = file_after_symbol_seen;
continue;
default:
- if (!bed->is_function_type (type))
- break;
- case STT_NOTYPE:
- if (bfd_get_section (&q->symbol) == section
- && q->symbol.value >= low_func
- && q->symbol.value <= offset)
+ if (bed->maybe_function_sym (q, &code_sec, &code_off)
+ && code_sec == section
+ && code_off >= low_func
+ && code_off <= offset)
{
func = (asymbol *) q;
- low_func = q->symbol.value;
+ low_func = code_off;
filename = NULL;
if (file != NULL
&& (ELF_ST_BIND (q->internal_elf_sym.st_info) == STB_LOCAL
@@ -9690,3 +9690,22 @@ _bfd_elf_is_function_type (unsigned int type)
return (type == STT_FUNC
|| type == STT_GNU_IFUNC);
}
+
+/* Return TRUE iff the ELF symbol SYM might be a function. Set *CODE_SEC
+ and *CODE_OFF to the function's entry point. */
+
+bfd_boolean
+_bfd_elf_maybe_function_sym (const elf_symbol_type *sym,
+ asection **code_sec, bfd_vma *code_off)
+{
+ unsigned int type = ELF_ST_TYPE (sym->internal_elf_sym.st_info);
+ if (type == STT_NOTYPE
+ || type == STT_FUNC
+ || type == STT_GNU_IFUNC)
+ {
+ *code_sec = sym->symbol.section;
+ *code_off = sym->symbol.value;
+ return TRUE;
+ }
+ return FALSE;
+}