1*c18e2b64SPatrick Venture #pragma once 2*c18e2b64SPatrick Venture 3*c18e2b64SPatrick Venture namespace blobs 4*c18e2b64SPatrick Venture { 5*c18e2b64SPatrick Venture 6*c18e2b64SPatrick Venture namespace internal 7*c18e2b64SPatrick Venture { 8*c18e2b64SPatrick Venture /** 9*c18e2b64SPatrick Venture * Interface to the dynamic library loader. 10*c18e2b64SPatrick Venture */ 11*c18e2b64SPatrick Venture class DlSysInterface 12*c18e2b64SPatrick Venture { 13*c18e2b64SPatrick Venture public: 14*c18e2b64SPatrick Venture virtual ~DlSysInterface() = default; 15*c18e2b64SPatrick Venture 16*c18e2b64SPatrick Venture /** 17*c18e2b64SPatrick Venture * obtain error diagnostic for functions in the dlopen API 18*c18e2b64SPatrick Venture * 19*c18e2b64SPatrick Venture * @return the error details 20*c18e2b64SPatrick Venture */ 21*c18e2b64SPatrick Venture virtual const char* dlerror() const = 0; 22*c18e2b64SPatrick Venture 23*c18e2b64SPatrick Venture /** 24*c18e2b64SPatrick Venture * open a shared object 25*c18e2b64SPatrick Venture * 26*c18e2b64SPatrick Venture * @param[in] filename - the path to the shared object or the filename to 27*c18e2b64SPatrick Venture * for searching 28*c18e2b64SPatrick Venture * @param[in] flags - the flags 29*c18e2b64SPatrick Venture * @return a handle to the shared object (null on failure) 30*c18e2b64SPatrick Venture */ 31*c18e2b64SPatrick Venture virtual void* dlopen(const char* filename, int flags) const = 0; 32*c18e2b64SPatrick Venture 33*c18e2b64SPatrick Venture /** 34*c18e2b64SPatrick Venture * obtain address of a symbol in a shared object or executable 35*c18e2b64SPatrick Venture * 36*c18e2b64SPatrick Venture * @param[in] handle - pointer to shared object 37*c18e2b64SPatrick Venture * @param[in] symbol - name of the symbol to find 38*c18e2b64SPatrick Venture * @return the address of the symbol if found (null otherwise) 39*c18e2b64SPatrick Venture */ 40*c18e2b64SPatrick Venture virtual void* dlsym(void* handle, const char* symbol) const = 0; 41*c18e2b64SPatrick Venture }; 42*c18e2b64SPatrick Venture 43*c18e2b64SPatrick Venture class DlSysImpl : public DlSysInterface 44*c18e2b64SPatrick Venture { 45*c18e2b64SPatrick Venture public: 46*c18e2b64SPatrick Venture const char* dlerror() const override; 47*c18e2b64SPatrick Venture void* dlopen(const char* filename, int flags) const override; 48*c18e2b64SPatrick Venture void* dlsym(void* handle, const char* symbol) const override; 49*c18e2b64SPatrick Venture }; 50*c18e2b64SPatrick Venture 51*c18e2b64SPatrick Venture extern DlSysImpl dlsys_impl; 52*c18e2b64SPatrick Venture 53*c18e2b64SPatrick Venture } // namespace internal 54*c18e2b64SPatrick Venture } // namespace blobs 55