Tcl Source Code

View Ticket
Login
Ticket UUID: 217820
Title: SHLIB_PATH support for Tcl load command under HP-UX
Type: Bug Created on: 2000-10-26 00:44:11
Submitter: nobody Assigned to: nobody
Subsystem: 40. Dynamic Loading Severity:
Priority: 1 Zero Last modified: 2001-04-13 23:12:55
Status: Closed Closed by: dgp
Resolution: Duplicate Closed on: 2001-04-13 16:12:55
Version: obsolete: 8.0.4
Description:
OriginalBugID: 1460 RFE
Version: 8.0.4
SubmitDate: '1999-03-05'
LastModified: '1999-03-08'
Severity: LOW
Status: Closed
Submitter: pat
ChangedBy: pat
OS: HP-UX
OSVersion: 10.20
Machine: Other
FixedDate: '2000-10-25'
ClosedDate: '1999-03-08'


Name:

Tony Borthwick


Extensions:

Oratcl25


DesiredBehavior:

    On HP's,  in order for TclLoadFile (tclLoadShl.c) to support loading

    shared libraries located by the search path specified by SHLIB_PATH,

    then the flags parameter given to the shl_load() call needs to be OR'ed

    with DYNAMIC_PATH.


    I have been simply changing  tclLoadShl.c for each release of Tcl I use

    on HP,  and I thought it was about time it was changed in the official

    release.


    How could this be acheived :

    1) Run time switch

    2) compilation flag set by configure/Makefile

    3) Hard coded in the shl_load() call.


    You decide....


    Solaris uses LD_LIBRARY_PATH  when calling dlopen(), whether you like it

    or not,  so why not mimic the same functionality.


    In case  you haven't got access to an HP,  here's an extract from HP-UX

    10.20 shl_load() man page of all the support flags:


                              One of the following must be specified:


                                   BIND_IMMEDIATE        Resolve symbol

                                                         references when the

                                                         library is loaded.


                                   BIND_DEFERRED         Delay code symbol

                                                         resolution until

    actual

                                                         reference.


                              Zero or more of the following can be specified

    by

                              doing a bitwise OR operation:


                                   BIND_FIRST            Place the library

    at

                                                         the head of the

    symbol

                                                         search order.  In

                                                         default mode, the

                                                         library and its

                                                         dependent libraries

    are

                                                         bound independently

    of

                                                         each other (see

                                                         BIND_TOGETHER).

    This

                                                         flag may not be

                                                         supported in future

                                                         64-bit HP-UX

    releases.


                                   BIND_NONFATAL         Default

    BIND_IMMEDIATE

                                                         behavior is to

    treat

                                                         all unsatisfied

    symbols

                                                         as fatal.  This

    flag

                                                         allows binding of

                                                         unsatisfied code

                                                         symbols to be

    deferred

                                                         until use.  This

    flag

                                                         may not be

    supported in

                                                         future 64-bit HP-UX

                                                         releases.


                                   BIND_NOSTART          Do not call the

                                                         initializers for

    the

                                                         shared library when

    the

                                                         library is loaded,

    nor

                                                         on a future call to

                                                         shl_unload(); by

                                                         default, all the

                                                         initializers

    registered

                                                         with the specified

                                                         library are invoked

                                                         upon loading.  This

                                                         flag may not be

                                                         supported in future

                                                         64-bit HP-UX

    releases.


                                   BIND_VERBOSE          Print verbose

    messages

                                                         concerning possible

                                                         unsatisfied

    symbols.

                                                         This flag may not

    be

                                                         supported in future

                                                         64-bit HP-UX

    releases.


                                   BIND_RESTRICTED       Restrict symbols

                                                         visible to the

    library

                                                         to those present at

    the

                                                         time the library is

                                                         loaded.  This flag

    may

                                                         not be supported in

                                                         future 64-bit HP-UX

                                                         releases.


                                   DYNAMIC_PATH          Allow the loader to

                                                         dynamically search

    for

                                                         the library

    specified

                                                         by the path

    argument.

                                                         The directories to

    be

                                                         searched are

    determined

                                                         by the +s and +b

                                                         options of the ld

                                                         command used when

    the

                                                         program was linked.

                                                         This flag may not

    be

                                                         supported in future

                                                         64-bit HP-UX

    releases.


                                   BIND_TOGETHER         When used with

                                                         BIND_FIRST, the

    library

                                                         being mapped and

    its

                                                         dependent libraries

                                                         will be bound

    together.

                                                         This is the default

                                                         behavior for all

                                                         shl_load() requests

    not

                                                         using BIND_FIRST.

    This

                                                         flag may not be

                                                         supported in future

                                                         64-bit HP-UX

    releases.


Patch:

*** Makefile.in.old     Fri Mar  5 14:56:03 1999

--- Makefile.in.new     Fri Mar  5 14:55:13 1999

***************

*** 215,220 ****

--- 215,223 ----

  ${AC_FLAGS} ${MATH_FLAGS} ${GENERIC_FLAGS} ${PROTO_FLAGS} ${MEM_DEBUG_FLAGS} \

  ${COMPILE_DEBUG_FLAGS} ${ENV_FLAGS} -DTCL_SHLIB_EXT=\"${SHLIB_SUFFIX}\"


+ #SHL_LOAD_FLAGS = -DSHL_LOAD_FLAGS="BIND_IMMEDIATE"

+ SHL_LOAD_FLAGS = -DSHL_LOAD_FLAGS="BIND_IMMEDIATE|DYNAMIC_PATH"

+

  LIBS =                @DL_LIBS@ @LIBS@ $(MATH_LIBS) -lc


  DEPEND_SWITCHES = ${CFLAGS} -I${GENERIC_DIR} -I${SRC_DIR} \

***************

*** 695,701 ****

        $(CC) -c $(CC_SWITCHES) $(UNIX_DIR)/tclLoadOSF.c


  tclLoadShl.o: $(UNIX_DIR)/tclLoadShl.c

!       $(CC) -c $(CC_SWITCHES) $(UNIX_DIR)/tclLoadShl.c


  tclMain.o: $(GENERIC_DIR)/tclMain.c

        $(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tclMain.c

--- 698,704 ----

        $(CC) -c $(CC_SWITCHES) $(UNIX_DIR)/tclLoadOSF.c


  tclLoadShl.o: $(UNIX_DIR)/tclLoadShl.c

!       $(CC) -c $(SHL_LOAD_FLAGS) $(CC_SWITCHES) $(UNIX_DIR)/tclLoadShl.c


  tclMain.o: $(GENERIC_DIR)/tclMain.c

        $(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tclMain.c


*** tclLoadShl.c.old    Mon Sep 14 19:40:17 1998

--- tclLoadShl.c.new    Fri Mar  5 15:08:01 1999

***************

*** 11,16 ****

--- 11,23 ----

   * of this file, and for a DISCLAIMER OF ALL WARRANTIES.

   *

   * RCS: @(#) $Id: tclLoadShl.c,v 1.2 1998/09/14 18:40:17 stanton Exp $

+  *

+  *

+  * Fri Mar  5 15:03:30 GMT 1999 Tony Borthwick, Tertio Ltd:

+  * shl_load() requires the flag DYNAMIC_PATH to be set if the +b, +s specifed

+  * when linking (ld) are supported. +s allows the use of SHLIB_PATH.

+  * Replaced flags given to shl_load() with marco SHL_LOAD_FLAGS, defined in

+  * Makefile.

   */


  #include <dl.h>

***************

*** 60,66 ****

      shl_t handle;

      Tcl_DString newName;


!     handle = shl_load(fileName, BIND_IMMEDIATE, 0L);

      if (handle == NULL) {

        Tcl_AppendResult(interp, "couldn't load file \"", fileName,

                "\": ", Tcl_PosixError(interp), (char *) NULL);

--- 67,73 ----

      shl_t handle;

      Tcl_DString newName;


!     handle = shl_load(fileName, SHL_LOAD_FLAGS, 0L);

      if (handle == NULL) {

        Tcl_AppendResult(interp, "couldn't load file \"", fileName,

                "\": ", Tcl_PosixError(interp), (char *) NULL);




03/08/1999 09:14 - pat -duplicate of bug 1459