I have C ++ 14 code that should load an arbitrary file of shared objects using dlopen . Unfortunately, on some systems (for example, my archlinux is also reported to apply to some .so on ubuntu and gentoo), these so-called files may be "GNU ld scripts" instead of real binary files.
For reference, here is the contents of my /usr/lib/libm.so :
OUTPUT_FORMAT(elf64-x86-64) GROUP ( /usr/lib/libm.so.6 AS_NEEDED ( /usr/lib/libmvec.so.1 ) )
I found a couple of codes that relate to this problem in ghc or ruby . I would not want to resort to the manual analysis of a text file based on the analysis of the dlerror text and the file. I feel that this is terribly evil, and I will not be able to implement and support corner cases of this format.
Is there a clean way to implement handling this case? Honestly, I am puzzled by why dlopen is actually not doing this.
Note. Given the above fixes, I think this is not just a problem with my configuration / system versions. If this should work out of the box with dlopen (error instead of missing function), let me know.
Zulan source share