VirtualBox

Ignore:
Timestamp:
Nov 6, 2018 6:58:03 AM (6 years ago)
Author:
vboxsync
Message:

OpenGL: make runtime loading of shared objects work without DT_RPATH.
bugref:8019: GCC sanitisers
Unfortunately gcc address sanitiser breaks DT_RPATH, and our host OpenGL test
tool depends on this when trying to load the libraries. The simple fix is to
retry loading the library in RTPathSharedLibs() if the first load attempt
fails.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/GuestHost/OpenGL/util/dll.c

    r68859 r75267  
    1616
    1717#if defined(IRIX) || defined(IRIX64) || defined(Linux) || defined(FreeBSD) || defined(AIX) || defined(DARWIN) || defined(SunOS) || defined(OSF1)
     18# include <iprt/assert.h>
     19# include <iprt/err.h>
     20# include <iprt/path.h>
    1821#include <dlfcn.h>
    1922#endif
     
    274277        };
    275278#elif defined(IRIX) || defined(IRIX64) || defined(Linux) || defined(FreeBSD) || defined(AIX) || defined(SunOS) || defined(OSF1)
    276         if (resolveGlobal)
    277                 dll->hinstLib = dlopen( dllname, RTLD_LAZY | RTLD_GLOBAL );
    278         else
    279                 dll->hinstLib = dlopen( dllname, RTLD_LAZY );
    280         dll_err = (char*) dlerror();
     279        {
     280                int flags = RTLD_LAZY;
     281                if (resolveGlobal)
     282                   flags |= RTLD_GLOBAL;
     283                dll->hinstLib = dlopen( dllname, flags );
     284# ifndef IN_GUEST
     285                /* GCC address sanitiser breaks DT_RPATH. */
     286                if (!dll->hinstLib) do {
     287                        char szPath[RTPATH_MAX];
     288                        int rc = RTPathSharedLibs(szPath, sizeof(szPath));
     289                        AssertLogRelMsgRCBreak(rc, ("RTPathSharedLibs() failed: %Rrc\n", rc));
     290                        rc = RTPathAppend(szPath, sizeof(szPath), dllname);
     291                        AssertLogRelMsgRCBreak(rc, ("RTPathAppend() failed: %Rrc\n", rc));
     292                        dll->hinstLib = dlopen( szPath, flags );
     293                } while(0);
     294# endif
     295                dll_err = (char*) dlerror();
     296        }
    281297#else
    282298#error DSO
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette