[fpc-devel] assumed bug in the RTL with ARM v5 regarding loading dynamic libraries

Michael Schnell mschnell at lumino.de
Thu Jan 24 11:07:25 CET 2013


On 01/23/2013 10:20 AM, Thomas Schatzl wrote:
> program test;
> uses cmem, dynlibs;
> begin
>    writeln('Hello');
> end.
> Compile with:
>
> ppcarm -Fl/opt/arm-none-linux-gnueabi/lib test.pas
>
Hi Tomas.

I tested your code and compiler line on my device and it behaves as I 
expected:

============================================
[/share/Public/heizarm] # ppcarm -Fl/opt/arm-linux-gnueabi/lib test.pas
Free Pascal Compiler version 2.6.0 [2011/12/27] for arm
Copyright (c) 1993-2011 by Florian Klaempfl and others
Target OS: Linux for ARMEL
Compiling test.pas
Assembling test
Linking test
/share/Public/root/lib/fpc/2.6.0/units/arm-linux/rtl/cprt0.o: In 
function `_haltproc_eabi':
(.text+0x88): undefined reference to `_fini'
/share/Public/root/lib/fpc/2.6.0/units/arm-linux/rtl/cprt0.o: In 
function `_haltproc_eabi':
(.text+0x90): undefined reference to `_init'
test.pas(4,18) Error: Error while linking
test.pas(4,18) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted
[/share/Public/heizarm] # cp /opt/arm-none-linux-gnueabi/lib/c
============================================

Obviously something in my installation is different.

/opt/arm-linux-gnueabi/lib is exactly the location where I copied crti.o 
from.

I still don't see the difference between copying the file to the current 
dir and using -Fl to add that dir to the library search path.


Up till now I used the gnu linker only with embedded projects in C 
language via cross-compiling and without dynamic link libraries.

So I of course am lacking a lot of knowledge, but you might be inclined 
to fill some gaps.

I understand that
a) the linker does not open all files in a search directory and try to 
find resolutions for open (non weak) externals
b) the linker only opens the .o and .a files it is told to use (e.g. in 
a linker script file - this is what I used in the said "C" projects)
c) if one of the denoted files is not found in any of the search 
directories, the linker aborts with an error message.

Regarding my inability to link your testing program, and my other tests:
1) rather obviously the file crti.o is not a viable file to be used, as 
(i) the linker will never see it unless explicitly denoted (e.g. by {$L 
crti.o ) and this is not done in your successful test on your machine 
and (ii) my testing programs immediately  when I include it,
2) I suppose in your environment not crti.o, but some library (.a file 
or maybe some other file somehow specified) is used to resolve the _init 
and _finit externals.
3) I understand that for this, that library somehow needs to be 
specified, as I believe the linker will not on it's own go out and 
search and open files that might provide these globals.
4) Thus in your environment somehow such a library file is specified. 
Maybe it's done in fpc.cfg, which in my environment has not been 
obtained in a really "decent" way ant the syntax of which I fail to 
understand well enough. (The file did not come with the 2.6.0 "TAR" 
distribution, so it is inherited from the Debian 2.2 stuff ).
5) In dl.pp (That I understand you test program implicitly pulls), there 
is the line {$linklib c}. I don't really understand what exactly this is 
suppose to mean. I would _assume_ that it might be an instruction to the 
linker to use the library file "c.a" but I believe there is no file with 
such name. So there might be some compiler magic that constructs a 
different instruction to the linker.

-Michael

FYI: This is the content of /opt/arm-linux-gnueabi/lib on this machine:

[/opt/lib] # ls -l
drwxr-xr-x    2 admin    administ     4096 Jan  3 11:36 armv4t/
-rwxr-xr-x    1 admin    administ     7132 Feb 14  2012 e2initrd_helper*
drwxr-xr-x    3 admin    administ     4096 Jan  3 11:36 gcc/
drwxr-xr-x    3 admin    administ     4096 Jan  3 11:10 gio/
drwxr-xr-x    3 admin    administ     4096 Jan  3 11:10 glib-2.0/
drwxr-xr-x    4 admin    administ     4096 Jan  3 15:18 groff/
drwxr-xr-x    5 admin    administ     4096 Jan 21 22:52 ipkg/
-rw-r--r--    1 admin    administ  4407522 Feb 14  2012 libbfd.a
-rwxr-xr-x    1 admin    administ      937 Feb 14  2012 libbfd.la*
lrwxrwxrwx    1 admin    administ       13 Jan  3 11:10 libblkid.so -> 
libblkid.so.1*
lrwxrwxrwx    1 admin    administ       15 Jan  3 11:10 libblkid.so.1 -> 
libblkid.so.1.0*
-rwxr-xr-x    1 admin    administ    41080 Feb 14  2012 libblkid.so.1.0*
-rw-r--r--    1 admin    administ      209 Feb 14  2012 libc.so
-rw-r--r--    1 admin    administ    20912 Feb 14  2012 libc_nonshared.a
lrwxrwxrwx    1 admin    administ       15 Jan  3 11:10 libcom_err.so -> 
libcom_err.so.2*
lrwxrwxrwx    1 admin    administ       17 Jan  3 11:10 libcom_err.so.2 
-> libcom_err.so.2.1*
-rwxr-xr-x    1 admin    administ     8828 Feb 14  2012 libcom_err.so.2.1*
-rwxr-xr-x    1 admin    administ   721164 Feb 15  2012 libdb-4.2.so*
lrwxrwxrwx    1 admin    administ       12 Jan  3 11:24 libdb-4.so -> 
libdb-4.2.so*
lrwxrwxrwx    1 admin    administ       12 Jan  3 11:24 libdb.so -> 
libdb-4.2.so*
lrwxrwxrwx    1 admin    administ       11 Jan  3 11:10 libe2p.so -> 
libe2p.so.2*
lrwxrwxrwx    1 admin    administ       13 Jan  3 11:10 libe2p.so.2 -> 
libe2p.so.2.3*
-rwxr-xr-x    1 admin    administ    22796 Feb 14  2012 libe2p.so.2.3*
lrwxrwxrwx    1 admin    administ       14 Jan  3 11:10 libext2fs.so -> 
libext2fs.so.2*
lrwxrwxrwx    1 admin    administ       16 Jan  3 11:10 libext2fs.so.2 
-> libext2fs.so.2.4*
-rwxr-xr-x    1 admin    administ   163556 Feb 14  2012 libext2fs.so.2.4*
lrwxrwxrwx    1 admin    administ       12 Jan  3 10:29 libform.so -> 
libform.so.5*
lrwxrwxrwx    1 admin    administ       14 Jan  3 10:29 libform.so.5 -> 
libform.so.5.7*
-rwxr-xr-x    1 admin    administ    44884 Dec 24 06:48 libform.so.5.7*
lrwxrwxrwx    1 admin    administ       13 Jan  3 15:19 libformw.so -> 
libformw.so.5*
lrwxrwxrwx    1 admin    administ       15 Jan  3 15:19 libformw.so.5 -> 
libformw.so.5.7*
-rwxr-xr-x    1 admin    administ    52232 Dec 22 00:32 libformw.so.5.7*
lrwxrwxrwx    1 admin    administ       13 Jan  3 11:36 libgcc_s.so -> 
libgcc_s.so.1
-rw-r--r--    1 admin    administ   238932 Feb 15  2012 libgcc_s.so.1
lrwxrwxrwx    1 admin    administ       16 Jan  3 11:24 libgdbm.so -> 
libgdbm.so.3.0.0*
lrwxrwxrwx    1 admin    administ       16 Jan  3 11:24 libgdbm.so.3 -> 
libgdbm.so.3.0.0*
-rwxr-xr-x    1 admin    administ    18660 Feb 18  2012 libgdbm.so.3.0.0*
lrwxrwxrwx    1 admin    administ       23 Jan  3 11:24 
libgdbm_compat.so -> libgdbm_compat.so.3.0.0*
lrwxrwxrwx    1 admin    administ       23 Jan  3 11:24 
libgdbm_compat.so.3 -> libgdbm_compat.so.3.0.0*
-rwxr-xr-x    1 admin    administ     6188 Feb 18  2012 
libgdbm_compat.so.3.0.0*
-rwxr-xr-x    1 admin    administ     1063 Feb 14  2012 libgio-2.0.la*
lrwxrwxrwx    1 admin    administ       22 Jan  3 11:10 libgio-2.0.so -> 
libgio-2.0.so.0.2000.4*
lrwxrwxrwx    1 admin    administ       22 Jan  3 11:10 libgio-2.0.so.0 
-> libgio-2.0.so.0.2000.4*
-rwxr-xr-x    1 admin    administ   415536 Feb 14  2012 
libgio-2.0.so.0.2000.4*
-rwxr-xr-x    1 admin    administ      986 Feb 14  2012 libglib-2.0.la*
lrwxrwxrwx    1 admin    administ       23 Jan  3 11:10 libglib-2.0.so 
-> libglib-2.0.so.0.2000.4*
lrwxrwxrwx    1 admin    administ       23 Jan  3 11:10 libglib-2.0.so.0 
-> libglib-2.0.so.0.2000.4*
-rwxr-xr-x    1 admin    administ   842160 Feb 14  2012 
libglib-2.0.so.0.2000.4*
-rwxr-xr-x    1 admin    administ     1033 Feb 14  2012 libgmodule-2.0.la*
lrwxrwxrwx    1 admin    administ       26 Jan  3 11:10 
libgmodule-2.0.so -> libgmodule-2.0.so.0.2000.4*
lrwxrwxrwx    1 admin    administ       26 Jan  3 11:10 
libgmodule-2.0.so.0 -> libgmodule-2.0.so.0.2000.4*
-rwxr-xr-x    1 admin    administ     9960 Feb 14  2012 
libgmodule-2.0.so.0.2000.4*
-rwxr-xr-x    1 admin    administ     1028 Feb 14  2012 libgobject-2.0.la*
lrwxrwxrwx    1 admin    administ       26 Jan  3 11:10 
libgobject-2.0.so -> libgobject-2.0.so.0.2000.4*
lrwxrwxrwx    1 admin    administ       26 Jan  3 11:10 
libgobject-2.0.so.0 -> libgobject-2.0.so.0.2000.4*
-rwxr-xr-x    1 admin    administ   245804 Feb 14  2012 
libgobject-2.0.so.0.2000.4*
-rwxr-xr-x    1 admin    administ     1043 Feb 14  2012 libgthread-2.0.la*
lrwxrwxrwx    1 admin    administ       26 Jan  3 11:10 
libgthread-2.0.so -> libgthread-2.0.so.0.2000.4*
lrwxrwxrwx    1 admin    administ       26 Jan  3 11:10 
libgthread-2.0.so.0 -> libgthread-2.0.so.0.2000.4*
-rwxr-xr-x    1 admin    administ    14228 Feb 14  2012 
libgthread-2.0.so.0.2000.4*
lrwxrwxrwx    1 admin    administ       15 Jan  3 10:29 libhistory.so -> 
libhistory.so.6*
lrwxrwxrwx    1 admin    administ       17 Jan  3 10:29 libhistory.so.6 
-> libhistory.so.6.1*
-r-xr-xr-x    1 admin    administ    26328 Feb 14  2012 libhistory.so.6.1*
-rw-r--r--    1 admin    administ   683294 Feb 14  2012 libiberty.a
lrwxrwxrwx    1 admin    administ       16 Jan  3 10:29 libipkg.so -> 
libipkg.so.0.0.0*
lrwxrwxrwx    1 admin    administ       16 Jan  3 10:29 libipkg.so.0 -> 
libipkg.so.0.0.0*
-rwxr-xr-x    1 admin    administ   150260 Feb 15  2012 libipkg.so.0.0.0*
lrwxrwxrwx    1 admin    administ       12 Jan  3 10:29 libmenu.so -> 
libmenu.so.5*
lrwxrwxrwx    1 admin    administ       14 Jan  3 10:29 libmenu.so.5 -> 
libmenu.so.5.7*
-rwxr-xr-x    1 admin    administ    23508 Dec 24 06:48 libmenu.so.5.7*
lrwxrwxrwx    1 admin    administ       13 Jan  3 15:19 libmenuw.so -> 
libmenuw.so.5*
lrwxrwxrwx    1 admin    administ       15 Jan  3 15:19 libmenuw.so.5 -> 
libmenuw.so.5.7*
-rwxr-xr-x    1 admin    administ    24020 Dec 22 00:32 libmenuw.so.5.7*
lrwxrwxrwx    1 admin    administ       15 Jan  3 10:29 libncurses.so -> 
libncurses.so.5*
lrwxrwxrwx    1 admin    administ       17 Jan  3 10:29 libncurses.so.5 
-> libncurses.so.5.7*
-rwxr-xr-x    1 admin    administ   251724 Dec 24 06:48 libncurses.so.5.7*
lrwxrwxrwx    1 admin    administ       16 Jan  3 15:19 libncursesw.so 
-> libncursesw.so.5*
lrwxrwxrwx    1 admin    administ       18 Jan  3 15:19 libncursesw.so.5 
-> libncursesw.so.5.7*
-rwxr-xr-x    1 admin    administ   292860 Dec 22 00:32 libncursesw.so.5.7*
-rw-r--r--    1 admin    administ    98394 Feb 14  2012 libnsl-2.5.so
lrwxrwxrwx    1 admin    administ       13 Jan  3 11:36 libnsl.so -> 
libnsl-2.5.so
lrwxrwxrwx    1 admin    administ       13 Jan  3 11:36 libnsl.so.1 -> 
libnsl-2.5.so
-rw-r--r--    1 admin    administ   449090 Feb 14  2012 libopcodes.a
-rwxr-xr-x    1 admin    administ      945 Feb 14  2012 libopcodes.la*
lrwxrwxrwx    1 admin    administ       13 Jan  3 10:29 libpanel.so -> 
libpanel.so.5*
lrwxrwxrwx    1 admin    administ       15 Jan  3 10:29 libpanel.so.5 -> 
libpanel.so.5.7*
-rwxr-xr-x    1 admin    administ     8224 Dec 24 06:48 libpanel.so.5.7*
lrwxrwxrwx    1 admin    administ       14 Jan  3 15:19 libpanelw.so -> 
libpanelw.so.5*
lrwxrwxrwx    1 admin    administ       16 Jan  3 15:19 libpanelw.so.5 
-> libpanelw.so.5.7*
-rwxr-xr-x    1 admin    administ     8224 Dec 22 00:32 libpanelw.so.5.7*
-rw-r--r--    1 admin    administ     1404 Feb 14  2012 
libpthread_nonshared.a
lrwxrwxrwx    1 admin    administ       16 Jan  3 10:29 libreadline.so 
-> libreadline.so.6*
lrwxrwxrwx    1 admin    administ       18 Jan  3 10:29 libreadline.so.6 
-> libreadline.so.6.1*
-r-xr-xr-x    1 admin    administ   204696 Feb 14  2012 libreadline.so.6.1*
lrwxrwxrwx    1 admin    administ       17 Jan  3 11:10 libslang.so -> 
libslang.so.2.2.3
lrwxrwxrwx    1 admin    administ       17 Jan  3 11:10 libslang.so.2 -> 
libslang.so.2.2.3
-rw-r--r--    1 admin    administ   811612 Feb 23  2012 libslang.so.2.2.3
lrwxrwxrwx    1 admin    administ       10 Jan  3 11:10 libss.so -> 
libss.so.2*
lrwxrwxrwx    1 admin    administ       12 Jan  3 11:10 libss.so.2 -> 
libss.so.2.0*
-rwxr-xr-x    1 admin    administ    17036 Feb 14  2012 libss.so.2.0*
-rwxr-xr-x    1 admin    administ     1308 Feb 15  2012 libstdc++.la*
lrwxrwxrwx    1 admin    administ       18 Jan  3 15:19 libstdc++.so -> 
libstdc++.so.6.0.9
lrwxrwxrwx    1 admin    administ       18 Jan  3 15:19 libstdc++.so.6 
-> libstdc++.so.6.0.9
-rw-r--r--    1 admin    administ   816192 Feb 14  2012 libstdc++.so.6.0.9
-rw-r--r--    1 admin    administ   551800 Feb 15  2012 libsupc++.a
-rwxr-xr-x    1 admin    administ     1214 Feb 15  2012 libsupc++.la*
lrwxrwxrwx    1 admin    administ       12 Jan  3 11:10 libuuid.so -> 
libuuid.so.1*
lrwxrwxrwx    1 admin    administ       14 Jan  3 11:10 libuuid.so.1 -> 
libuuid.so.1.2*
-rwxr-xr-x    1 admin    administ    15668 Feb 14  2012 libuuid.so.1.2*
drwxr-xr-x    4 admin    administ     4096 Jan  3 11:24 perl5/
drwxr-xr-x    2 admin    administ     4096 Jan  3 11:10 pkgconfig/
drwxr-xr-x    3 admin    administ     4096 Jan  3 11:10 slang/
lrwxrwxrwx    1 admin    administ       17 Jan  3 10:29 terminfo -> 
../share/terminfo/
drwxr-xr-x    2 admin    administ     4096 Jan  3 11:36 thumb2/
[/opt/lib] #

A file libc.so.6 is in /lib. But adding -Fl/lib to the compile line does 
not change the behavior.



























More information about the fpc-devel mailing list