Skip to content

Commit

Permalink
exe/elf: Take mapping alignment into account for relocations
Browse files Browse the repository at this point in the history
  • Loading branch information
Qwinci committed Nov 4, 2023
1 parent 94e2238 commit ffba484
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion kernel/src/exe/elf_loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -386,8 +386,9 @@ int elf_load_from_file(Task* task, VNode* node, LoadedElf* res) {
return ERR_INVALID_ARG;
}

usize align = phdr_vaddr & (PAGE_SIZE - 1);
if (type == R_AMD64_RELATIVE) {
*offset(m->mapping, u64*, addr - phdr_vaddr) = base + rela->r_addend;
*offset(m->mapping, u64*, align + addr - phdr_vaddr) = base + rela->r_addend;
}
else {
panic("unsupported elf relocation type %u\n", type);
Expand Down

0 comments on commit ffba484

Please sign in to comment.