1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
15 Implementation of internal functions to get module names
21 #include "pal/thread.hpp"
22 #include "pal/malloc.hpp"
23 #include "pal/palinternal.h"
24 #include "pal/dbgmsg.h"
25 #include "pal/modulename.h"
29 #else // NEED_DLCOMPAT
31 #endif // NEED_DLCOMPAT
33 using namespace CorUnix;
35 SET_DEFAULT_DEBUG_CHANNEL(LOADER);
40 Internal wrapper for dladder used only to get module name
46 Pointer to string with the fullpath to the librotor_pal.so being
49 NULL if error occurred.
52 The string returned by this function is owned by the OS.
53 If you need to keep it, strdup() it, because it is unknown how long
54 this ptr will point at the string you want (over the lifetime of
55 the system running) It is only safe to use it immediately after calling
58 const char *PAL_dladdr(LPVOID ProcAddress)
61 if (!dladdr(ProcAddress, &dl_info))
63 WARN("dladdr() call failed! dlerror says '%s'\n", dlerror());
64 /* If we get an error, return NULL */
69 /* Return the module name */
70 return dl_info.dli_fname;