[fpc-pascal] Calling fpc libraries from other languages on freebsd/amd64 (bis)

fredvs fiens at hotmail.com
Mon Aug 4 14:40:42 CEST 2014


Aaaargh, difficult t find help here...

In the original thread 
>> [fpc-devel] (hack) calling fpc libraries from other languages on
>> freebsd/amd64
>> of Michal Wallace michal.wallace at gmail.com 

Michael Wallace said that he has find the solution :=>

>> Anyway, the problem appears to be in this file:
>> http://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/rtl/freebsd/x86_64/dllpr=

(But this file is no more accessible. ;-( )

>> It has the comment:

>> # FreeBSD RunTime dynamic loader only
>> # calls the functions specified by -init
>> # as functions without parameters
>> # Thus, it is not possible to retrieve argc, argv and envp
>> # On x86_64 CPU, using weak for the operatingsystem_parameter_XXX

>> # allows to bind to main program parameters,
>> # but this does not seem to work for i386 loader.

>> Then at the bottom:

>> /* Do not fail linkage if argc, argv and envp are not found. */
>> .weak operatingsystem_parameter_argc
>> .weak operatingsystem_parameter_argv
>> .weak operatingsystem_parameter_envp

>> My change was to comment these lines out and copy the lines from prt0.as
>> :


>> .global operatingsystem_parameter_envp
>> .global operatingsystem_parameter_argc
>> .global operatingsystem_parameter_argv
>> .set operatingsystem_parameter_envp,operatingsystem_parameters+0
>> .set operatingsystem_parameter_envp,operatingsystem_parameters+0
>> .set operatingsystem_parameter_envp,operatingsystem_parameters+0

>> Then after recompiling fpc, I was able to compile a *.so file usable from
>> python.

>> But... It seems like the original .weak version was done quite
>> deliberately, so I suspect that if I submit a patch, it would break
>> things for other people. OTOH, I'd like to get a fix for my issue
>> into trunk.

So, it seems that Michal Wallace do not sent a patch for that.
It seems too that his solution was for Python, maybe it works for Java too.

But later Sergei Gorelkin answers :

> Studying sources of FreeBSD dynamic loader reveals that, although it does
> not pass argc, argv and 
> envp to the initialization function in .init section, it *does* pass them
> to procedures pointed to 
> from .init_array section. Generally, .init_array is considered as a
> replacement for .init. 
> Therefore, the correct solution would be to change initialization to use
> .init_array and remove all 
> associated hacks.

> Regards,
> Sergei

So i do not know where is the good solution, please, wonderful fpc people,
help us and me...

Fred





-----
Many thanks ;-)
--
View this message in context: http://free-pascal-general.1045716.n5.nabble.com/Calling-fpc-libraries-from-other-languages-on-freebsd-amd64-bis-tp5719667p5719869.html
Sent from the Free Pascal - General mailing list archive at Nabble.com.



More information about the fpc-pascal mailing list