git: 79dea0c8af4e - main - linker: Fix the ifunc symbol value calculation for ET_REL files

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Wed, 02 Jul 2025 18:41:41 UTC
The branch main has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=79dea0c8af4eeb394c6db6ce62a4da77177bd234

commit 79dea0c8af4eeb394c6db6ce62a4da77177bd234
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2025-07-02 18:38:20 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2025-07-02 18:41:06 +0000

    linker: Fix the ifunc symbol value calculation for ET_REL files
    
    Reported by:    cy
    Fixes:          aefae931820f ("linker: Improve handling of ifuncs when fetching symbol metadata")
---
 sys/kern/link_elf_obj.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/sys/kern/link_elf_obj.c b/sys/kern/link_elf_obj.c
index 3d18aed2b1c0..151aab96f9be 100644
--- a/sys/kern/link_elf_obj.c
+++ b/sys/kern/link_elf_obj.c
@@ -1514,19 +1514,17 @@ static void
 link_elf_ifunc_symbol_value(linker_file_t lf, caddr_t *valp, size_t *sizep)
 {
 	c_linker_sym_t sym;
-	elf_file_t ef;
 	const Elf_Sym *es;
 	caddr_t val;
 	long off;
 
 	val = *valp;
-	ef = (elf_file_t)lf;
 
 	/* Provide the value and size of the target symbol, if available. */
 	val = ((caddr_t (*)(void))val)();
 	if (link_elf_search_symbol(lf, val, &sym, &off) == 0 && off == 0) {
 		es = (const Elf_Sym *)sym;
-		*valp = (caddr_t)ef->address + es->st_value;
+		*valp = (caddr_t)es->st_value;
 		*sizep = es->st_size;
 	} else {
 		*valp = val;