Does dlopen() set errno?

[亡魂溺海] 提交于 2019-12-12 02:16:56

问题


Everything is in the title really. The man page does not say anything. Some google reports some people checking errno after dlopen, but just few and with various results. The function does return a success/non-success value, but how should one figure out the cause of the failure.

So does dlopen() set errno? where are the different errno values defined, then? If not, what should be used to check what caused the failure?


回答1:


No (emphasis added).

Upon successful completion, dlopen() shall return a symbol table handle. If file cannot be found, cannot be opened for reading, is not of an appropriate executable object file format for processing by dlopen(), or if an error occurs during the process of loading file or relocating its symbolic references, dlopen() shall return a null pointer. More detailed diagnostic information shall be available through dlerror().


As noted by others, nothing prohibits dlopen() (or, more likely, functions that dlopen() calls) from modifying errno. But a standard-conforming dlopen() will not report its own errors through errno. You need to call dlerror().



来源:https://stackoverflow.com/questions/40158005/does-dlopen-set-errno

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!