On 3/14/10 23:36, Walter Bright wrote:
Jacob Carlborg wrote:
I've been working the whole day on getting Tango to work built as a
dynamic library with dmd on Mac OS X. I have one problem (for now)
that I can't seem to solve.
The problem is that the module constructors are not called. That is
because the module info array in the object module, which contains all
the module constructors that should be called, is (almost) empty. It
seems like that the compiler or the linker doesn't put the module
constructors that are dynamically linked into the executable. I've
also tried to move the _minfo_beg and _minfo_end variables, which are
the beginning and the end of the sections containing the module info
array, from the object module to a statically linked module and then
passed them as arguments to the _moduleCtor function but without any
success.
Does anyone have any idea have to solve the above problem? Does the
compiler need to be modified?
There will be an _minfo_beg and _minfo_end for each loaded shared
library. These must then be combined at runtime to form an aggregate
array of all the modules.
I don't know how to search the shared libraries to find the
_minfo_beg/end sections, though I've never researched it, either.
Latest update:
I've found the __minfodata section and the content looks fine. The new
problem I have is that an exception is thrown in _moduleCtor2 and I
can't catch the exception. The problem is that it can't find any handler
table. I think it's something wrong with _deh_beg and _deh_end in the
deh module.
If I have the _deh_beg and _deh_end as globals (as they are by default)
it doesn't find a handler table. If I instead get the __deh_beg and the
__deh_end sections from the main executable it does find a table handler
but the table looks very different compared to a statically linked
Tango. The length of the table is close to 600 compared to 1 when Tango
is statically linked. It also contains a lot of zeros.