this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

darling-coredump: Fix alignment issues with ELF notes

Also take into account that NT_FILE entries may be larger than memory regions we're checking

+4 -4
+4 -4
src/hosttools/src/coredump/main.c
··· 108 108 }; 109 109 110 110 static const void* note_data(const Elf64_Nhdr* note) { 111 - return note_name(note) + round_up_pow2(note->n_namesz, 8); 111 + return note_name(note) + round_up_pow2(note->n_namesz, 4); 112 112 }; 113 113 114 114 static const Elf64_Nhdr* find_next_note(const Elf64_Nhdr* note) { 115 - uint64_t length = sizeof(*note) + round_up_pow2(note->n_namesz, 8) + round_up_pow2(note->n_descsz, 8); 115 + uint64_t length = sizeof(*note) + round_up_pow2(note->n_namesz, 4) + round_up_pow2(note->n_descsz, 4); 116 116 return (Elf64_Nhdr*)((char*)note + length); 117 117 }; 118 118 ··· 378 378 const struct nt_file_entry* entry = &entries[i]; 379 379 const char* filename = cprm.nt_file_filenames[i]; 380 380 381 - if (entry->start != vm_area->memory_address) { 381 + if (entry->start > vm_area->memory_address || entry->end < vm_area->memory_address + vm_area->memory_size) { 382 382 continue; 383 383 } 384 384 385 385 vm_area->filename = filename; 386 386 vm_area->filename_length = strlen(vm_area->filename); 387 - vm_area->file_offset = entry->offset * cprm.nt_file->page_size; 387 + vm_area->file_offset = (entry->offset * cprm.nt_file->page_size) + (vm_area->memory_address - entry->start); 388 388 vm_area->file_size = entry->end - entry->start; 389 389 390 390 break;