aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2013-02-08 07:04:50 +0000
committerAlan Modra <amodra@gmail.com>2013-02-08 07:04:50 +0000
commit619a703ea3e1ef4463c168e96b17802b6aa480a0 (patch)
tree0d8ebb8fe17e5311dec2cddefad0ba4f0d83fe78 /bfd/elf.c
parent02acbe2250b647ae693a88fa30056f80aee514d9 (diff)
downloadgdb-619a703ea3e1ef4463c168e96b17802b6aa480a0.zip
gdb-619a703ea3e1ef4463c168e96b17802b6aa480a0.tar.gz
gdb-619a703ea3e1ef4463c168e96b17802b6aa480a0.tar.bz2
PR binutils/15106
* elf-bfd.h (struct elf_obj_tdata): Add elf_find_function_cache. * elf.c (elf_find_function): Revert last change. Use new tdata field rather than static vars for cache.
Diffstat (limited to 'bfd/elf.c')
-rw-r--r--bfd/elf.c54
1 files changed, 31 insertions, 23 deletions
diff --git a/bfd/elf.c b/bfd/elf.c
index 9d6ff31..380f6ef 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -7504,20 +7504,29 @@ elf_find_function (bfd *abfd,
const char **filename_ptr,
const char **functionname_ptr)
{
- static asection *last_section;
- static asymbol **last_symbols;
- static asymbol *func;
- static const char *filename;
- static bfd_size_type func_size;
+ struct elf_find_function_cache
+ {
+ asection *last_section;
+ asymbol *func;
+ const char *filename;
+ bfd_size_type func_size;
+ } *cache;
if (symbols == NULL)
return FALSE;
- if (last_section != section
- || last_symbols != symbols
- || func == NULL
- || offset < func->value
- || offset >= func->value + func_size)
+ cache = elf_tdata (abfd)->elf_find_function_cache;
+ if (cache == NULL)
+ {
+ cache = bfd_zalloc (abfd, sizeof (*cache));
+ elf_tdata (abfd)->elf_find_function_cache = cache;
+ if (cache == NULL)
+ return FALSE;
+ }
+ if (cache->last_section != section
+ || cache->func == NULL
+ || offset < cache->func->value
+ || offset >= cache->func->value + cache->func_size)
{
asymbol *file;
bfd_vma low_func;
@@ -7533,14 +7542,13 @@ elf_find_function (bfd *abfd,
enum { nothing_seen, symbol_seen, file_after_symbol_seen } state;
const struct elf_backend_data *bed = get_elf_backend_data (abfd);
- filename = NULL;
- func = NULL;
file = NULL;
low_func = 0;
state = nothing_seen;
- func_size = 0;
- last_section = section;
- last_symbols = symbols;
+ cache->filename = NULL;
+ cache->func = NULL;
+ cache->func_size = 0;
+ cache->last_section = section;
for (p = symbols; *p != NULL; p++)
{
@@ -7561,29 +7569,29 @@ elf_find_function (bfd *abfd,
&& code_off <= offset
&& (code_off > low_func
|| (code_off == low_func
- && size > func_size)))
+ && size > cache->func_size)))
{
- func = sym;
- func_size = size;
+ cache->func = sym;
+ cache->func_size = size;
+ cache->filename = NULL;
low_func = code_off;
- filename = NULL;
if (file != NULL
&& ((sym->flags & BSF_LOCAL) != 0
|| state != file_after_symbol_seen))
- filename = bfd_asymbol_name (file);
+ cache->filename = bfd_asymbol_name (file);
}
if (state == nothing_seen)
state = symbol_seen;
}
}
- if (func == NULL)
+ if (cache->func == NULL)
return FALSE;
if (filename_ptr)
- *filename_ptr = filename;
+ *filename_ptr = cache->filename;
if (functionname_ptr)
- *functionname_ptr = bfd_asymbol_name (func);
+ *functionname_ptr = bfd_asymbol_name (cache->func);
return TRUE;
}