- Dwarf *dwarf = dwarf_begin(fd, DWARF_C_READ);
- if (dwarf == NULL)
- xbt_die("Your program must be compiled with -g (%s)",
- info->file_name.c_str());
- // For each compilation unit:
- Dwarf_Off offset = 0;
- Dwarf_Off next_offset = 0;
- size_t length;
- while (dwarf_nextcu(dwarf, offset, &next_offset, &length, NULL, NULL, NULL) ==
- 0) {
- Dwarf_Die unit_die;
- if (dwarf_offdie(dwarf, offset + length, &unit_die) != NULL) {
-
- // For each child DIE:
- Dwarf_Die child;
- int res;
- for (res = dwarf_child(&unit_die, &child); res == 0;
- res = dwarf_siblingof(&child, &child)) {
- MC_dwarf_handle_die(info, &child, &unit_die, NULL, NULL);
- }
-
- }
- offset = next_offset;
+ Elf* elf = elf_begin(fd, ELF_C_READ, nullptr);
+ if (elf == nullptr)
+ xbt_die("Not an ELF file 1");
+ Elf_Kind kind = elf_kind(elf);
+ if (kind != ELF_K_ELF)
+ xbt_die("Not an ELF file 2");
+
+ Elf64_Half type = get_type(elf);
+ if (type == ET_EXEC)
+ info->flags |= simgrid::mc::ObjectInformation::Executable;
+
+ Dwarf* dwarf = dwarf_begin_elf (elf, DWARF_C_READ, nullptr);
+ // Dwarf *dwarf = dwarf_begin(fd, DWARF_C_READ);
+ if (dwarf != nullptr) {
+ read_dwarf_info(info, dwarf);
+ dwarf_end(dwarf);
+ dwarf = nullptr;