Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 07 Sep 1999 22:12:05 -0700 (PDT)
From:      John Polstra <jdp@polstra.com>
To:        Nate Williams <nate@mt.sri.com>
Cc:        current@FreeBSD.ORG
Subject:   RE: java too? (was Re: Perl still broken in 4.0-CURRENT)
Message-ID:  <XFMail.990907221205.jdp@polstra.com>
In-Reply-To: <199909071620.KAA21936@mt.sri.com>

next in thread | previous in thread | raw e-mail | index | archive | help
OK, sorry for the delay.  Here's what I'd recommend for Java:

1. To determine whether the dynamic linker implements dladdr():

    #define PATH_RTLD "/usr/libexec/ld-elf.so.1"

    if ((handle = dlopen(PATH_RTLD, RTLD_LAZY)) == NULL)
        err(1, "Can't dlopen %s: %s", PATH_RTLD, dlerror());
    
    if (dlsym(handle, "dladdr") != NULL)
        printf("%s implements dladdr()\n", PATH_RTLD);
    else
        printf("%s doesn't implement dladdr()\n", PATH_RTLD);

If the dynamic linker does implement dladdr() you can call it from
your own dladdr() wrapper via the pointer returned from the dlsym
call.  Otherwise ...

2. If the dynamic linker doesn't implement dladdr():

    #include <link.h>

    struct r_debug r_debug;

    /* "handle" is the dlopen handle for the dynamic linker (see above) */
    if ((r_debug = dlsym(handle, "r_debug")) == NULL)
        err(1, "Can't dlsym r_debug", dlerror());

See <link.h> for the details of "r_debug".  It contains a member
"r_map" which is the head of a linked list of "link_map" structures.
They contain (I think) all the information you need to implement
dladdr's functionality.  These data structures are safer to use
because they're published interfaces that are used by GDB.

Let me know if it seems like this won't do the job.

John
--
  John Polstra                                               jdp@polstra.com
  John D. Polstra & Co., Inc.                        Seattle, Washington USA
  "No matter how cynical I get, I just can't keep up."        -- Nora Ephron


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?XFMail.990907221205.jdp>