Forum > General
RTL/Packages as dynamically linked library
Alex_Lutovinin:
Hi.
Does anyone have experience using RTL/Packages as dynamically linked library?
In my case, several FPC applications should be installed on the host and it seems logical to me that
they will share the same RTL/Packages libraries.
I use crosscompiller 3.0.4 version for ARM_LINUX platform.
I tried to combine all RTL/Packages *.ppu modules using "ppumove" into several *.so libraries.
After solving some problems, I managed to build a small test application with the key "XD".
The result: the tiny size of the executable module, the application works.
But there is a problem: after the application is shut down, "EAccessViolation" occurs.
A little debugging showed that most likely the error occurs when releasing resource strings:
--- Quote ---Program received signal SIGSEGV, Segmentation fault.
0xb6f7955c in fpc_ansistr_decr_ref () from /usr/lib/libfpcrtl.so
(gdb)
(gdb) bt
#0 0xb6f7955c in fpc_ansistr_decr_ref () from /usr/lib/libfpcrtl.so
#1 0xb6f8695c in fpc_ansistr_assign () from /usr/lib/libfpcrtl.so
#2 0xb6f6fc8c in OBJPAS_$$_FINALIZERESOURCETABLES () from /usr/lib/libfpcrtl.so
#3 0xb6f6fcd4 in OBJPAS_$$_finalize$ () from /usr/lib/libfpcrtl.so
#4 0xb6f920fc in SYSTEM_$$_FINALIZEUNITS () from /usr/lib/libfpcrtl.so
#5 0xb6f9249c in SYSTEM_$$_INTERNALEXIT () from /usr/lib/libfpcrtl.so
#6 0xb6f92514 in SYSTEM_$$_DO_EXIT () from /usr/lib/libfpcrtl.so
#7 0x0000c5c0 in _haltproc_eabi ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
--- End quote ---
Are there any ideas about my plan? How is this even possible?
marcov:
No, because automated types (like string) don't work over DLL borders without special care.
See e.g. https://wiki.freepascal.org/packages
PascalDragon:
--- Quote from: marcov on February 07, 2023, 05:39:13 pm ---No, because automated types (like string) don't work over DLL borders without special care.
--- End quote ---
Due to the way ELF binaries work, on systems that use ELF binaries it can work, which is why ppumove was introduced after all.
I can't say whether it's still really usable however as it relies on a few assumptions...
In general I'd simply wait until dynamic packages support has been finalized (for arm-linux it's essentially only missing an adjustment of the startup code for the compile/link time case, like most targets).
marcov:
--- Quote from: PascalDragon on February 07, 2023, 09:21:26 pm ---
--- Quote from: marcov on February 07, 2023, 05:39:13 pm ---No, because automated types (like string) don't work over DLL borders without special care.
--- End quote ---
Due to the way ELF binaries work, on systems that use ELF binaries it can work, which is why ppumove was introduced after all.
--- End quote ---
If you mean single _LINKER_ namespace, afaik not all ELF binaries do (e.g. Solaris, AIX). But anyway, what I was referring that as soon you have two RTLs you have to sub-allocators if you don't take special case.
Alex_Lutovinin:
--- Quote from: marcov on February 07, 2023, 11:12:03 pm ---
--- Quote from: PascalDragon on February 07, 2023, 09:21:26 pm ---
--- Quote from: marcov on February 07, 2023, 05:39:13 pm ---No, because automated types (like string) don't work over DLL borders without special care.
--- End quote ---
Due to the way ELF binaries work, on systems that use ELF binaries it can work, which is why ppumove was introduced after all.
--- End quote ---
If you mean single namespace, afaik not all ELF binaries do (e.g. Solaris). But anyway, what I was referring that as soon you have two RTLs you have to sub-allocators if you don't take special case.
--- End quote ---
Thank you so much for your answer!
Navigation
[0] Message Index
[#] Next page