diff --git a/src/system/kernel/arch/x86/arch_elf.cpp b/src/system/kernel/arch/x86/arch_elf.cpp index f785e20645..cb1d0f2363 100644 --- a/src/system/kernel/arch/x86/arch_elf.cpp +++ b/src/system/kernel/arch/x86/arch_elf.cpp @@ -239,7 +239,7 @@ arch_elf_relocate_rela(struct elf_image_info *image, // Calculate the relocation value. Elf64_Addr relocValue; - switch(type) { + switch (type) { case R_X86_64_NONE: continue; case R_X86_64_64: @@ -269,7 +269,10 @@ arch_elf_relocate_rela(struct elf_image_info *image, return B_BAD_ADDRESS; } - *(Elf64_Addr *)relocAddr = relocValue; + if (type == R_X86_64_PC32) + *(Elf32_Addr *)relocAddr = relocValue; + else + *(Elf64_Addr *)relocAddr = relocValue; #endif } diff --git a/src/system/runtime_loader/arch/x86_64/arch_relocate.cpp b/src/system/runtime_loader/arch/x86_64/arch_relocate.cpp index fda4c27c33..90a62bf237 100644 --- a/src/system/runtime_loader/arch/x86_64/arch_relocate.cpp +++ b/src/system/runtime_loader/arch/x86_64/arch_relocate.cpp @@ -43,7 +43,7 @@ relocate_rela(image_t* rootImage, image_t* image, Elf64_Rela* rel, // Calculate the relocation value. Elf64_Addr relocValue; - switch(type) { + switch (type) { case R_X86_64_NONE: continue; case R_X86_64_64: @@ -70,7 +70,10 @@ relocate_rela(image_t* rootImage, image_t* image, Elf64_Rela* rel, return B_BAD_DATA; } - *(Elf64_Addr *)relocAddr = relocValue; + if (type == R_X86_64_PC32 || type == R_X86_64_DTPOFF32) + *(Elf32_Addr *)relocAddr = relocValue; + else + *(Elf64_Addr *)relocAddr = relocValue; } return B_OK;