10 #include <sys/types.h>
15 #include <elfutils/libdwfl.h>
40 return elf_symbol::NOTYPE_TYPE;
42 return elf_symbol::OBJECT_TYPE;
44 return elf_symbol::FUNC_TYPE;
46 return elf_symbol::SECTION_TYPE;
48 return elf_symbol::FILE_TYPE;
50 return elf_symbol::COMMON_TYPE;
52 return elf_symbol::TLS_TYPE;
54 return elf_symbol::GNU_IFUNC_TYPE;
76 return elf_symbol::LOCAL_BINDING;
78 return elf_symbol::GLOBAL_BINDING;
80 return elf_symbol::WEAK_BINDING;
82 return elf_symbol::GNU_UNIQUE_BINDING;
102 return elf_symbol::DEFAULT_VISIBILITY;
104 return elf_symbol::INTERNAL_VISIBILITY;
106 return elf_symbol::HIDDEN_VISIBILITY;
108 return elf_symbol::PROTECTED_VISIBILITY;
127 return "elf-no-arch";
129 return "elf-att-we-32100";
131 return "elf-sun-sparc";
133 return "elf-intel-80386";
135 return "elf-motorola-68k";
137 return "elf-motorola-88k";
139 return "elf-intel-80860";
141 return "elf-mips-r3000-be";
143 return "elf-ibm-s370";
145 return "elf-mips-r3000-le";
147 return "elf-hp-parisc";
149 return "elf-fujitsu-vpp500";
151 return "elf-sun-sparc-v8plus";
153 return "elf-intel-80960";
155 return "elf-powerpc";
157 return "elf-powerpc-64";
159 return "elf-ibm-s390";
161 return "elf-nec-v800";
163 return "elf-fujitsu-fr20";
165 return "elf-trw-rh32";
167 return "elf-motorola-rce";
171 return "elf-digital-alpha";
173 return "elf-hitachi-sh";
175 return "elf-sun-sparc-v9-64";
177 return "elf-siemens-tricore";
179 return "elf-argonaut-risc-core";
181 return "elf-hitachi-h8-300";
183 return "elf-hitachi-h8-300h";
185 return "elf-hitachi-h8s";
187 return "elf-hitachi-h8-500";
189 return "elf-intel-ia-64";
191 return "elf-stanford-mips-x";
193 return "elf-motorola-coldfire";
195 return "elf-motorola-68hc12";
197 return "elf-fujitsu-mma";
199 return "elf-siemens-pcp";
201 return "elf-sony-ncpu";
203 return "elf-denso-ndr1";
205 return "elf-motorola-starcore";
207 return "elf-toyota-me16";
209 return "elf-stm-st100";
211 return "elf-alc-tinyj";
213 return "elf-amd-x86_64";
215 return "elf-sony-pdsp";
217 return "elf-siemens-fx66";
219 return "elf-stm-st9+";
221 return "elf-stm-st7";
223 return "elf-motorola-68hc16";
225 return "elf-motorola-68hc11";
227 return "elf-motorola-68hc08";
229 return "elf-motorola-68hc05";
233 return "elf-stm-st19";
235 return "elf-digital-vax";
237 return "elf-axis-cris";
239 return "elf-infineon-javelin";
241 return "elf-firepath";
243 return "elf-lsi-zsp";
245 return "elf-don-knuth-mmix";
247 return "elf-harvard-huany";
249 return "elf-sitera-prism";
251 return "elf-atmel-avr";
253 return "elf-fujistu-fr30";
255 return "elf-mitsubishi-d10v";
257 return "elf-mitsubishi-d30v";
259 return "elf-nec-v850";
261 return "elf-mitsubishi-m32r";
263 return "elf-matsushita-mn10300";
265 return "elf-matsushita-mn10200";
267 return "elf-picojava";
269 return "elf-openrisc-32";
273 return "elf-tensilica-xtensa";
275 #ifdef HAVE_EM_AARCH64_MACRO
277 return "elf-arm-aarch64";
280 #ifdef HAVE_EM_TILEPRO_MACRO
282 return "elf-tilera-tilepro";
285 #ifdef HAVE_EM_TILEGX_MACRO
287 return "elf-tilera-tilegx";
290 #ifdef HAVE_EM_RISCV_MACRO
296 return "elf-last-arch-number";
298 return "elf-non-official-alpha";
301 std::ostringstream o;
302 o <<
"elf-unknown-arch-value-" << e_machine;
318 size_t section_header_string_index = 0;
319 if (elf_getshdrstrndx (elf_handle, §ion_header_string_index) < 0)
322 Elf_Scn* section = 0;
323 GElf_Shdr header_mem, *header;
324 while ((section = elf_nextscn(elf_handle, section)) != 0)
326 header = gelf_getshdr(section, &header_mem);
330 const char* section_name =
331 elf_strptr(elf_handle, section_header_string_index, header->sh_name);
332 if (section_name && name == section_name)
351 find_section(Elf* elf_handle,
const std::string& name, Elf64_Word section_type)
353 size_t section_header_string_index = 0;
354 if (elf_getshdrstrndx (elf_handle, §ion_header_string_index) < 0)
357 Elf_Scn* section = 0;
358 GElf_Shdr header_mem, *header;
359 while ((section = elf_nextscn(elf_handle, section)) != 0)
361 header = gelf_getshdr(section, &header_mem);
362 if (header == NULL || header->sh_type != section_type)
365 const char* section_name =
366 elf_strptr(elf_handle, section_header_string_index, header->sh_name);
367 if (section_name && name == section_name)
386 Elf_Scn* section =
nullptr;
387 while ((section = elf_nextscn(elf_handle, section)) != 0)
389 GElf_Shdr header_mem, *header;
390 header = gelf_getshdr(section, &header_mem);
391 if (header->sh_type == section_type)
437 if (dynsym || sym_tab)
440 GElf_Ehdr* elf_header = gelf_getehdr(elf_handle, &eh_mem);
441 if (elf_header->e_type == ET_REL
442 || elf_header->e_type == ET_EXEC)
443 return sym_tab ? sym_tab : dynsym;
445 return dynsym ? dynsym : sym_tab;
471 symtab_index = elf_ndxscn(section);
486 size_t& ht_section_index,
487 size_t& symtab_section_index)
490 return NO_HASH_TABLE_KIND;
492 GElf_Shdr header_mem, *section_header;
493 bool found_sysv_ht =
false, found_gnu_ht =
false;
494 for (Elf_Scn* section = elf_nextscn(elf_handle, 0);
496 section = elf_nextscn(elf_handle, section))
498 section_header= gelf_getshdr(section, &header_mem);
499 if (section_header->sh_type != SHT_HASH
500 && section_header->sh_type != SHT_GNU_HASH)
503 ht_section_index = elf_ndxscn(section);
504 symtab_section_index = section_header->sh_link;
506 if (section_header->sh_type == SHT_HASH)
507 found_sysv_ht =
true;
508 else if (section_header->sh_type == SHT_GNU_HASH)
513 return GNU_HASH_TABLE_KIND;
514 else if (found_sysv_ht)
515 return SYSV_HASH_TABLE_KIND;
517 return NO_HASH_TABLE_KIND;
527 {
return find_section(elf_handle,
".text", SHT_PROGBITS);}
545 {
return find_section(elf_handle,
".rodata", SHT_PROGBITS);}
554 {
return find_section(elf_handle,
".data", SHT_PROGBITS);}
563 {
return find_section(elf_handle,
".data1", SHT_PROGBITS);}
574 {
return find_section(elf_handle,
".opd", SHT_PROGBITS);}
593 Elf_Scn*& versym_section,
594 Elf_Scn*& verdef_section,
595 Elf_Scn*& verneed_section)
597 Elf_Scn* section = NULL;
599 Elf_Scn* versym = NULL, *verdef = NULL, *verneed = NULL;
601 while ((section = elf_nextscn(elf_handle, section)) != NULL)
603 GElf_Shdr* h = gelf_getshdr(section, &mem);
604 if (h->sh_type == SHT_GNU_versym)
606 else if (h->sh_type == SHT_GNU_verdef)
608 else if (h->sh_type == SHT_GNU_verneed)
612 if (versym || verdef || verneed)
615 versym_section = versym;
616 verdef_section = verdef;
617 verneed_section = verneed;
632 {
return find_section(elf_handle,
"__ksymtab", SHT_PROGBITS);}
642 {
return find_section(elf_handle,
"__ksymtab_gpl", SHT_PROGBITS);}
655 return find_section(elf_handle,
"__ksymtab_strings", SHT_PROGBITS);
672 size_t target_index = elf_ndxscn(target_section);
676 Elf_Scn* section = 0;
677 GElf_Shdr header_mem, *header;
678 while ((section = elf_nextscn(elf_handle, section)) != 0)
680 header = gelf_getshdr(section, &header_mem);
682 || (header->sh_type != SHT_RELA && header->sh_type != SHT_REL))
685 if (header->sh_info == target_index)
702 Elf_Scn *strtab_section = NULL;
706 GElf_Shdr symtab_shdr_mem, *symtab_shdr;
708 symtab_shdr = gelf_getshdr(symtab_section, &symtab_shdr_mem);
709 strtab_section = elf_getscn(elf_handle, symtab_shdr->sh_link);
712 return strtab_section;
731 Elf_Scn* verdef_section,
734 Elf_Data* verdef_data = elf_getdata(verdef_section, NULL);
735 GElf_Verdef verdef_mem;
736 GElf_Verdef* verdef = gelf_getverdef(verdef_data, 0, &verdef_mem);
737 size_t vd_offset = 0;
739 for (;; vd_offset += verdef->vd_next)
743 if (verdef->vd_ndx == (*versym & 0x7fff))
746 vd_offset += verdef->vd_next;
747 verdef = (verdef->vd_next == 0
749 : gelf_getverdef(verdef_data, vd_offset, &verdef_mem));
754 GElf_Verdaux verdaux_mem;
755 GElf_Verdaux *verdaux = gelf_getverdaux(verdef_data,
756 vd_offset + verdef->vd_aux,
758 GElf_Shdr header_mem;
759 GElf_Shdr* verdef_section_header = gelf_getshdr(verdef_section,
761 size_t verdef_stridx = verdef_section_header->sh_link;
762 version.
str(elf_strptr(elf_handle, verdef_stridx, verdaux->vda_name));
763 if (*versym & 0x8000)
769 if (!verdef || verdef->vd_next == 0)
792 Elf_Scn* verneed_section,
795 if (versym == 0 || elf_handle == 0 || verneed_section == 0)
798 size_t vn_offset = 0;
799 Elf_Data* verneed_data = elf_getdata(verneed_section, NULL);
800 GElf_Verneed verneed_mem;
801 GElf_Verneed* verneed = gelf_getverneed(verneed_data, 0, &verneed_mem);
803 for (;verneed; vn_offset += verneed->vn_next)
805 size_t vna_offset = vn_offset;
806 GElf_Vernaux vernaux_mem;
807 GElf_Vernaux *vernaux = gelf_getvernaux(verneed_data,
808 vn_offset + verneed->vn_aux,
810 for (;vernaux != 0 && verneed;)
812 if (vernaux->vna_other == *versym)
815 vna_offset += verneed->vn_next;
816 verneed = (verneed->vn_next == 0
818 : gelf_getverneed(verneed_data, vna_offset, &verneed_mem));
821 if (verneed != 0 && vernaux != 0 && vernaux->vna_other == *versym)
823 GElf_Shdr header_mem;
824 GElf_Shdr* verneed_section_header = gelf_getshdr(verneed_section,
826 size_t verneed_stridx = verneed_section_header->sh_link;
827 version.
str(elf_strptr(elf_handle,
830 if (*versym & 0x8000)
837 if (!verneed || verneed->vn_next == 0)
865 bool get_def_version,
868 Elf_Scn *versym_section = NULL,
869 *verdef_section = NULL,
870 *verneed_section = NULL;
878 GElf_Versym versym_mem;
879 Elf_Data* versym_data = (versym_section)
880 ? elf_getdata(versym_section, NULL)
882 GElf_Versym* versym = (versym_data)
883 ? gelf_getversym(versym_data, symbol_index, &versym_mem)
886 if (versym == 0 || *versym <= 1)
895 if (*versym == 0x8001)
903 verdef_section, version))
910 verneed_section, version))
929 size_t crc_section_index = crc_symbol->st_shndx;
930 GElf_Addr crc_symbol_address =
932 if (crc_section_index == SHN_ABS)
934 crc_value = crc_symbol_address;
938 Elf_Scn* kcrctab_section = elf_getscn(elf_handle, crc_section_index);
939 if (kcrctab_section == NULL)
942 GElf_Shdr sheader_mem;
943 GElf_Shdr* sheader = gelf_getshdr(kcrctab_section, &sheader_mem);
947 Elf_Data* kcrctab_data = elf_rawdata(kcrctab_section, NULL);
948 if (kcrctab_data == NULL)
951 if (crc_symbol_address < sheader->sh_addr)
954 size_t offset = crc_symbol_address - sheader->sh_addr;
955 if (offset +
sizeof(uint32_t) > kcrctab_data->d_size
956 || offset +
sizeof(uint32_t) > sheader->sh_size)
959 crc_value = *
reinterpret_cast<uint32_t*
>(
960 reinterpret_cast<char*
>(kcrctab_data->d_buf) + offset);
974 GElf_Ehdr* elf_header = gelf_getehdr(elf_handle, &eh_mem);
975 return (elf_header && elf_header->e_machine == EM_PPC64);
987 GElf_Ehdr* elf_header = gelf_getehdr(elf_handle, &eh_mem);
988 return (elf_header && elf_header->e_machine == EM_PPC);
1000 GElf_Ehdr* elf_header = gelf_getehdr(elf_handle, &eh_mem);
1001 return (elf_header && elf_header->e_machine == EM_ARM);
1012 #ifdef HAVE_EM_AARCH64_MACRO
1014 GElf_Ehdr* elf_header = gelf_getehdr(elf_handle, &eh_mem);
1015 return (elf_header && elf_header->e_machine == EM_AARCH64);
1031 GElf_Ehdr elf_header;
1032 gelf_getehdr(elf_handle, &elf_header);
1034 bool is_big_endian = (elf_header.e_ident[EI_DATA] == ELFDATA2MSB);
1037 ABG_ASSERT(elf_header.e_ident[EI_DATA] == ELFDATA2LSB);
1039 return is_big_endian;
1060 template <
typename T>
1063 unsigned char number_of_bytes,
1075 const uint8_t* cur = bytes;
1080 const uint8_t* msb = cur;
1084 for (uint i = 1; i < number_of_bytes; ++i)
1085 res = (res << 8) | ((T)msb[i]);
1091 const uint8_t* lsb = cur;
1094 for (uint i = 1; i < number_of_bytes; ++i)
1095 res = res | (((T)lsb[i]) << i * 8);
1151 return fn_desc_address;
1154 return fn_desc_address;
1160 return fn_desc_address;
1162 GElf_Shdr header_mem;
1164 GElf_Shdr* opd_sheader = gelf_getshdr(opd_section, &header_mem);
1168 size_t fn_desc_offset = fn_desc_address - opd_sheader->sh_addr;
1169 Elf_Data* elf_data = elf_rawdata(opd_section, 0);
1173 if (elf_data->d_size <= fn_desc_offset + 8)
1174 return fn_desc_address;
1178 uint8_t* bytes = (uint8_t*)elf_data->d_buf;
1182 GElf_Addr result = 0;
1184 is_big_endian, result));
1199 return (
find_section(elf_handle,
".modinfo", SHT_PROGBITS)
1201 ".gnu.linkonce.this_module",
1216 "__ksymtab_strings",
1233 GElf_Ehdr elf_header;
1234 gelf_getehdr(elf_handle, &elf_header);
1235 size_t num_segments = elf_header.e_phnum;
1236 GElf_Phdr *program_header = NULL;
1238 bool found_loaded_segment =
false;
1241 for (
unsigned i = 0; i < num_segments; ++i)
1243 program_header = gelf_getphdr(elf_handle, i, &ph_mem);
1244 if (program_header && program_header->p_type == PT_LOAD)
1246 if (!found_loaded_segment)
1248 result = program_header->p_vaddr;
1249 found_loaded_segment =
true;
1252 if (program_header->p_vaddr < result)
1255 result = program_header->p_vaddr;
1259 if (found_loaded_segment)
1261 load_address = result;
1275 unsigned char word_size = 0;
1276 GElf_Ehdr elf_header;
1277 gelf_getehdr(elf_handle, &elf_header);
1278 if (elf_header.e_ident[EI_CLASS] == ELFCLASS32)
1280 else if (elf_header.e_ident[EI_CLASS] == ELFCLASS64)
1295 GElf_Ehdr elf_header;
1296 gelf_getehdr(elf_handle, &elf_header);
1297 return elf_header.e_type == ET_EXEC;
1308 GElf_Ehdr elf_header;
1309 gelf_getehdr(elf_handle, &elf_header);
1310 return elf_header.e_type == ET_DYN;
1333 Elf_Scn* symbol_section = elf_getscn(elf_handle, sym->st_shndx);
1334 GElf_Addr addr = sym->st_value;
1336 if (!symbol_section)
1339 GElf_Ehdr elf_header;
1340 if (!gelf_getehdr(elf_handle, &elf_header))
1343 if (elf_header.e_type != ET_REL)
1346 GElf_Shdr section_header;
1347 if (!gelf_getshdr(symbol_section, §ion_header))
1350 return addr + section_header.sh_addr;
1366 GElf_Shdr sheader_mem;
1367 GElf_Shdr* sheader = gelf_getshdr(section, &sheader_mem);
1369 if (sheader->sh_addr <= addr && addr <= sheader->sh_addr + sheader->sh_size)
1404 Elf64_Sxword data_tag,
1405 vector<string>& dt_tag_data)
1407 size_t num_prog_headers = 0;
1409 if (elf_getphdrnum(elf, &num_prog_headers) < 0)
1413 for (
size_t i = 0; i < num_prog_headers; ++i)
1416 GElf_Phdr *phdr = gelf_getphdr(elf, i, &phdr_mem);
1417 if (phdr == NULL || phdr->p_type != PT_DYNAMIC)
1427 Elf_Scn *dynamic_section = gelf_offscn(elf, phdr->p_offset);
1429 GElf_Shdr *dynamic_section_header = gelf_getshdr(dynamic_section,
1431 if (dynamic_section_header == NULL
1432 || dynamic_section_header->sh_type != SHT_DYNAMIC)
1436 Elf_Data *data = elf_getdata(dynamic_section, NULL);
1441 size_t string_table_index = 0;
1442 ABG_ASSERT (elf_getshdrstrndx(elf, &string_table_index) >= 0);
1444 size_t dynamic_section_header_entry_size = gelf_fsize(elf,
1450 gelf_getshdr(elf_getscn(elf,
1451 dynamic_section_header->sh_link),
1455 size_t num_dynamic_section_entries =
1456 dynamic_section_header->sh_size / dynamic_section_header_entry_size;
1460 for (
size_t j = 0; j < num_dynamic_section_entries; ++j)
1462 GElf_Dyn dynamic_section_mem;
1463 GElf_Dyn *dynamic_section = gelf_getdyn(data,
1465 &dynamic_section_mem);
1466 if (dynamic_section->d_tag == data_tag)
1468 dt_tag_data.push_back(elf_strptr(elf,
1469 dynamic_section_header->sh_link,
1470 dynamic_section->d_un.d_val));
1478 const Dwfl_Callbacks&
1479 initialize_dwfl_callbacks(Dwfl_Callbacks& cb,
1480 char** debug_info_root_path)
1482 cb.find_debuginfo = dwfl_standard_find_debuginfo;
1483 cb.section_address = dwfl_offline_section_address;
1484 cb.debuginfo_path = debug_info_root_path;
1489 create_new_dwfl_handle(Dwfl_Callbacks& cb)
1491 dwfl_sptr handle(dwfl_begin(&cb), dwfl_deleter());
1508 int fd = open(path.c_str(), O_RDONLY);
1512 elf_version (EV_CURRENT);
1513 Elf* elf = elf_begin (fd, ELF_C_READ_MMAP, NULL);
1516 GElf_Ehdr* ehdr = gelf_getehdr (elf, &ehdr_mem);
1520 for (
int i = 0; i < ehdr->e_phnum; ++i)
1523 GElf_Phdr* phdr = gelf_getphdr (elf, i, &phdr_mem);
1525 if (phdr != NULL && phdr->p_type == PT_DYNAMIC)
1527 Elf_Scn* scn = gelf_offscn (elf, phdr->p_offset);
1529 GElf_Shdr* shdr = gelf_getshdr (scn, &shdr_mem);
1530 if (!(shdr == NULL || (shdr->sh_type == SHT_DYNAMIC
1531 || shdr->sh_type == SHT_PROGBITS)))
1536 size_t entsize = (shdr != NULL && shdr->sh_entsize != 0
1538 : gelf_fsize (elf, ELF_T_DYN, 1, EV_CURRENT));
1539 int maxcnt = (shdr != NULL
1540 ? shdr->sh_size / entsize : INT_MAX);
1541 Elf_Data* data = elf_getdata (scn, NULL);
1545 for (
int cnt = 0; cnt < maxcnt; ++cnt)
1548 GElf_Dyn* dyn = gelf_getdyn (data, cnt, &dynmem);
1552 if (dyn->d_tag == DT_NULL)
1555 if (dyn->d_tag != DT_SONAME)
1558 soname = elf_strptr (elf, shdr->sh_link, dyn->d_un.d_val);
Elf_Scn * find_section_by_name(Elf *elf_handle, const std::string &name)
Find and return a section by its name.
bool get_crc_for_symbol(Elf *elf_handle, GElf_Sym *crc_symbol, uint32_t &crc_value)
Return the CRC from the "__crc_" symbol.
unsigned char get_architecture_word_size(Elf *elf_handle)
Return the size of a word for the current architecture.
bool get_version_definition_for_versym(Elf *elf_handle, GElf_Versym *versym, Elf_Scn *verdef_section, elf_symbol::version &version)
Get the version definition (from the SHT_GNU_verdef section) of a given symbol represented by a point...
bool lookup_data_tag_from_dynamic_segment(Elf *elf, Elf64_Sxword data_tag, vector< string > &dt_tag_data)
Get data tag information of an ELF file by looking up into its dynamic segment.
bool address_is_in_opd_section(Elf *elf_handle, Dwarf_Addr addr)
Return true if an address is in the ".opd" section that is present on the ppc64 platform.
bool architecture_is_arm64(Elf *elf_handle)
Test if the architecture of the current binary is arm64.
bool address_is_in_section(Dwarf_Addr addr, Elf_Scn *section)
Test if a given address is in a given section.
Elf_Scn * find_relocation_section(Elf *elf_handle, Elf_Scn *target_section)
Return the .rel{a,} section corresponding to a given section.
bool architecture_is_big_endian(Elf *elf_handle)
Test if the endianness of the current binary is Big Endian.
bool is_dso(Elf *elf_handle)
Test if the elf file being read is a dynamic shared / object.
bool architecture_is_ppc32(Elf *elf_handle)
Test if the architecture of the current binary is ppc32.
bool get_binary_load_address(Elf *elf_handle, GElf_Addr &load_address)
Get the address at which a given binary is loaded in memory.
GElf_Addr maybe_adjust_et_rel_sym_addr_to_abs_addr(Elf *elf_handle, GElf_Sym *sym)
Translate a section-relative symbol address (i.e, symbol value) into an absolute symbol address by ad...
bool get_version_needed_for_versym(Elf *elf_handle, GElf_Versym *versym, Elf_Scn *verneed_section, elf_symbol::version &version)
Get the version needed (from the SHT_GNU_verneed section) to resolve an undefined symbol represented ...
Elf_Scn * find_strtab_for_symtab_section(Elf *elf_handle, Elf_Scn *symtab_section)
Return the string table used by the given symbol table.
bool get_soname_of_elf_file(const string &path, string &soname)
Fetch the SONAME ELF property from an ELF binary file.
bool get_version_for_symbol(Elf *elf_handle, size_t symbol_index, bool get_def_version, elf_symbol::version &version)
Return the version for a symbol that is at a given index in its SHT_SYMTAB section.
elf_symbol::binding stb_to_elf_symbol_binding(unsigned char stb)
Convert an elf symbol binding (given by the ELF{32,64}_ST_BIND macros) into an elf_symbol::binding va...
Elf_Scn * find_ksymtab_gpl_section(Elf *elf_handle)
Return the __ksymtab_gpl section of a linux kernel ELF file (either a vmlinux binary or a kernel modu...
Elf_Scn * find_ksymtab_section(Elf *elf_handle)
Return the __ksymtab section of a linux kernel ELF file (either a vmlinux binary or a kernel module).
Elf_Scn * find_symtab_section(Elf *elf_handle)
Find and return the .symtab section.
std::string e_machine_to_string(GElf_Half e_machine)
Convert the value of the e_machine field of GElf_Ehdr into a string. This is to get a string represen...
Elf_Scn * find_text_section(Elf *elf_handle)
Find and return the .text section.
bool architecture_is_ppc64(Elf *elf_handle)
Test if the architecture of the current binary is ppc64.
Elf_Scn * find_rodata_section(Elf *elf_handle)
Find and return the .rodata section.
Elf_Scn * find_opd_section(Elf *elf_handle)
Return the "Official Procedure descriptors section." This section is named .opd, and is usually prese...
bool is_executable(Elf *elf_handle)
Test if the elf file being read is an executable.
bool read_int_from_array_of_bytes(const uint8_t *bytes, unsigned char number_of_bytes, bool is_big_endian, T &result)
Read N bytes and convert their value into an integer type T.
Elf_Scn * find_data1_section(Elf *elf_handle)
Find and return the .data1 section.
GElf_Addr lookup_ppc64_elf_fn_entry_point_address(Elf *elf_handle, GElf_Addr fn_desc_address)
Lookup the address of the function entry point that corresponds to the address of a given function de...
elf_symbol::visibility stv_to_elf_symbol_visibility(unsigned char stv)
Convert an ELF symbol visiblity given by the symbols ->st_other data member as returned by the GELF_S...
bool find_symbol_table_section_index(Elf *elf_handle, size_t &symtab_index)
Find the index (in the section headers table) of the symbol table section.
bool get_symbol_versionning_sections(Elf *elf_handle, Elf_Scn *&versym_section, Elf_Scn *&verdef_section, Elf_Scn *&verneed_section)
Return the SHT_GNU_versym, SHT_GNU_verdef and SHT_GNU_verneed sections that are involved in symbol ve...
Elf_Scn * find_bss_section(Elf *elf_handle)
Find and return the .bss section.
bool read_uint64_from_array_of_bytes(const uint8_t *bytes, bool is_big_endian, uint64_t &result)
Read 8 bytes and convert their value into an uint64_t.
Elf_Scn * find_dynsym_section(Elf *elf_handle)
Find and return the .symtab section.
Elf_Scn * find_section(Elf *elf_handle, const std::string &name, Elf64_Word section_type)
Find and return a section by its name and its type.
elf_symbol::type stt_to_elf_symbol_type(unsigned char stt)
Convert an elf symbol type (given by the ELF{32,64}_ST_TYPE macros) into an elf_symbol::type value.
bool architecture_is_arm32(Elf *elf_handle)
Test if the architecture of the current binary is arm32.
Elf_Scn * find_symbol_table_section(Elf *elf_handle)
Find the symbol table.
Elf_Scn * find_data_section(Elf *elf_handle)
Find and return the .data section.
bool is_linux_kernel_module(Elf *elf_handle)
Test if the ELF binary denoted by a given ELF handle is a Linux Kernel Module.
Elf_Scn * find_ksymtab_strings_section(Elf *elf_handle)
Find the __ksymtab_strings section of a Linux kernel binary.
bool is_linux_kernel(Elf *elf_handle)
Test if the ELF binary denoted by a given ELF handle is a Linux Kernel binary (either vmlinux or a ke...
hash_table_kind find_hash_table_section_index(Elf *elf_handle, size_t &ht_section_index, size_t &symtab_section_index)
Get the offset offset of the hash table section.
This contains a set of ELF utilities used by the dwarf reader.
#define ABG_ASSERT(cond)
This is a wrapper around the 'assert' glibc call. It allows for its argument to have side effects,...
The abstraction of the version of an ELF symbol.
bool is_default() const
Getter for the 'is_default' property of the version.
const string & str() const
Getter for the version name.
binding
The binding of a symbol.
type
The type of a symbol.
visibility
The visibility of the symbol.
Toplevel namespace for libabigail.