Mach-O's two-level namespace symbol resolution in ELF/linux
Asked Answered
C

2

10

Anyone know of an equivalent to Mach-O's two-level namespace symbol resolution in ELF/linux? I want code that links to lib+sym, not sym.

I'm trying to do what could best be described as precompilation of what normally would be a JIT compilation. I'd like to get a compile time binding of symbols, that normally would be done by a dlopen/dlsym. However, there could be collisions, which are nicely avoided by the dlopen/dlsym.

It seems that ELF actually lacks this, and there is the VERSION stuff, but any workarounds or suggestions would be appreciated.

Cinquefoil answered 6/8, 2011 at 3:43 Comment(6)
I think there would be many people who know about ELF and Linux but who do not have any idea about Mach-O, such as myself. You might want to expand your question to briefly explain what is it exactly that you are trying to achieve.Hunsaker
I just updated it to do so... the last sentence of the first paragraph explains the goal, and the next two paragraphs explain why.Cinquefoil
Your question has now turned into complete gibberish to me (and I do understand both ELF and (to much lesser extent) Mach-O). It is unlikely that you would get a good answer to the question in its current form. I suggest you try to expand and clarify it, perhaps with an example of what you are actually trying to do.Mortensen
Say you're compiling a traditionally interpreted language to machine code. This language has an FFI that lets you import symbols in terms of path_to_library + symbol_name. The goal is to compile this symbol referencing semantic down to platform-specific dynamic linking without the use of dlopen/dlsym. Mach-O has a disambiguation mechanism that lets you specify unresolved symbols this way, thus making symbol conflicts among dynamic libraries a non-issue on macs. Windows has no mechanism other than LoadLibrary/GetProcAddress, so no issue there. The questions is: can similar be done with ELF?Kosiur
Thanks for clarification. ELF is in exactly the same position as Windows -- there is no mechanism other than dlopen/dlsym.Mortensen
This is not correct. Windows is NOT in the same position since it has Acitvation Context API that allows applications to get exactly the symbol version that it was compiled for: msdn.microsoft.com/en-us/library/windows/desktop/…Semiconscious
M
3

There is no ELF equivalent (and usually one isn't needed).

Mortensen answered 7/8, 2011 at 2:47 Comment(1)
While it is true that there's no equivalent, I'd challenge the assertion that one isn't needed. Problems with flat namespace (described here: stpeterandpaul.ca/tiger/releasenotes/DeveloperTools/…) are very real on Linux.Semiconscious
A
2

It sounds like you want dlmopen.

Aforementioned answered 30/11, 2017 at 23:43 Comment(1)
Underrated answer. dlmopen is indeed the closest thing to two-level namespaces in the cases when it's needed (i.e. avoiding symbol collisions).Vassalage

© 2022 - 2024 — McMap. All rights reserved.