1
0
Fork 0
mirror of https://github.com/tobast/libunwind-eh_elf.git synced 2024-11-25 00:27:39 +01:00

Fix incorrect return code of unw_get_proc_name

The code for symbol lookup (elfxx.c:lookup_symbol) works by iterating
over symbol tables while maintaing the symbol closest to the supplied
instruction pointer. Whenever this search encountered symbol that was
longer than result buffer, the function returned -UNW_ENOMEM even though
the final symbol wasn't too long.

Signed-off-by: Martin Milata <mmilata@redhat.com>
This commit is contained in:
Martin Milata 2012-08-06 19:58:12 +02:00
parent 707b1dba99
commit e11a6a4fdf

View file

@ -41,7 +41,7 @@ elf_w (lookup_symbol) (unw_addr_space_t as,
Elf_W (Off) soff, str_soff;
Elf_W (Shdr) *shdr, *str_shdr;
Elf_W (Addr) val, min_dist = ~(Elf_W (Addr))0;
int i, ret = 0;
int i, ret = -UNW_ENOINFO;
char *strtab;
if (!elf_w (valid_object) (ei))
@ -102,8 +102,8 @@ elf_w (lookup_symbol) (unw_addr_space_t as,
min_dist = (Elf_W (Addr)) (ip - val);
strncpy (buf, strtab + sym->st_name, buf_len);
buf[buf_len - 1] = '\0';
if (strlen (strtab + sym->st_name) >= buf_len)
ret = -UNW_ENOMEM;
ret = (strlen (strtab + sym->st_name) >= buf_len
? -UNW_ENOMEM : 0);
}
}
}