From f728a5f3f9a4f1cad64aa3a1d3e9951940b0955c Mon Sep 17 00:00:00 2001 From: Damjan Jovanovic Date: Wed, 10 Jun 2020 05:15:20 +0200 Subject: [PATCH] ntdll: Interpretation of l_addr depends on FreeBSD version. FreeBSD changed l_addr to mean the relocation offset like it does on other OSes, and provided a dynamic linker symbol, "_rtld_version_laddr_offset", that can be used to check the meaning. Signed-off-by: Damjan Jovanovic Signed-off-by: Alexandre Julliard --- dlls/ntdll/loader.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c index 0c8f05285c4..c2e65c94abc 100644 --- a/dlls/ntdll/loader.c +++ b/dlls/ntdll/loader.c @@ -1372,8 +1372,10 @@ static void call_constructors( WINE_MODREF *wm ) { caddr_t relocbase = (caddr_t)map->l_addr; -#ifdef __FreeBSD__ /* FreeBSD doesn't relocate l_addr */ - if (!get_relocbase(map->l_addr, &relocbase)) return; +#ifdef __FreeBSD__ + /* On older FreeBSD versions, l_addr was the absolute load address, now it's the relocation offset. */ + if (!dlsym(RTLD_DEFAULT, "_rtld_version_laddr_offset")) + if (!get_relocbase(map->l_addr, &relocbase)) return; #endif switch (dyn->d_tag) {