Damjan Jovanovic : ntdll: Interpretation of l_addr depends on FreeBSD version.

Alexandre Julliard julliard at winehq.org
Wed Jun 10 16:09:41 CDT 2020


Module: wine
Branch: master
Commit: f728a5f3f9a4f1cad64aa3a1d3e9951940b0955c
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=f728a5f3f9a4f1cad64aa3a1d3e9951940b0955c

Author: Damjan Jovanovic <damjan.jov at gmail.com>
Date:   Wed Jun 10 05:15:20 2020 +0200

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 <damjan.jov at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 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 0c8f05285c..c2e65c94ab 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)
         {




More information about the wine-cvs mailing list