comparison dynload/dynload_unix.c @ 645:6a8aac9b2bcf

- removal of `autovar` macro detection lib: * was a good idea, but never fully pushed through, so code was duplicating most of dyncall_macros.h * didn't find any outside use and plans to make it a standalone lib never materialized * so basically removing code to avoid code duplication that risks to never stay in sync
author Tassilo Philipp
date Mon, 05 Feb 2024 16:43:59 +0100
parents 61c485f8cc06
children
comparison
equal deleted inserted replaced
644:f13444192ceb 645:6a8aac9b2bcf
32 32
33 */ 33 */
34 34
35 35
36 #include "dynload.h" 36 #include "dynload.h"
37 #include "../autovar/autovar_OS.h" 37 #include "../dyncall/dyncall_macros.h"
38 38
39 #include <string.h> 39 #include <string.h>
40 40
41 #if defined(__GLIBC__) 41 #if defined(__GLIBC__)
42 /* @@@ version check glibc more precisely... dl_iterate_phdr(): glibc ver >= 2.2.4*/ 42 /* @@@ version check glibc more precisely... dl_iterate_phdr(): glibc ver >= 2.2.4*/
99 * 2.3.3, but its implementation is dangerous, as no checks are done whether 99 * 2.3.3, but its implementation is dangerous, as no checks are done whether
100 * the handle is valid, thus rendering the returned values useless) check for 100 * the handle is valid, thus rendering the returned values useless) check for
101 * RTLD_DI_LINKMAP and RTLD_SELF, which are #defines used by dlinfo() on most 101 * RTLD_DI_LINKMAP and RTLD_SELF, which are #defines used by dlinfo() on most
102 * supported targets, or specifically check the OS (e.g. dlinfo() is originally 102 * supported targets, or specifically check the OS (e.g. dlinfo() is originally
103 * from Solaris) */ 103 * from Solaris) */
104 #if ((defined(RTLD_DI_LINKMAP) && defined(RTLD_SELF)) || defined(OS_SunOS)) && !defined(DL_USE_GLIBC_ITER_PHDR) 104 #if ((defined(RTLD_DI_LINKMAP) && defined(RTLD_SELF)) || defined(DC__OS_SunOS)) && !defined(DL_USE_GLIBC_ITER_PHDR)
105 105
106 #include <link.h> 106 #include <link.h>
107 107
108 int dlGetLibraryPath(DLLib* pLib, char* sOut, int bufSize) 108 int dlGetLibraryPath(DLLib* pLib, char* sOut, int bufSize)
109 { 109 {
115 return l+1; /* strlen + '\0' */ 115 return l+1; /* strlen + '\0' */
116 } 116 }
117 117
118 118
119 /* specific implementation needed on Darwin -----> */ 119 /* specific implementation needed on Darwin -----> */
120 #elif defined(OS_Darwin) 120 #elif defined(DC__OS_Darwin)
121 121
122 #include <stdint.h> 122 #include <stdint.h>
123 #include <mach-o/dyld.h> 123 #include <mach-o/dyld.h>
124 124
125 int dlGetLibraryPath(DLLib* pLib, char* sOut, int bufSize) 125 int dlGetLibraryPath(DLLib* pLib, char* sOut, int bufSize)
162 /* - OpenBSD >= 3.7 has dl_iterate_phdr(), as well as glibc >= 2.2.4 162 /* - OpenBSD >= 3.7 has dl_iterate_phdr(), as well as glibc >= 2.2.4
163 - also some libc impls (like musl) provide dlinfo(), but not RTLD_SELF (see above), however they might come 163 - also some libc impls (like musl) provide dlinfo(), but not RTLD_SELF (see above), however they might come
164 with dl_iterate_phdr (which comes from ELF program header iteration), so base it on that 164 with dl_iterate_phdr (which comes from ELF program header iteration), so base it on that
165 - skip and use dladdr()-based guessing (see below) if explicitly requested, e.g. by ./configure 165 - skip and use dladdr()-based guessing (see below) if explicitly requested, e.g. by ./configure
166 - Haiku/BeOS does have the headers but no implementation of dl_iterate_phdr() (at least as of 2021) */ 166 - Haiku/BeOS does have the headers but no implementation of dl_iterate_phdr() (at least as of 2021) */
167 #elif !defined(DL_DLADDR_TO_LIBPATH) && (defined(OS_OpenBSD) || defined(DL_USE_GLIBC_ITER_PHDR) || (!defined(RTLD_SELF) && defined(__ELF__))) && !defined(OS_BeOS) 167 #elif !defined(DL_DLADDR_TO_LIBPATH) && (defined(DC__OS_OpenBSD) || defined(DL_USE_GLIBC_ITER_PHDR) || (!defined(RTLD_SELF) && defined(__ELF__))) && !defined(DC__OS_BeOS)
168 168
169 #include <sys/types.h> 169 #include <sys/types.h>
170 #include <link.h> 170 #include <link.h>
171 171
172 typedef struct { 172 typedef struct {