ld: implement GLOB_DAT and 64 relocation types
This commit is contained in:
+29
-1
@@ -183,7 +183,7 @@ static int map_image(struct elf_image *image)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
kern_logf("ld: image %s -> %zx", image->e_leaf.l_name, image->e_base);
|
kern_tracef("ld: image %s -> %zx", image->e_leaf.l_name, image->e_base);
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -291,6 +291,34 @@ static int do_rela(struct elf_image *image, elf_rela_t *rela, bool lazy)
|
|||||||
ELF64_R_SYM(rela->r_info),
|
ELF64_R_SYM(rela->r_info),
|
||||||
rela->r_addend);
|
rela->r_addend);
|
||||||
break;
|
break;
|
||||||
|
case R_X86_64_GLOB_DAT:
|
||||||
|
sym = get_dynsym(image, ELF64_R_SYM(rela->r_info));
|
||||||
|
if (!sym) {
|
||||||
|
return ENOEXEC;
|
||||||
|
}
|
||||||
|
|
||||||
|
*(uint64_t *)(image->e_base + rela->r_offset)
|
||||||
|
= image->e_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_64:
|
||||||
|
sym = get_dynsym(image, ELF64_R_SYM(rela->r_info));
|
||||||
|
if (!sym) {
|
||||||
|
return ENOEXEC;
|
||||||
|
}
|
||||||
|
|
||||||
|
*(uint64_t *)(image->e_base + rela->r_offset)
|
||||||
|
= image->e_base + sym->st_value + rela->r_addend;
|
||||||
|
kern_tracef(
|
||||||
|
"64: offset=%zx, symbol=%zu, addend=%zx",
|
||||||
|
rela->r_offset,
|
||||||
|
ELF64_R_SYM(rela->r_info),
|
||||||
|
rela->r_addend);
|
||||||
|
break;
|
||||||
case R_X86_64_RELATIVE:
|
case R_X86_64_RELATIVE:
|
||||||
*(uint64_t *)(image->e_base + rela->r_offset)
|
*(uint64_t *)(image->e_base + rela->r_offset)
|
||||||
= image->e_base + rela->r_addend;
|
= image->e_base + rela->r_addend;
|
||||||
|
|||||||
Reference in New Issue
Block a user