From b38ee2510107352b73cd02ff66f7bd1c3d1114e6 Mon Sep 17 00:00:00 2001 From: Asher Baker Date: Sun, 25 Sep 2022 15:03:27 +0200 Subject: [PATCH 2/5] Write FUNC records instead of PUBLIC for ELF symbols with --- src/common/linux/elf_symbols_to_module.cc | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/common/linux/elf_symbols_to_module.cc b/src/common/linux/elf_symbols_to_module.cc index 4aee38d6..5b7991d5 100644 --- a/src/common/linux/elf_symbols_to_module.cc +++ b/src/common/linux/elf_symbols_to_module.cc @@ -156,19 +156,28 @@ bool ELFSymbolsToModule(const uint8_t* symtab_section, while(!iterator->at_end) { if (ELF32_ST_TYPE(iterator->info) == STT_FUNC && iterator->shndx != SHN_UNDEF) { - Module::Extern* ext = new Module::Extern(iterator->value); - ext->name = SymbolString(iterator->name_offset, strings); + string name = SymbolString(iterator->name_offset, strings); #if !defined(__ANDROID__) // Android NDK doesn't provide abi::__cxa_demangle. int status = 0; char* demangled = - abi::__cxa_demangle(ext->name.c_str(), NULL, NULL, &status); + abi::__cxa_demangle(name.c_str(), NULL, NULL, &status); if (demangled) { if (status == 0) - ext->name = demangled; + name = demangled; free(demangled); } #endif +#if 1 + if (iterator->size) { + Module::Function *fun = new Module::Function(name, iterator->value); + fun->ranges.push_back(Module::Range(iterator->value, iterator->size)); + module->AddFunction(fun); + } +#else + Module::Extern *ext = new Module::Extern(iterator->value); + ext->name = name; module->AddExtern(ext); +#endif } ++iterator; } -- 2.25.1