summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--agent/tcf/services/tcf_elf.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/agent/tcf/services/tcf_elf.c b/agent/tcf/services/tcf_elf.c
index 4b129914..fbf5915d 100644
--- a/agent/tcf/services/tcf_elf.c
+++ b/agent/tcf/services/tcf_elf.c
@@ -380,6 +380,9 @@ static ELF_File * create_elf_cache(const char * file_name) {
if (error == 0) {
Elf32_Ehdr hdr;
+ int symtab_found;
+ ELF_Section * dynsym_section;
+
memset(&hdr, 0, sizeof(hdr));
if (read(file->fd, (char *)&hdr, sizeof(hdr)) < 0) error = errno;
if (error == 0 && strncmp((char *)hdr.e_ident, ELFMAG, SELFMAG) != 0) {
@@ -397,6 +400,9 @@ static ELF_File * create_elf_cache(const char * file_name) {
}
file->byte_swap = file->big_endian != big_endian_host();
}
+
+ symtab_found = 0;
+ dynsym_section = NULL;
if (error != 0) {
/* Nothing */
}
@@ -466,7 +472,14 @@ static ELF_File * create_elf_cache(const char * file_name) {
sec->link = shdr.sh_link;
sec->info = shdr.sh_info;
sec->entsize = shdr.sh_entsize;
- if (sec->type == SHT_SYMTAB) sec->sym_count = (unsigned)(sec->size / sizeof(Elf32_Sym));
+ if (sec->type == SHT_SYMTAB) {
+ sec->sym_count = (unsigned int)(sec->size / sizeof(Elf32_Sym));
+ symtab_found = 1;
+ } else if (sec->type == SHT_DYNSYM) {
+ assert(dynsym_section == NULL);
+ sec->sym_count = (unsigned int)(sec->size / sizeof(Elf32_Sym));
+ dynsym_section = sec;
+ }
cnt++;
}
}
@@ -580,7 +593,15 @@ static ELF_File * create_elf_cache(const char * file_name) {
sec->link = shdr.sh_link;
sec->info = shdr.sh_info;
sec->entsize = (U4_T)shdr.sh_entsize;
- if (sec->type == SHT_SYMTAB) sec->sym_count = (unsigned)(sec->size / sizeof(Elf64_Sym));
+ if (sec->type == SHT_SYMTAB) {
+ sec->sym_count = (unsigned)(sec->size / sizeof(Elf64_Sym));
+ symtab_found = 1;
+ } else if (sec->type == SHT_DYNSYM) {
+ assert(dynsym_section == NULL);
+ sec->sym_count = (unsigned int)(sec->size / sizeof(Elf64_Sym));
+ dynsym_section = sec;
+ }
+
cnt++;
}
}
@@ -642,6 +663,9 @@ static ELF_File * create_elf_cache(const char * file_name) {
}
}
}
+
+ if ((dynsym_section != NULL) && (symtab_found == 1))
+ dynsym_section->sym_count = 0;
}
file->debug_info_file = is_debug_info_file(file);
if (error == 0 && !file->debug_info_file) {