/* corefile.c
Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009,
- 2010, 2011 Free Software Foundation, Inc.
+ 2010, 2011, 2012 Free Software Foundation, Inc.
This file is part of GNU Binutils.
extern void tahoe_find_call (Sym *, bfd_vma, bfd_vma);
extern void sparc_find_call (Sym *, bfd_vma, bfd_vma);
extern void mips_find_call (Sym *, bfd_vma, bfd_vma);
+extern void aarch64_find_call (Sym *, bfd_vma, bfd_vma);
static void
parse_error (const char *filename)
static int
cmp_symbol_map (const void * l, const void * r)
{
- return strcmp (((struct function_map *) l)->function_name,
+ return strcmp (((struct function_map *) l)->function_name,
((struct function_map *) r)->function_name);
}
mips_find_call (parent, p_lowpc, p_highpc);
break;
+ case bfd_arch_aarch64:
+ aarch64_find_call (parent, p_lowpc, p_highpc);
+ break;
+
default:
fprintf (stderr, _("%s: -c not supported on architecture %s\n"),
whoami, bfd_printable_name(core_bfd));
if (*name == '$')
return 0;
- if (*name == '.')
+ while (*name == '.')
{
- /* Allow GCC cloned functions. */
- if (strlen (name) > 7 && strncmp (name, ".clone.", 7) == 0)
- name += 6;
+ /* Allow both nested subprograms (which end with ".NNN", where N is
+ a digit) and GCC cloned functions (which contain ".clone").
+ Allow for multiple iterations of both - apparently GCC can clone
+ clones and subprograms. */
+ int digit_seen = 0;
+#define CLONE_NAME ".clone."
+#define CLONE_NAME_LEN strlen (CLONE_NAME)
+#define CONSTPROP_NAME ".constprop."
+#define CONSTPROP_NAME_LEN strlen (CONSTPROP_NAME)
+
+ if (strlen (name) > CLONE_NAME_LEN
+ && strncmp (name, CLONE_NAME, CLONE_NAME_LEN) == 0)
+ name += CLONE_NAME_LEN - 1;
+
+ else if (strlen (name) > CONSTPROP_NAME_LEN
+ && strncmp (name, CONSTPROP_NAME, CONSTPROP_NAME_LEN) == 0)
+ name += CONSTPROP_NAME_LEN - 1;
- /* Do not discard nested subprograms (those
- which end with .NNN, where N are digits). */
for (name++; *name; name++)
- if (! ISDIGIT (*name))
+ if (digit_seen && *name == '.')
+ break;
+ else if (ISDIGIT (*name))
+ digit_seen = 1;
+ else
return 0;
-
- break;
}
}
/* Return number of symbols in a symbol-table file. */
-static int
+static int
num_of_syms_in (FILE * f)
{
const int BUFSIZE = 1024;
char type;
char * name = (char *) xmalloc (BUFSIZE);
int num = 0;
-
+
while (!feof (f) && fgets (buf, BUFSIZE - 1, f))
{
if (sscanf (buf, "%s %c %s", address, &type, name) == 3)
bfd_vma max_vma = 0;
int cxxclass;
long i;
- struct function_map * found;
+ struct function_map * found = NULL;
int core_has_func_syms = 0;
switch (core_bfd->xvec->flavour)
/* Don't create a symtab entry for a function that has
a mapping to a file, unless it's the first function
in the file. */
- found = (struct function_map *) bsearch (core_syms[i]->name, symbol_map,
- symbol_map_count,
- sizeof (struct function_map),
- search_mapped_symbol);
+ if (symbol_map_count != 0)
+ {
+ /* Note: some systems (SunOS 5.8) crash if bsearch base argument
+ is NULL. */
+ found = (struct function_map *) bsearch
+ (core_syms[i]->name, symbol_map, symbol_map_count,
+ sizeof (struct function_map), search_mapped_symbol);
+ }
if (found == NULL || found->is_first)
++symtab.len;
}
continue;
}
- found = (struct function_map *) bsearch (core_syms[i]->name, symbol_map,
- symbol_map_count,
- sizeof (struct function_map), search_mapped_symbol);
+ if (symbol_map_count != 0)
+ {
+ /* Note: some systems (SunOS 5.8) crash if bsearch base argument
+ is NULL. */
+ found = (struct function_map *) bsearch
+ (core_syms[i]->name, symbol_map, symbol_map_count,
+ sizeof (struct function_map), search_mapped_symbol);
+ }
if (found && ! found->is_first)
continue;