lib: launch: implement GLOB_DAT and RELATIVE relocations
This commit is contained in:
@@ -334,6 +334,28 @@ static enum launch_status do_rela(struct elf_image *image, elf_rela_t *rela)
|
||||
ELF64_R_SYM(rela->r_info),
|
||||
rela->r_addend);
|
||||
break;
|
||||
case R_X86_64_GLOB_DAT:
|
||||
sym = get_dynsym(image, ELF64_R_SYM(rela->r_info));
|
||||
if (!sym) {
|
||||
return LAUNCH_ERR_MISSING_SYMBOL;
|
||||
}
|
||||
|
||||
*(uint64_t *)(image->e_local_base + rela->r_offset)
|
||||
= image->e_remote_base + sym->st_value + rela->r_addend;
|
||||
kern_tracef(
|
||||
"GLOB_DAT: offset=%zx, symbol=%zu, addend=%zx",
|
||||
rela->r_offset,
|
||||
ELF64_R_SYM(rela->r_info),
|
||||
rela->r_addend);
|
||||
break;
|
||||
case R_X86_64_RELATIVE:
|
||||
*(uint64_t *)(image->e_local_base + rela->r_offset)
|
||||
= image->e_remote_base + rela->r_addend;
|
||||
kern_tracef(
|
||||
"RELATIVE: offset=%zx, addend=%zx",
|
||||
rela->r_offset,
|
||||
rela->r_addend);
|
||||
break;
|
||||
default:
|
||||
kern_trace("Unknown relocation type");
|
||||
return LAUNCH_ERR_UNSUPPORTED_EXECUTABLE;
|
||||
|
||||
Reference in New Issue
Block a user