stsp / dj64dev

dj64dev development suite
https://github.com/stsp/dj64dev/
GNU Lesser General Public License v3.0
6 stars 1 forks source link

get rid of dlmopen() #4

Closed stsp closed 5 months ago

stsp commented 5 months ago

dlmopen() is not portable. The code is arranged to track all the resources with handles, so I suppose its quite ready to work w/o dlmopen(). Its likely that only crt1_startup should be tweaked.

stsp commented 5 months ago

Hmm, seems impossible. :( man page says:

       Another use is to load the same object more than once.  With‐
       out the use of dlmopen(), this would require the creation  of  distinct
       copies  of  the  shared  object  file.

But even the distinct copies do not help unless the one copies also entire libdj64.so.0.2...

stsp commented 5 months ago

But with that we are back to linux-only, as no one provides dlmopen()... That seems to really suck!

stsp commented 5 months ago

I can use static linking. comcom64.exe size then increases from 315K to 1.2M. Stripped version increases from 140K to 425K.

So... perhaps I need to support both static and dynamic linking, supporting only static linking on non-GNU systems... :(

stsp commented 5 months ago

Static linking implemented. Oh well...

stsp commented 5 months ago

In fact, static linking might be short-sighted solution. I still need to find out why I can't implement the proper dynamic linking. Maybe there are just a few more places where the handle control is screwed, with dosobj subsystem being the first suspect.

stsp commented 5 months ago

The problem seems to be that I am using absolute pointers in athunks, so they do not properly relocate after dos exec. Still don't see any obvious solution besides the static linking. :(

stsp commented 5 months ago

Seems somewhat working...