Date: Wed, 08 Apr 2026 22:42:40 +0000 From: Vladimir Druzenko <vvd@FreeBSD.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org Cc: Generic Rikka <rikka.goering@outlook.de> Subject: git: 94fc6d9ffebb - main - net/ucx: Fix FreeBSD UCM relocation handling Message-ID: <69d6d9e0.22bd5.3a1f0820@gitrepo.freebsd.org>
index | next in thread | raw e-mail
The branch main has been updated by vvd: URL: https://cgit.FreeBSD.org/ports/commit/?id=94fc6d9ffebbad5014a7f48ba925b9a39df8478f commit 94fc6d9ffebbad5014a7f48ba925b9a39df8478f Author: Generic Rikka <rikka.goering@outlook.de> AuthorDate: 2026-04-08 22:25:29 +0000 Commit: Vladimir Druzenko <vvd@FreeBSD.org> CommitDate: 2026-04-08 22:42:19 +0000 net/ucx: Fix FreeBSD UCM relocation handling On FreeBSD, dynamic-section pointers observed through dl_iterate_phdr() for shared objects need to be rebased by dlpi_addr before dereference. Also fix the PT_LOAD end range calculation to include the object base address when tracking the library address span. This fixes runtime failures in UCM relocation patching on FreeBSD. PR: 293867 Sponsored by: UNIS Labs MFH: 2026Q2 --- net/ucx/files/patch-src_ucm_util_reloc.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/net/ucx/files/patch-src_ucm_util_reloc.c b/net/ucx/files/patch-src_ucm_util_reloc.c index 436cc4bd600e..30991731f7b4 100644 --- a/net/ucx/files/patch-src_ucm_util_reloc.c +++ b/net/ucx/files/patch-src_ucm_util_reloc.c @@ -1,6 +1,34 @@ --- src/ucm/util/reloc.c.orig 2026-02-04 09:52:46 UTC +++ src/ucm/util/reloc.c -@@ -673,10 +673,13 @@ static int ucm_dlclose(void *handle) +@@ -97,8 +97,15 @@ ucm_reloc_get_pointer(ElfW(Addr) base, const ElfW(Phdr + { + uintptr_t entry = ucm_reloc_get_entry(base, dphdr, tag); + +-#if defined(__riscv) +- /* On RISC-V these are not pointers but offsets */ ++#if defined(__FreeBSD__) || defined(__riscv) ++ /* ++ * On FreeBSD, the dynamic-section pointer entries we consume here ++ * (DT_SYMTAB, DT_STRTAB, DT_JMPREL, DT_RELA, ...) are observed through ++ * dl_iterate_phdr() as object-relative virtual addresses for shared ++ * objects, so they must be rebased by dlpi_addr before dereference. ++ * ++ * RISC-V already required the same treatment. ++ */ + return UCS_PTR_BYTE_OFFSET(base, entry); + #else + return (void *)entry; +@@ -353,7 +360,8 @@ static ucs_status_t ucm_reloc_dl_info_get(const struct + if (phdr->p_type == PT_LOAD) { + /* Found loadable section - update address range */ + dl_info->start = ucs_min(dl_info->start, dlpi_addr + phdr->p_vaddr); +- dl_info->end = ucs_max(dl_info->end, phdr->p_vaddr + phdr->p_memsz); ++ dl_info->end = ucs_max(dl_info->end, dlpi_addr + phdr->p_vaddr + ++ phdr->p_memsz); + found_pt_load = 1; + } else if (phdr->p_type == PT_DYNAMIC) { + /* Found dynamic section */ +@@ -673,10 +681,13 @@ static int ucm_dlclose(void *handle) * cached information anyway, and it may be re-added on the next call to * ucm_reloc_apply_patch(). */home | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?69d6d9e0.22bd5.3a1f0820>
