NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

lib/39649: dlsym(3) does not follow dependencies

>Number:         39649
>Category:       lib
>Synopsis:       dlsym(3) does not follow dependencies
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Sep 29 12:05:00 +0000 2008
>Originator:     Jared D. McNeill
>Release:        NetBSD 4.99.72
System: NetBSD 4.99.72 NetBSD 4.99.72 (GENERIC) #98: Tue Sep 
23 14:23:39 EDT 2008
Architecture: x86_64
Machine: amd64
        After dlopen(3)ing a library and then calling dlsym(3) on the handle,
        symbols in libraries marked as NEEDED are not searched.

        Install multimedia/ffmpeg and run the following test application.

        Results on NetBSD -current:

                $ cc -Wl,-R/usr/pkg/lib test.c -o test 
                $ ./test
                couldn't find symbol av_free: Undefined symbol "av_free"

        Results on Ubuntu 8.04LTS:

                $ cc test.c -o test -ldl
                $ ./test

        Test application:

#include <dlfcn.h>
#include <stdio.h>
#include <stdlib.h>

        void *hdl, *fn;

        hdl = dlopen("", RTLD_NOW);
        if (hdl == NULL) {
                printf("couldn't find libavcodec: %s\n", dlerror());
                return EXIT_FAILURE;

        /* av_free is in libavutil */
        fn = dlsym(hdl, "av_free");
        if (fn == NULL) {
                printf("couldn't find symbol av_free: %s\n", dlerror());
                return EXIT_FAILURE;


        return 0;


Home | Main Index | Thread Index | Old Index