mirror of
https://github.com/JakeHillion/drgn.git
synced 2024-12-22 17:23:06 +00:00
libdrgn: x86-64: support R_X86_64_PC32 relocation type
This is used for .orc_unwind_ip for kernel modules. Signed-off-by: Omar Sandoval <osandov@osandov.com>
This commit is contained in:
parent
e0aaaf203d
commit
090064f20d
@ -298,6 +298,15 @@ invalid_offset:
|
||||
memcpy(dst, &value, sizeof(value));
|
||||
break;
|
||||
}
|
||||
case R_X86_64_PC32: {
|
||||
uint32_t value = sym_value + r_addend - (relocating->addr + r_offset);
|
||||
if (dst_size < sizeof(value))
|
||||
goto invalid_offset;
|
||||
if (relocating->bswap)
|
||||
value = bswap_32(value);
|
||||
memcpy(dst, &value, sizeof(value));
|
||||
break;
|
||||
}
|
||||
case R_X86_64_32: {
|
||||
uint32_t value = sym_value + r_addend;
|
||||
if (dst_size < sizeof(value))
|
||||
|
@ -682,6 +682,7 @@ static struct drgn_error *relocate_elf_section(Elf_Scn *scn, Elf_Scn *reloc_scn,
|
||||
struct drgn_relocating_section relocating = {
|
||||
.buf = data->d_buf,
|
||||
.buf_size = data->d_size,
|
||||
.addr = sh_addrs[elf_ndxscn(scn)],
|
||||
.bswap = bswap,
|
||||
};
|
||||
|
||||
|
@ -28,6 +28,7 @@ struct drgn_register_layout {
|
||||
struct drgn_relocating_section {
|
||||
char *buf;
|
||||
size_t buf_size;
|
||||
uint64_t addr;
|
||||
bool bswap;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user