Dave
2020-04-21 21:34:35 UTC
Hello,
I've been experimenting with accessing native DLLs from TNS programs, as documented in the "Guardian Programmer's Guide" section "Accessing User-provided DLLs from TNS Programs" [1]. It seems to work as advertised, unless the native DLL tries to link with the C runtime. When the loader tries to resolve the runtime DLL, and the other DLLs it references, it fails. I've tried a lot of different things, including explicitly opening the runtime DLLs with dlopen(). Error examples are below. It won't get past failing to load xcrtldll if I don't add define _RLD_FIRST_LIB_PATH. With that define set, it terminates with "corrupted environment".
Has anyone had any success with linking TNS with native DLLs that use the C runtime? I can provide sample code if interested.
Thanks,
Dave
[1] https://support.hpe.com/hpesc/public/docDisplay?docLocale=en_US&docId=emr_na-a00045528en_us
== The TNS program is CLIENT in written in TAL.
== The DLL is LIBDLL written in C.
== Error with =_RLD_FIRST_LIB_PATH not set
tacl> info define =_RLD*
Define Name =_RLDVERBOSE
CLASS MAP
FILE $VOL.#8
tacl> run client
0001:Searching for load file '$VOL.SUBVOL.libdll'.
0002:Opened Library '$VOL.SUBVOL.libdll'
0003:Loaded Library '$VOL.SUBVOL.libdll',
Segment base address = 0x0000000078000000
Rebase amount = 0x0000000000000000
0004:Searching for load file 'xcrtldll' in Public library location.
*** RLD ERROR ***: Internal Error 717 Context#:-1 Context1:NSKKeyBasicCall_ Context2:NSKPubLibsOpenPublicLib
T0893L01 XTNSDLL - OCI/OCA version 25, 2017/08/01
*** TNS Error 4: User-provided DLL $VOL.SUBVOL.libdll could not be dlopen'd
dlopen (6CA005F0->$VOL.SUBVOL.libdll, 1): Internal Error 717
Context#:-1 Context1:NSKKeyBasicCall_ Context2:NSKPubLibsOpenPublicLib
TNS object file: $VOL.SUBVOL.CLIENT
Warning - 2,110 replied error 201 to the OPEN message - continuing
ABENDED: 2,110
CPU time: 0:00:00.000
== Error with =_RLD_FIRST_LIB_PATH not set
tacl> info define =_RLD*
Define Name =_RLDVERBOSE
CLASS MAP
FILE $VOL.#8
Define Name =_RLD_FIRST_LIB_PATH
CLASS SEARCH
SUBVOL0 $SYSTEM.ZDLL002F
tacl> run client
0001:Searching for load file '$VOL.SUBVOL.libdll'.
0002:Opened Library '$VOL.SUBVOL.libdll'
0003:Loaded Library '$VOL.SUBVOL.libdll',
Segment base address = 0x0000000078000000
Rebase amount = 0x0000000000000000
0004:Searching for load file 'xcrtldll' in location '$SYSTEM.ZDLL002F'.
0005:Opened Library '$SYSTEM.ZDLL002F.xcrtldll'
0006:Searching for load file 'xcredll' in location '$SYSTEM.ZDLL002F'.
0007:Opened Library '$SYSTEM.ZDLL002F.xcredll'
0008:Loaded Library '$SYSTEM.ZDLL002F.xcrtldll',
Segment base address = 0x00000000F27D0000
Rebase amount = 0x0000000000000000
0009:Opened Duplicate of Library '$SYSTEM.ZDLL002F.xcredll'
0010:Searching for load file 'XI18NDLL' in location '$SYSTEM.ZDLL002F'.
0011:Opened Library '$SYSTEM.ZDLL002F.XI18NDLL'
0012:Searching for load file 'XICNVDLL' in location '$SYSTEM.ZDLL002F'.
0013:Opened Library '$SYSTEM.ZDLL002F.XICNVDLL'
0014:Searching for load file 'XOSSKDLL' in location '$SYSTEM.ZDLL002F'.
0015:Opened Library '$SYSTEM.ZDLL002F.XOSSKDLL'
0016:Loaded Library '$SYSTEM.ZDLL002F.xcredll',
Segment base address = 0x00000000F2590000
Rebase amount = 0x0000000000000000
0017:Loaded Library '$SYSTEM.ZDLL002F.XI18NDLL',
Segment base address = 0x00000000F3420000
Rebase amount = 0x0000000000000000
0018:Opened Duplicate of Library '$SYSTEM.ZDLL002F.xcredll'
0019:Opened Duplicate of Library '$SYSTEM.ZDLL002F.xcrtldll'
0020:Opened Duplicate of Library '$SYSTEM.ZDLL002F.XICNVDLL'
0021:Loaded Library '$SYSTEM.ZDLL002F.XICNVDLL',
Segment base address = 0x00000000F34A0000
Rebase amount = 0x0000000000000000
0022:Opened Duplicate of Library '$SYSTEM.ZDLL002F.xcredll'
0023:Opened Duplicate of Library '$SYSTEM.ZDLL002F.xcrtldll'
0024:Opened Duplicate of Library '$SYSTEM.ZDLL002F.XI18NDLL'
0025:Loaded Library '$SYSTEM.ZDLL002F.XOSSKDLL',
Segment base address = 0x00000000F29F0000
Rebase amount = 0x0000000000000000
0026:Opened Duplicate of Library '$SYSTEM.ZDLL002F.xcredll'
0027:Opened Duplicate of Library '$SYSTEM.ZDLL002F.xcrtldll'
Warning - 2,136 replied error 201 to the OPEN message - continuing
ABENDED: 2,136
CPU time: 0:00:00.001
Corrupted environment
tacl>
I've been experimenting with accessing native DLLs from TNS programs, as documented in the "Guardian Programmer's Guide" section "Accessing User-provided DLLs from TNS Programs" [1]. It seems to work as advertised, unless the native DLL tries to link with the C runtime. When the loader tries to resolve the runtime DLL, and the other DLLs it references, it fails. I've tried a lot of different things, including explicitly opening the runtime DLLs with dlopen(). Error examples are below. It won't get past failing to load xcrtldll if I don't add define _RLD_FIRST_LIB_PATH. With that define set, it terminates with "corrupted environment".
Has anyone had any success with linking TNS with native DLLs that use the C runtime? I can provide sample code if interested.
Thanks,
Dave
[1] https://support.hpe.com/hpesc/public/docDisplay?docLocale=en_US&docId=emr_na-a00045528en_us
== The TNS program is CLIENT in written in TAL.
== The DLL is LIBDLL written in C.
== Error with =_RLD_FIRST_LIB_PATH not set
tacl> info define =_RLD*
Define Name =_RLDVERBOSE
CLASS MAP
FILE $VOL.#8
tacl> run client
0001:Searching for load file '$VOL.SUBVOL.libdll'.
0002:Opened Library '$VOL.SUBVOL.libdll'
0003:Loaded Library '$VOL.SUBVOL.libdll',
Segment base address = 0x0000000078000000
Rebase amount = 0x0000000000000000
0004:Searching for load file 'xcrtldll' in Public library location.
*** RLD ERROR ***: Internal Error 717 Context#:-1 Context1:NSKKeyBasicCall_ Context2:NSKPubLibsOpenPublicLib
T0893L01 XTNSDLL - OCI/OCA version 25, 2017/08/01
*** TNS Error 4: User-provided DLL $VOL.SUBVOL.libdll could not be dlopen'd
dlopen (6CA005F0->$VOL.SUBVOL.libdll, 1): Internal Error 717
Context#:-1 Context1:NSKKeyBasicCall_ Context2:NSKPubLibsOpenPublicLib
TNS object file: $VOL.SUBVOL.CLIENT
Warning - 2,110 replied error 201 to the OPEN message - continuing
ABENDED: 2,110
CPU time: 0:00:00.000
== Error with =_RLD_FIRST_LIB_PATH not set
tacl> info define =_RLD*
Define Name =_RLDVERBOSE
CLASS MAP
FILE $VOL.#8
Define Name =_RLD_FIRST_LIB_PATH
CLASS SEARCH
SUBVOL0 $SYSTEM.ZDLL002F
tacl> run client
0001:Searching for load file '$VOL.SUBVOL.libdll'.
0002:Opened Library '$VOL.SUBVOL.libdll'
0003:Loaded Library '$VOL.SUBVOL.libdll',
Segment base address = 0x0000000078000000
Rebase amount = 0x0000000000000000
0004:Searching for load file 'xcrtldll' in location '$SYSTEM.ZDLL002F'.
0005:Opened Library '$SYSTEM.ZDLL002F.xcrtldll'
0006:Searching for load file 'xcredll' in location '$SYSTEM.ZDLL002F'.
0007:Opened Library '$SYSTEM.ZDLL002F.xcredll'
0008:Loaded Library '$SYSTEM.ZDLL002F.xcrtldll',
Segment base address = 0x00000000F27D0000
Rebase amount = 0x0000000000000000
0009:Opened Duplicate of Library '$SYSTEM.ZDLL002F.xcredll'
0010:Searching for load file 'XI18NDLL' in location '$SYSTEM.ZDLL002F'.
0011:Opened Library '$SYSTEM.ZDLL002F.XI18NDLL'
0012:Searching for load file 'XICNVDLL' in location '$SYSTEM.ZDLL002F'.
0013:Opened Library '$SYSTEM.ZDLL002F.XICNVDLL'
0014:Searching for load file 'XOSSKDLL' in location '$SYSTEM.ZDLL002F'.
0015:Opened Library '$SYSTEM.ZDLL002F.XOSSKDLL'
0016:Loaded Library '$SYSTEM.ZDLL002F.xcredll',
Segment base address = 0x00000000F2590000
Rebase amount = 0x0000000000000000
0017:Loaded Library '$SYSTEM.ZDLL002F.XI18NDLL',
Segment base address = 0x00000000F3420000
Rebase amount = 0x0000000000000000
0018:Opened Duplicate of Library '$SYSTEM.ZDLL002F.xcredll'
0019:Opened Duplicate of Library '$SYSTEM.ZDLL002F.xcrtldll'
0020:Opened Duplicate of Library '$SYSTEM.ZDLL002F.XICNVDLL'
0021:Loaded Library '$SYSTEM.ZDLL002F.XICNVDLL',
Segment base address = 0x00000000F34A0000
Rebase amount = 0x0000000000000000
0022:Opened Duplicate of Library '$SYSTEM.ZDLL002F.xcredll'
0023:Opened Duplicate of Library '$SYSTEM.ZDLL002F.xcrtldll'
0024:Opened Duplicate of Library '$SYSTEM.ZDLL002F.XI18NDLL'
0025:Loaded Library '$SYSTEM.ZDLL002F.XOSSKDLL',
Segment base address = 0x00000000F29F0000
Rebase amount = 0x0000000000000000
0026:Opened Duplicate of Library '$SYSTEM.ZDLL002F.xcredll'
0027:Opened Duplicate of Library '$SYSTEM.ZDLL002F.xcrtldll'
Warning - 2,136 replied error 201 to the OPEN message - continuing
ABENDED: 2,136
CPU time: 0:00:00.001
Corrupted environment
tacl>