Originally posted by Weasel
View Post
https://en.wikipedia.org/wiki/C_POSIX_library
libc is define as part of Posix standard. It is allowed to under POSIX that is no other way to allocate memory other than free/malloc/calloc in libc. So implementing your own malloc/free will be sitting on top of the C one.
This part of standard means when you have a 2 link map inside an application or more the libc memory allocations have to be kept the same. This make libcapsule design mandatory or you will break legacy Linux applications. Windows platform rules don't define 1 single malloc/free for applications to use instead define multi-able.
Free exists on posix because it was defined and you are meant to link against the platform libc. Most Linux distributions platform libc is glibc.
When writing application yes you have to import malloc and free. If you application is valid POSIX you have imported malloc and free not written your own and with that imported malloc and free you have a expected set of behaviours include the ability to allocate in 1 library and free in a different one.
Sorry the windows one of you must free inside the dll that allocated does not fly on POSIX. A common runtime is requirement of Posix this has made doing libcapsule a little tricker than what windows did with each dll having it own link-map.
Originally posted by Weasel
View Post
Relocation Record is term for the entry in the dynamic link map of entry going between two different files be this the executable to a dynamic link libary or dynamic link libary to dynamic link library. RIP/PIE has absolutely nothing to-do with this. The values for the pointers contained in dynamic link maps has to be resolved this comes with overhead RIP/PIE in fact increase this overhead.
10 so files with individual link-map per file run into the same overhead problem as 10 dlls with individual link-map.
Originally posted by Weasel
View Post
Yes 10 dll gives you the flexibility of 10 different runtimes but what about the case where you only have 1 runtime. You are paying the overhead as if you are using 10.
Also Weasel the rule about always free in the dll that allocated it happens be based around the presume that every dll has it own runtime. Of course this does cause a overhead problem. So X is allocated in A dll/so using C runtime. B dll/so using C runtime is the point where it worked X should be freed obeying your logic you will have to call exported function on A that then calls the C runtime to free X now posix logic B calls the C runtime directly.
dlmopen allows multi link-maps. Multi link-maps means you can have multi runtimes. Rules about cross link-maps containing different libc parts is the same dll that you must free in the right link map. Is there any requirement for malloc/free defines by posix standard to come from libc to be different.
On posix platforms you have to think of libc like the ntdll.dll on windows you don't get a different function no matter the dll that calls ntdll.dll inside your application right. So libc free/malloc under posix is expected to be the same by default.
Most platforms have not been designed like windows where windows expected that each dll will have it own unique runtime.
SUN with AT&T in 1988 designed dlmopen to allow applications to have more than 1 libc version loaded at time this was used in audit tools.
Weasel there is more than 1 way to skin a cat. There is more than 1 way to solve the multi runtime problem. The windows option is blindly create multi link-maps and take the overhead. The SUN/AT&T design is when you need more than 1 runtime you will declare multi link-maps in your code. libcapsule follows the SUN/AT&T design those shims declare create new link map.
By the way Weasel;l the 1 link-map per dll is in fact limiting.
So 10 dlls 10 runtime right is this true for platforms with dlmopen the answer is no it not.
dlmopen support a horrible hair ball.
You have A.so with X, Y, Z runtime options that alter the function of A.so. Using dlmopen to create link-maps it possible for my application to have A.so with all 3 run-times inside my application just with different link maps. Now try doing the same thing under windows without using new WSL at this point you should wake up that the link-map per dll under windows has in fact tied your hands. Why should Linux world be interested in a less flexible solution.
dlmopen allows if you wish a link-map per .so file it allows for a link-map shared between a group of .so files it also allows for a link-map to contain the same .so multi times linking to different dependencies.
Limitation has been lack of software/library to effectively use dlmopen and dlmopen being broken. libcapsule addresses the software problem and has also addressed the broken problem.
Comment