git: a9b24e4dc28a - main - riscv: fix relocation handling for R_RISCV_64
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 20 Oct 2022 15:04:29 UTC
The branch main has been updated by mhorne:
URL: https://cgit.FreeBSD.org/src/commit/?id=a9b24e4dc28abfe668038e4c053d77b6dd4dce19
commit a9b24e4dc28abfe668038e4c053d77b6dd4dce19
Author: Mitchell Horne <mhorne@FreeBSD.org>
AuthorDate: 2022-10-20 14:56:59 +0000
Commit: Mitchell Horne <mhorne@FreeBSD.org>
CommitDate: 2022-10-20 15:01:29 +0000
riscv: fix relocation handling for R_RISCV_64
It requires the addend. In practice this doesn't seem to be a problem,
since relocations of this type are all with an addend of zero.
Obviously, we still want to handle this correctly if that ever changes.
Reviewed by: markj
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D37039
---
sys/riscv/riscv/elf_machdep.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/sys/riscv/riscv/elf_machdep.c b/sys/riscv/riscv/elf_machdep.c
index 68c7afb4d09f..b3d8ac54a36d 100644
--- a/sys/riscv/riscv/elf_machdep.c
+++ b/sys/riscv/riscv/elf_machdep.c
@@ -340,15 +340,25 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbase, const void *data,
break;
case R_RISCV_64:
+ error = lookup(lf, symidx, 1, &addr);
+ if (error != 0)
+ return (-1);
+
+ before64 = *where;
+ *where = addr + addend;
+ if (debug_kld)
+ printf("%p %c %-24s %016lx -> %016lx\n", where,
+ (local ? 'l' : 'g'), reloctype_to_str(rtype),
+ before64, *where);
+ break;
+
case R_RISCV_JUMP_SLOT:
error = lookup(lf, symidx, 1, &addr);
if (error != 0)
return (-1);
- val = addr;
before64 = *where;
- if (*where != val)
- *where = val;
+ *where = addr;
if (debug_kld)
printf("%p %c %-24s %016lx -> %016lx\n", where,
(local ? 'l' : 'g'), reloctype_to_str(rtype),