14 #include <elfutils/libdwfl.h>
39 return elf_symbol::NOTYPE_TYPE;
41 return elf_symbol::OBJECT_TYPE;
43 return elf_symbol::FUNC_TYPE;
45 return elf_symbol::SECTION_TYPE;
47 return elf_symbol::FILE_TYPE;
49 return elf_symbol::COMMON_TYPE;
51 return elf_symbol::TLS_TYPE;
53 return elf_symbol::GNU_IFUNC_TYPE;
75 return elf_symbol::LOCAL_BINDING;
77 return elf_symbol::GLOBAL_BINDING;
79 return elf_symbol::WEAK_BINDING;
81 return elf_symbol::GNU_UNIQUE_BINDING;
101 return elf_symbol::DEFAULT_VISIBILITY;
103 return elf_symbol::INTERNAL_VISIBILITY;
105 return elf_symbol::HIDDEN_VISIBILITY;
107 return elf_symbol::PROTECTED_VISIBILITY;
126 return "elf-no-arch";
128 return "elf-att-we-32100";
130 return "elf-sun-sparc";
132 return "elf-intel-80386";
134 return "elf-motorola-68k";
136 return "elf-motorola-88k";
138 return "elf-intel-80860";
140 return "elf-mips-r3000-be";
142 return "elf-ibm-s370";
144 return "elf-mips-r3000-le";
146 return "elf-hp-parisc";
148 return "elf-fujitsu-vpp500";
150 return "elf-sun-sparc-v8plus";
152 return "elf-intel-80960";
154 return "elf-powerpc";
156 return "elf-powerpc-64";
158 return "elf-ibm-s390";
160 return "elf-nec-v800";
162 return "elf-fujitsu-fr20";
164 return "elf-trw-rh32";
166 return "elf-motorola-rce";
170 return "elf-digital-alpha";
172 return "elf-hitachi-sh";
174 return "elf-sun-sparc-v9-64";
176 return "elf-siemens-tricore";
178 return "elf-argonaut-risc-core";
180 return "elf-hitachi-h8-300";
182 return "elf-hitachi-h8-300h";
184 return "elf-hitachi-h8s";
186 return "elf-hitachi-h8-500";
188 return "elf-intel-ia-64";
190 return "elf-stanford-mips-x";
192 return "elf-motorola-coldfire";
194 return "elf-motorola-68hc12";
196 return "elf-fujitsu-mma";
198 return "elf-siemens-pcp";
200 return "elf-sony-ncpu";
202 return "elf-denso-ndr1";
204 return "elf-motorola-starcore";
206 return "elf-toyota-me16";
208 return "elf-stm-st100";
210 return "elf-alc-tinyj";
212 return "elf-amd-x86_64";
214 return "elf-sony-pdsp";
216 return "elf-siemens-fx66";
218 return "elf-stm-st9+";
220 return "elf-stm-st7";
222 return "elf-motorola-68hc16";
224 return "elf-motorola-68hc11";
226 return "elf-motorola-68hc08";
228 return "elf-motorola-68hc05";
232 return "elf-stm-st19";
234 return "elf-digital-vax";
236 return "elf-axis-cris";
238 return "elf-infineon-javelin";
240 return "elf-firepath";
242 return "elf-lsi-zsp";
244 return "elf-don-knuth-mmix";
246 return "elf-harvard-huany";
248 return "elf-sitera-prism";
250 return "elf-atmel-avr";
252 return "elf-fujistu-fr30";
254 return "elf-mitsubishi-d10v";
256 return "elf-mitsubishi-d30v";
258 return "elf-nec-v850";
260 return "elf-mitsubishi-m32r";
262 return "elf-matsushita-mn10300";
264 return "elf-matsushita-mn10200";
266 return "elf-picojava";
268 return "elf-openrisc-32";
272 return "elf-tensilica-xtensa";
274 #ifdef HAVE_EM_AARCH64_MACRO
276 return "elf-arm-aarch64";
279 #ifdef HAVE_EM_TILEPRO_MACRO
281 return "elf-tilera-tilepro";
284 #ifdef HAVE_EM_TILEGX_MACRO
286 return "elf-tilera-tilegx";
290 return "elf-last-arch-number";
292 return "elf-non-official-alpha";
295 std::ostringstream o;
296 o <<
"elf-unknown-arch-value-" << e_machine;
312 size_t section_header_string_index = 0;
313 if (elf_getshdrstrndx (elf_handle, §ion_header_string_index) < 0)
316 Elf_Scn* section = 0;
317 GElf_Shdr header_mem, *header;
318 while ((section = elf_nextscn(elf_handle, section)) != 0)
320 header = gelf_getshdr(section, &header_mem);
324 const char* section_name =
325 elf_strptr(elf_handle, section_header_string_index, header->sh_name);
326 if (section_name && name == section_name)
345 find_section(Elf* elf_handle,
const std::string& name, Elf64_Word section_type)
347 size_t section_header_string_index = 0;
348 if (elf_getshdrstrndx (elf_handle, §ion_header_string_index) < 0)
351 Elf_Scn* section = 0;
352 GElf_Shdr header_mem, *header;
353 while ((section = elf_nextscn(elf_handle, section)) != 0)
355 header = gelf_getshdr(section, &header_mem);
356 if (header == NULL || header->sh_type != section_type)
359 const char* section_name =
360 elf_strptr(elf_handle, section_header_string_index, header->sh_name);
361 if (section_name && name == section_name)
380 Elf_Scn* section =
nullptr;
381 while ((section = elf_nextscn(elf_handle, section)) != 0)
383 GElf_Shdr header_mem, *header;
384 header = gelf_getshdr(section, &header_mem);
385 if (header->sh_type == section_type)
431 if (dynsym || sym_tab)
434 GElf_Ehdr* elf_header = gelf_getehdr(elf_handle, &eh_mem);
435 if (elf_header->e_type == ET_REL
436 || elf_header->e_type == ET_EXEC)
437 return sym_tab ? sym_tab : dynsym;
439 return dynsym ? dynsym : sym_tab;
465 symtab_index = elf_ndxscn(section);
480 size_t& ht_section_index,
481 size_t& symtab_section_index)
484 return NO_HASH_TABLE_KIND;
486 GElf_Shdr header_mem, *section_header;
487 bool found_sysv_ht =
false, found_gnu_ht =
false;
488 for (Elf_Scn* section = elf_nextscn(elf_handle, 0);
490 section = elf_nextscn(elf_handle, section))
492 section_header= gelf_getshdr(section, &header_mem);
493 if (section_header->sh_type != SHT_HASH
494 && section_header->sh_type != SHT_GNU_HASH)
497 ht_section_index = elf_ndxscn(section);
498 symtab_section_index = section_header->sh_link;
500 if (section_header->sh_type == SHT_HASH)
501 found_sysv_ht =
true;
502 else if (section_header->sh_type == SHT_GNU_HASH)
507 return GNU_HASH_TABLE_KIND;
508 else if (found_sysv_ht)
509 return SYSV_HASH_TABLE_KIND;
511 return NO_HASH_TABLE_KIND;
521 {
return find_section(elf_handle,
".text", SHT_PROGBITS);}
539 {
return find_section(elf_handle,
".rodata", SHT_PROGBITS);}
548 {
return find_section(elf_handle,
".data", SHT_PROGBITS);}
557 {
return find_section(elf_handle,
".data1", SHT_PROGBITS);}
568 {
return find_section(elf_handle,
".opd", SHT_PROGBITS);}
587 Elf_Scn*& versym_section,
588 Elf_Scn*& verdef_section,
589 Elf_Scn*& verneed_section)
591 Elf_Scn* section = NULL;
593 Elf_Scn* versym = NULL, *verdef = NULL, *verneed = NULL;
595 while ((section = elf_nextscn(elf_handle, section)) != NULL)
597 GElf_Shdr* h = gelf_getshdr(section, &mem);
598 if (h->sh_type == SHT_GNU_versym)
600 else if (h->sh_type == SHT_GNU_verdef)
602 else if (h->sh_type == SHT_GNU_verneed)
606 if (versym || verdef || verneed)
609 versym_section = versym;
610 verdef_section = verdef;
611 verneed_section = verneed;
626 {
return find_section(elf_handle,
"__ksymtab", SHT_PROGBITS);}
636 {
return find_section(elf_handle,
"__ksymtab_gpl", SHT_PROGBITS);}
649 return find_section(elf_handle,
"__ksymtab_strings", SHT_PROGBITS);
666 size_t target_index = elf_ndxscn(target_section);
670 Elf_Scn* section = 0;
671 GElf_Shdr header_mem, *header;
672 while ((section = elf_nextscn(elf_handle, section)) != 0)
674 header = gelf_getshdr(section, &header_mem);
676 || (header->sh_type != SHT_RELA && header->sh_type != SHT_REL))
679 if (header->sh_info == target_index)
696 Elf_Scn *strtab_section = NULL;
700 GElf_Shdr symtab_shdr_mem, *symtab_shdr;
702 symtab_shdr = gelf_getshdr(symtab_section, &symtab_shdr_mem);
703 strtab_section = elf_getscn(elf_handle, symtab_shdr->sh_link);
706 return strtab_section;
725 Elf_Scn* verdef_section,
728 Elf_Data* verdef_data = elf_getdata(verdef_section, NULL);
729 GElf_Verdef verdef_mem;
730 GElf_Verdef* verdef = gelf_getverdef(verdef_data, 0, &verdef_mem);
731 size_t vd_offset = 0;
733 for (;; vd_offset += verdef->vd_next)
737 if (verdef->vd_ndx == (*versym & 0x7fff))
740 vd_offset += verdef->vd_next;
741 verdef = (verdef->vd_next == 0
743 : gelf_getverdef(verdef_data, vd_offset, &verdef_mem));
748 GElf_Verdaux verdaux_mem;
749 GElf_Verdaux *verdaux = gelf_getverdaux(verdef_data,
750 vd_offset + verdef->vd_aux,
752 GElf_Shdr header_mem;
753 GElf_Shdr* verdef_section_header = gelf_getshdr(verdef_section,
755 size_t verdef_stridx = verdef_section_header->sh_link;
756 version.
str(elf_strptr(elf_handle, verdef_stridx, verdaux->vda_name));
757 if (*versym & 0x8000)
763 if (!verdef || verdef->vd_next == 0)
786 Elf_Scn* verneed_section,
789 if (versym == 0 || elf_handle == 0 || verneed_section == 0)
792 size_t vn_offset = 0;
793 Elf_Data* verneed_data = elf_getdata(verneed_section, NULL);
794 GElf_Verneed verneed_mem;
795 GElf_Verneed* verneed = gelf_getverneed(verneed_data, 0, &verneed_mem);
797 for (;verneed; vn_offset += verneed->vn_next)
799 size_t vna_offset = vn_offset;
800 GElf_Vernaux vernaux_mem;
801 GElf_Vernaux *vernaux = gelf_getvernaux(verneed_data,
802 vn_offset + verneed->vn_aux,
804 for (;vernaux != 0 && verneed;)
806 if (vernaux->vna_other == *versym)
809 vna_offset += verneed->vn_next;
810 verneed = (verneed->vn_next == 0
812 : gelf_getverneed(verneed_data, vna_offset, &verneed_mem));
815 if (verneed != 0 && vernaux != 0 && vernaux->vna_other == *versym)
817 GElf_Shdr header_mem;
818 GElf_Shdr* verneed_section_header = gelf_getshdr(verneed_section,
820 size_t verneed_stridx = verneed_section_header->sh_link;
821 version.
str(elf_strptr(elf_handle,
824 if (*versym & 0x8000)
831 if (!verneed || verneed->vn_next == 0)
859 bool get_def_version,
862 Elf_Scn *versym_section = NULL,
863 *verdef_section = NULL,
864 *verneed_section = NULL;
872 GElf_Versym versym_mem;
873 Elf_Data* versym_data = (versym_section)
874 ? elf_getdata(versym_section, NULL)
876 GElf_Versym* versym = (versym_data)
877 ? gelf_getversym(versym_data, symbol_index, &versym_mem)
880 if (versym == 0 || *versym <= 1)
889 if (*versym == 0x8001)
897 verdef_section, version))
904 verneed_section, version))
923 size_t crc_section_index = crc_symbol->st_shndx;
924 GElf_Addr crc_symbol_address =
926 if (crc_section_index == SHN_ABS)
928 crc_value = crc_symbol_address;
932 Elf_Scn* kcrctab_section = elf_getscn(elf_handle, crc_section_index);
933 if (kcrctab_section == NULL)
936 GElf_Shdr sheader_mem;
937 GElf_Shdr* sheader = gelf_getshdr(kcrctab_section, &sheader_mem);
941 Elf_Data* kcrctab_data = elf_rawdata(kcrctab_section, NULL);
942 if (kcrctab_data == NULL)
945 if (crc_symbol_address < sheader->sh_addr)
948 size_t offset = crc_symbol_address - sheader->sh_addr;
949 if (offset +
sizeof(uint32_t) > kcrctab_data->d_size
950 || offset +
sizeof(uint32_t) > sheader->sh_size)
953 crc_value = *
reinterpret_cast<uint32_t*
>(
954 reinterpret_cast<char*
>(kcrctab_data->d_buf) + offset);
968 GElf_Ehdr* elf_header = gelf_getehdr(elf_handle, &eh_mem);
969 return (elf_header && elf_header->e_machine == EM_PPC64);
981 GElf_Ehdr* elf_header = gelf_getehdr(elf_handle, &eh_mem);
982 return (elf_header && elf_header->e_machine == EM_PPC);
994 GElf_Ehdr* elf_header = gelf_getehdr(elf_handle, &eh_mem);
995 return (elf_header && elf_header->e_machine == EM_ARM);
1006 #ifdef HAVE_EM_AARCH64_MACRO
1008 GElf_Ehdr* elf_header = gelf_getehdr(elf_handle, &eh_mem);
1009 return (elf_header && elf_header->e_machine == EM_AARCH64);
1025 GElf_Ehdr elf_header;
1026 gelf_getehdr(elf_handle, &elf_header);
1028 bool is_big_endian = (elf_header.e_ident[EI_DATA] == ELFDATA2MSB);
1031 ABG_ASSERT(elf_header.e_ident[EI_DATA] == ELFDATA2LSB);
1033 return is_big_endian;
1054 template <
typename T>
1057 unsigned char number_of_bytes,
1069 const uint8_t* cur = bytes;
1074 const uint8_t* msb = cur;
1078 for (uint i = 1; i < number_of_bytes; ++i)
1079 res = (res << 8) | ((T)msb[i]);
1085 const uint8_t* lsb = cur;
1088 for (uint i = 1; i < number_of_bytes; ++i)
1089 res = res | (((T)lsb[i]) << i * 8);
1145 return fn_desc_address;
1148 return fn_desc_address;
1154 return fn_desc_address;
1156 GElf_Shdr header_mem;
1158 GElf_Shdr* opd_sheader = gelf_getshdr(opd_section, &header_mem);
1162 size_t fn_desc_offset = fn_desc_address - opd_sheader->sh_addr;
1163 Elf_Data* elf_data = elf_rawdata(opd_section, 0);
1167 if (elf_data->d_size <= fn_desc_offset + 8)
1168 return fn_desc_address;
1172 uint8_t* bytes = (uint8_t*)elf_data->d_buf;
1176 GElf_Addr result = 0;
1178 is_big_endian, result));
1193 return (
find_section(elf_handle,
".modinfo", SHT_PROGBITS)
1195 ".gnu.linkonce.this_module",
1210 "__ksymtab_strings",
1227 GElf_Ehdr elf_header;
1228 gelf_getehdr(elf_handle, &elf_header);
1229 size_t num_segments = elf_header.e_phnum;
1230 GElf_Phdr *program_header = NULL;
1232 bool found_loaded_segment =
false;
1235 for (
unsigned i = 0; i < num_segments; ++i)
1237 program_header = gelf_getphdr(elf_handle, i, &ph_mem);
1238 if (program_header && program_header->p_type == PT_LOAD)
1240 if (!found_loaded_segment)
1242 result = program_header->p_vaddr;
1243 found_loaded_segment =
true;
1246 if (program_header->p_vaddr < result)
1249 result = program_header->p_vaddr;
1253 if (found_loaded_segment)
1255 load_address = result;
1269 unsigned char word_size = 0;
1270 GElf_Ehdr elf_header;
1271 gelf_getehdr(elf_handle, &elf_header);
1272 if (elf_header.e_ident[EI_CLASS] == ELFCLASS32)
1274 else if (elf_header.e_ident[EI_CLASS] == ELFCLASS64)
1289 GElf_Ehdr elf_header;
1290 gelf_getehdr(elf_handle, &elf_header);
1291 return elf_header.e_type == ET_EXEC;
1302 GElf_Ehdr elf_header;
1303 gelf_getehdr(elf_handle, &elf_header);
1304 return elf_header.e_type == ET_DYN;
1327 Elf_Scn* symbol_section = elf_getscn(elf_handle, sym->st_shndx);
1328 GElf_Addr addr = sym->st_value;
1330 if (!symbol_section)
1333 GElf_Ehdr elf_header;
1334 if (!gelf_getehdr(elf_handle, &elf_header))
1337 if (elf_header.e_type != ET_REL)
1340 GElf_Shdr section_header;
1341 if (!gelf_getshdr(symbol_section, §ion_header))
1344 return addr + section_header.sh_addr;
1360 GElf_Shdr sheader_mem;
1361 GElf_Shdr* sheader = gelf_getshdr(section, &sheader_mem);
1363 if (sheader->sh_addr <= addr && addr <= sheader->sh_addr + sheader->sh_size)
1398 Elf64_Sxword data_tag,
1399 vector<string>& dt_tag_data)
1401 size_t num_prog_headers = 0;
1403 if (elf_getphdrnum(elf, &num_prog_headers) < 0)
1407 for (
size_t i = 0; i < num_prog_headers; ++i)
1410 GElf_Phdr *phdr = gelf_getphdr(elf, i, &phdr_mem);
1411 if (phdr == NULL || phdr->p_type != PT_DYNAMIC)
1421 Elf_Scn *dynamic_section = gelf_offscn(elf, phdr->p_offset);
1423 GElf_Shdr *dynamic_section_header = gelf_getshdr(dynamic_section,
1425 if (dynamic_section_header == NULL
1426 || dynamic_section_header->sh_type != SHT_DYNAMIC)
1430 Elf_Data *data = elf_getdata(dynamic_section, NULL);
1435 size_t string_table_index = 0;
1436 ABG_ASSERT (elf_getshdrstrndx(elf, &string_table_index) >= 0);
1438 size_t dynamic_section_header_entry_size = gelf_fsize(elf,
1444 gelf_getshdr(elf_getscn(elf,
1445 dynamic_section_header->sh_link),
1449 size_t num_dynamic_section_entries =
1450 dynamic_section_header->sh_size / dynamic_section_header_entry_size;
1454 for (
size_t j = 0; j < num_dynamic_section_entries; ++j)
1456 GElf_Dyn dynamic_section_mem;
1457 GElf_Dyn *dynamic_section = gelf_getdyn(data,
1459 &dynamic_section_mem);
1460 if (dynamic_section->d_tag == data_tag)
1462 dt_tag_data.push_back(elf_strptr(elf,
1463 dynamic_section_header->sh_link,
1464 dynamic_section->d_un.d_val));
1472 const Dwfl_Callbacks&
1473 initialize_dwfl_callbacks(Dwfl_Callbacks& cb,
1474 char** debug_info_root_path)
1476 cb.find_debuginfo = dwfl_standard_find_debuginfo;
1477 cb.section_address = dwfl_offline_section_address;
1478 cb.debuginfo_path = debug_info_root_path;
1483 create_new_dwfl_handle(Dwfl_Callbacks& cb)
1485 dwfl_sptr handle(dwfl_begin(&cb), dwfl_deleter());
1502 int fd = open(path.c_str(), O_RDONLY);
1506 elf_version (EV_CURRENT);
1507 Elf* elf = elf_begin (fd, ELF_C_READ_MMAP, NULL);
1510 GElf_Ehdr* ehdr = gelf_getehdr (elf, &ehdr_mem);
1514 for (
int i = 0; i < ehdr->e_phnum; ++i)
1517 GElf_Phdr* phdr = gelf_getphdr (elf, i, &phdr_mem);
1519 if (phdr != NULL && phdr->p_type == PT_DYNAMIC)
1521 Elf_Scn* scn = gelf_offscn (elf, phdr->p_offset);
1523 GElf_Shdr* shdr = gelf_getshdr (scn, &shdr_mem);
1524 if (!(shdr == NULL || (shdr->sh_type == SHT_DYNAMIC
1525 || shdr->sh_type == SHT_PROGBITS)))
1530 size_t entsize = (shdr != NULL && shdr->sh_entsize != 0
1532 : gelf_fsize (elf, ELF_T_DYN, 1, EV_CURRENT));
1533 int maxcnt = (shdr != NULL
1534 ? shdr->sh_size / entsize : INT_MAX);
1535 Elf_Data* data = elf_getdata (scn, NULL);
1539 for (
int cnt = 0; cnt < maxcnt; ++cnt)
1542 GElf_Dyn* dyn = gelf_getdyn (data, cnt, &dynmem);
1546 if (dyn->d_tag == DT_NULL)
1549 if (dyn->d_tag != DT_SONAME)
1552 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.