Issue Details (XML | Word | Printable)

Key: CORE-2193
Type: Improvement Improvement
Status: Open Open
Priority: Major Major
Assignee: Unassigned
Reporter: Eugenk Konkov
Votes: 1
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Firebird Core

How to see cause why FireBird does not see UDF?

Created: 15/Nov/08 06:27 PM   Updated: 18/Feb/09 02:36 PM
Component/s: UDF
Affects Version/s: 2.0.3
Fix Version/s: None


 Description  « Hide

1. Test how firebird recognize libxxx and xxx and xxx.so libraries
(because of C variant of UDF works I will try gcc)

a) source file:
extern int c_test();

int c_test()

return 8;


b) home# gcc -c testudf.c
c) home# gcc testudf.o -o testudf.so -shared
d) home# nm testudf.so
00001630 A _DYNAMIC
00001704 A _GLOBAL_OFFSET_TABLE_
         w _Jv_RegisterClasses
000016f4 d __CTOR_END__
000016f0 d __CTOR_LIST__
000016fc d __DTOR_END__
000016f8 d __DTOR_LIST__
0000162c r __FRAME_END__
00001700 d __JCR_END__
00001700 d __JCR_LIST__
0000171c A __bss_start
         w __cxa_finalize@@FBSD_1.0
00000550 t __do_global_ctors_aux
000004a0 t __do_global_dtors_aux
00001624 d __dso_handle
00000537 t __i686.get_pc_thunk.bx
0000171c A _edata
00001720 A _end
00000584 T _fini
0000046c T _init
00000540 T c_test
0000171c b completed.4685
00000500 t frame_dummy
00001628 d p.4683

e) ls -l
-rwxr-xr-x 1 root wheel 4520 15 ноя 21:29 testudf.so
f) cp testudf.so /usr/local/libexec/firebird/udf
g) Because of FireBird is started from inetd:
home# /etc/rc.d/inetd restart
Stopping inetd.
Starting inetd.
h)
DECLARE EXTERNAL FUNCTION FNTEST
  RETURNS INTEGER BY VALUE
  ENTRY_POINT 'c_test'
  MODULE_NAME 'testudf'
i) select fntest() from rdb$database
result 8

2. Now I test different names for UDF
a) home# cd /usr/local/libexec/firebird/udf
b) home# mv testudf.so libtestudf.so
c) home# /etc/rc.d/inetd restart
Stopping inetd.
Starting inetd.

d) select fntest() from rdb$database
result 8

e) home# mv libtestudf.so testudf
f) home# /etc/rc.d/inetd restart
Stopping inetd.
Starting inetd.

g) select fntest() from rdb$database
result 8

h) home# mv testudf libtestudf
i) home# /etc/rc.d/inetd restart
Stopping inetd.
Starting inetd.

j) select fntest() from rdb$database
k) invalid requiest BLR at offset 60
function FNTEST is not defined
module name or entrypoint could not be found

So when I write:
... MODULE_NAME 'testudf'
firebird will see testudf.so/libtestudf.so/testudf and do not see libtestudf

PS.
#rm libtestudf
#cd to my directory with sources

3. Now I try to compile by FPC:
a) home# cat testudf.pp
library testudf;

function pp_test(): integer; cdecl; export;
begin
 pp_test:= 7;
end;

exports
 pp_test name 'pp_test2';
begin
end.

b) home# fpc testudf.pp
Target OS: FreeBSD/ELF for i386
Compiling testudf.pp
Linking libtestudf.so
11 lines compiled, 0.1 sec

c) nm libtestudf.so > libtestudf.txt see in attached file
libtestudf.txt
d) home# cp libtestudf.so /usr/local/libexec/firebird/udf
e) home# /etc/rc.d/inetd restart
Stopping inetd.
Starting inetd.
f) Change definition in SQL. So now it looks like:
DECLARE EXTERNAL FUNCTION FNTEST
  RETURNS INTEGER BY VALUE
  ENTRY_POINT 'pp_test'
  MODULE_NAME 'testudf'
g) select fntest() from rdb$database
h) invalid requiest BLR at offset 60
function FNTEST is not defined
module name or entrypoint could not be found

i) change definition in SQL. So now it looks like:
DECLARE EXTERNAL FUNCTION FNTEST
  RETURNS INTEGER BY VALUE
  ENTRY_POINT 'pp_test2'
  MODULE_NAME 'testudf'
j) select fntest() from rdb$database
k) invalid requiest BLR at offset 60
function FNTEST is not defined
module name or entrypoint could not be found

4. Compiling with fpc -Xc
a) nm testudf.o
home# nm testudf.o
         U FPC_INITIALIZEUNITS
00000020 D FPC_RESOURCESTRINGTABLES
00000014 D FPC_THREADVARTABLES
         U INIT$_SYSTEM
00000004 D INITFINAL
00000000 T P$TESTUDF_PP_TEST$$SMALLINT
00000014 T P$TESTUDF_main
00000014 T PASCALMAIN
00000000 D THREADVARLIST_P$TESTUDF
         U THREADVARLIST_SYSTEM
0000002c D __fpc_valgrind
00000028 D __heapsize
00000024 D __stklen
00000000 T pp_test
00000020 T pp_test2

b) home# cp libtestudf.so /usr/local/libexec/firebird/udf
c) home# /etc/rc.d/inetd restart
Stopping inetd.
Starting inetd.
d) DECLARE EXTERNAL FUNCTION FNTEST
  RETURNS INTEGER BY VALUE
  ENTRY_POINT 'pp_test2'
  MODULE_NAME 'testudf'
e) select fntest() from rdb$database
f) invalid requiest BLR at offset 60
function FNTEST is not defined
module name or entrypoint could not be found

g) DECLARE EXTERNAL FUNCTION FNTEST
  RETURNS INTEGER BY VALUE
  ENTRY_POINT 'pp_test'
  MODULE_NAME 'testudf'
h) select fntest() from rdb$database
i) invalid requiest BLR at offset 60
function FNTEST is not defined
module name or entrypoint could not be found


CONCLUSION: FPC generate wrong object file???


 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
There are no comments yet on this issue.