Skip to content

Commit e65c98e

Browse files
committed
Fix relocations
1 parent 8a8229b commit e65c98e

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

kernel/src/kernel/tasking/elf/elf_object.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -329,13 +329,11 @@ void elfObjectApplyRelocations(g_fd file, g_elf_object* object)
329329
break;
330330
}
331331

332-
if(shdr.sh_type != SHT_REL)
333-
{
332+
if(shdr.sh_type != SHT_RELA)
334333
continue;
335-
}
336334

337-
auto entry = (Elf64_Rel*) (object->baseAddress + shdr.sh_addr);
338-
while(entry < (Elf64_Rel*) (object->baseAddress + shdr.sh_addr + shdr.sh_size))
335+
auto entry = (Elf64_Rela*) (object->baseAddress + shdr.sh_addr);
336+
while(entry < (Elf64_Rela*) (object->baseAddress + shdr.sh_addr + shdr.sh_size))
339337
{
340338
uint32_t symbolIndex = ELF64_R_SYM(entry->r_info);
341339
uint8_t type = ELF64_R_TYPE(entry->r_info);
@@ -392,7 +390,7 @@ void elfObjectApplyRelocations(g_fd file, g_elf_object* object)
392390
{
393391
if(ELF64_ST_BIND(symbol->st_info) != STB_WEAK)
394392
logDebug("%! missing symbol '%s' (%h, bind: %i)", "elf", symbolName, cP,
395-
ELF64_ST_BIND(symbol->st_info));
393+
ELF64_ST_BIND(symbol->st_info));
396394

397395
cS = 0;
398396
}
@@ -420,7 +418,7 @@ void elfObjectApplyRelocations(g_fd file, g_elf_object* object)
420418
else if(type == R_X86_64_RELATIVE)
421419
{
422420
uint64_t cB = object->baseAddress;
423-
int32_t cA = *((int32_t*) cP);
421+
int64_t cA = *((int64_t*) cP);
424422
*((uint64_t*) cP) = cB + cA;
425423
}
426424
else if(type == R_X86_64_64)

0 commit comments

Comments
 (0)