summaryrefslogtreecommitdiff
path: root/addr2line.c
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-10-11 23:55:45 (GMT)
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-10-11 23:55:45 (GMT)
commit336f86f2ee87d95c249dc5a3f19b1c59584246ec (patch)
tree6f1e3d31ec2893e31b294a85660250944929e1a2 /addr2line.c
parent69f06e9e8444acc0641c3c5e6210123772ddcb8d (diff)
close dlopen-ed handle
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65010 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'addr2line.c')
-rw-r--r--addr2line.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/addr2line.c b/addr2line.c
index 75b1a8c..c544a2d 100644
--- a/addr2line.c
+++ b/addr2line.c
@@ -1577,20 +1577,21 @@ fill_lines(int num_traces, void **traces, int check_debuglink,
char *strtab = file + dynstr_shdr->sh_offset;
ElfW(Sym) *symtab = (ElfW(Sym) *)(file + dynsym_shdr->sh_offset);
int symtab_count = (int)(dynsym_shdr->sh_size / sizeof(ElfW(Sym)));
- for (j = 0; j < symtab_count; j++) {
- ElfW(Sym) *sym = &symtab[j];
- Dl_info info;
- void *h, *s;
- if (ELF_ST_TYPE(sym->st_info) != STT_FUNC || sym->st_size <= 0) continue;
- h = dlopen(NULL, RTLD_NOW|RTLD_LOCAL);
- if (!h) continue;
- s = dlsym(h, strtab + sym->st_name);
- if (!s) continue;
- if (dladdr(s, &info)) {
- dladdr_fbase = (uintptr_t)info.dli_fbase;
- break;
- }
- }
+ void *handle = dlopen(NULL, RTLD_NOW|RTLD_LOCAL);
+ if (handle) {
+ for (j = 0; j < symtab_count; j++) {
+ ElfW(Sym) *sym = &symtab[j];
+ Dl_info info;
+ void *s;
+ if (ELF_ST_TYPE(sym->st_info) != STT_FUNC) continue;
+ s = dlsym(handle, strtab + sym->st_name);
+ if (s && dladdr(s, &info)) {
+ dladdr_fbase = (uintptr_t)info.dli_fbase;
+ break;
+ }
+ }
+ dlclose(handle);
+ }
if (ehdr->e_type == ET_EXEC) {
obj->base_addr = 0;
}