symbol versioning and dlsym

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-22 18:04:27

问题


I load the pthread library in my program using dlopen, and fetch handlers to pthread_create and pthread_join using dlsym.

How can I ensure that both the handlers are of a compatible version? I do not care if the symbols are of new version or old versions. I just want that whatever pthread_create I use to work well with the pthread_join that I get.

I know there is a dlvsym to which I can pass explicit version number, but I do not care about exact version numbers as I want my code to be independent of library versions.


回答1:


The only reason the versioning exists is for a poor attempt at ABI-compatibility with programs compiled against ancient versions of glibc, which will not actually work anyway. (They've silently broken the ABI at least once in a way that, as far as I can tell, cannot be compatible.) Just ignore it.




回答2:


Sounds like you need "dladdr - find the shared object containing a given address".

However as you have not said what platform you are using, so it might not be available.

Have a look and see..



来源:https://stackoverflow.com/questions/5587718/symbol-versioning-and-dlsym

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