Driver dependency in Solaris 2.6

Driver dependency in Solaris 2.6

Post by Malcolm Lithgo » Thu, 19 Feb 1998 04:00:00



I'm trying to port a product that consists of a stack of
STREAMS modules. One of the modules is a logging module, and a number of
the modules call directly into it to do logging. The top module also
calls directly into the module below it, since they share many utility
routines.

In Solaris 2.4 and possibly 2.5, the char *_depends_on variable allowed
me to specify a module that this one depended upon, and if THAT module
depended on anything, the first one would pick up all the symbols in
that last module as well.

Now in Solaris 2.6 it seems that the linker is only looking in the
module specified in _depends_on only, and is not finding unresolved
externals in the second level of dependency. There is effectively no
documentation on this, so I don't know if it's possible to list multiple
dependencies in _depends_on (I've tried colons and commas as separators,
but they're treated as part of the module name).

Does anyone know how to solve this problem without munging two of my
modules together into one? It seems like a fairly fundamental
requirement to me.

Thanks,
Malcolm Lithgow.

 
 
 

Driver dependency in Solaris 2.6

Post by Casper H.S. Dik - Network Security Engine » Thu, 19 Feb 1998 04:00:00


[[ PLEASE DON'T SEND ME EMAIL COPIES OF POSTINGS ]]


>In Solaris 2.4 and possibly 2.5, the char *_depends_on variable allowed
>me to specify a module that this one depended upon, and if THAT module
>depended on anything, the first one would pick up all the symbols in
>that last module as well.

Which is arguably a bug; libraries dont' work that way either
(shouldn't anyway).

Quote:>Now in Solaris 2.6 it seems that the linker is only looking in the
>module specified in _depends_on only, and is not finding unresolved
>externals in the second level of dependency. There is effectively no
>documentation on this, so I don't know if it's possible to list multiple
>dependencies in _depends_on (I've tried colons and commas as separators,
>but they're treated as part of the module name).

_depends_on is not documented because it's a hack.

You can have multiple depends_ons using:

        char _depends_on[] = "misc/foo drv/bar";

Seperate with spaces.

Quote:>Does anyone know how to solve this problem without munging two of my
>modules together into one? It seems like a fairly fundamental
>requirement to me.

Yep, Solaris does it in a few modules too.

Casper
--
Expressed in this posting are my opinions.  They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.

 
 
 

1. Dependencies not loaded with dlopen() in Solaris 2.6

I have 2 shared libs I'm trying to dlopen() under Solaris 2.6.
The first, libdl1.so, defines 1 function func1() and has no dependencies.
The second, libdl2.so, defines 1 function func2() that calls func1().
libdl2.so is linked with libdl1.so.  I dlopen("./libld1.so"), then
./libdl2.so.  To ensure that dl2 sees I've already loaded dl1, I open
both with RTLD_GLOBAL (as well as RTLD_NOW for sanity).

  All works fine under Solaris 2.5.1 and 2.8 -- even without RTLD_GLOBAL,
and if the current dir/lib dir/executable dir is changed.
However, under Solaris 2.6, the dlopen() of dl2 fails because it cannot
load dl1.  It will only work if I set LD_LIBRARY_PATH or the like, which
I most assuredly do not wish to do.  With copious LD_DEBUG tracing I can
see the loader looking for dl1 during the dl2 dlopen() in the standard
/usr/lib place in both 2.6 and 2.8.  However, in 2.6 it reports failure
and errors, whilst 2.8 succeeds, apparently finding it already loaded.
(sidebar: why check /usr/lib *before* finding out dl1 is already loaded?)

  Any guesses as to why this works in 2.5.1 and 2.8, but *not* 2.6?  I'm
using Solaris cc and ld in both cases.  Any help is appreciated, thanks.
The 2.6 box is:  SunOS 5.6 Generic_105181-05 sun4u sparc SUNW,Ultra-2

-Kai

------------------------------cut-----------------------------------------
make with:
cc -Kpic -c dl1.c -o dl1.o
cc -G -o libdl1.so -h libdl1.so dl1.o
cc -Kpic -c dl2.c -o dl2.o
cc -G -o libdl2.so -h libdl2.so dl2.o -L. -ldl1
cc -Kpic -o dltest dltest.c -ldl
run as:
./dltest RTLD_GLOBAL ./libdl1.so ./libdl2.so

-----dl1.c:-----
void
func1()
{
-----dl2.c:-----
extern void func1();

void
func2()
{
  func1();
-----dltest.c:-----
#include <stdio.h>
#include <stdlib.h>
#include <dlfcn.h>

int
main(argc, argv)
int argc;
char *argv[];
{
  void *l1, *l2;
  void (*f1)(), (*f2)();
  int mode = 0;

  if (argc != 4)
    {
      printf("usage: %s mode lib1 lib2\n", argv[0]);
      return(1);
    }
  mode = (RTLD_NOW | (strcmp(argv[1], "RTLD_GLOBAL") == 0 ? RTLD_GLOBAL : 0));

  l1 = dlopen(argv[2], mode);
  if (l1 == NULL)
    printf("dlopen(%s) failed: %s\n", argv[2], dlerror());
  else if ((f1 = (void (*)())dlsym(l1, "func1")) == NULL)
    printf("dlsym(func1) failed: %s\n", dlerror());
  else
    f1();
  l2 = dlopen(argv[3], mode);
  if (l2 == NULL)
    printf("dlopen(%s) failed: %s\n", argv[3], dlerror());
  else if ((f2 = (void (*)())dlsym(l2, "func2")) == NULL)
    printf("dlsym(func2) failed: %s\n", dlerror());
  else
    f2();
  return(0);
-------------------------------------end------------------------------------

2. Recommend graphics card: xpert@work/diamond fire gl pro?

3. can't read Solaris 2.6 x86 hard disk on Solaris 2.6 Ultra-1 ?!?

4. emacs 18.57 on RS6000s

5. Upgrade from Solaris 2.6 with Volume Manager 2.6 to Solaris 8 with Volume Manager 3.2

6. Cylinder 1108 instead 1024?

7. Network Drivers on Solaris 2.6 ported from Solaris 2.5.1

8. WANTED: public domain (or GPL) bar code utilities

9. Hints for porting driver for Solaris 2.6 to Solaris 7

10. Errors compiling Wingz 1.4 Add-ins (Linux 1.3.99, GCC 2.6)

11. accessing ifconfig table under driver on Solaris 2.6

12. Help programming Solaris 2.6 driver (SPARC)

13. Solaris 2.6 x86 video driver for Dell Latitude CP notebook