ocaml / flexdll

a dlopen-like API for Windows
Other
98 stars 30 forks source link

Support generation of jmp thunk table #2

Closed elfmimi closed 4 years ago

elfmimi commented 9 years ago

As I said, I have created a patch to support generation of jmp thunk table. Its purpose is to avoid "target is too far" error on 64-bit platforms. Though, for universality I made it able to be utilized in 32-bit platforms as well. I wanted to let you know that this is actually possible.

There is one minor flaw that is it will put unneeded symbols in the jmp thunk table. This will increase the size of the binary but that amount is negligible. This can be fixed later.

I suppose this also well accomodates with COMDAT. Because there arise no need to modify the object files at all. But I have not yet tested it.

So, what would you say?

alainfrisch commented 9 years ago

Thanks, this is very nice. I'm not completely sure to understand the scope of what it fixes. In particular, do we agree that it doesn't solve, in general, the problem of loading dynamic OCaml plugins, because the dynlinked code can refer to symbols in the main program (not as jump target), which could end up being too far if Windows decides to load the .dll/.cmxs far enough from the main program? Do you have specific scenario that doesn't work without the addition of the patch, but work with it?