From owner-freebsd-bugs Tue Dec 19 6:30:11 2000 From owner-freebsd-bugs@FreeBSD.ORG Tue Dec 19 06:30:07 2000 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 6ED2E37B404 for ; Tue, 19 Dec 2000 06:30:06 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.1/8.11.1) id eBJEU6l25082; Tue, 19 Dec 2000 06:30:06 -0800 (PST) (envelope-from gnats) Resent-Date: Tue, 19 Dec 2000 06:30:06 -0800 (PST) Resent-Message-Id: <200012191430.eBJEU6l25082@freefall.freebsd.org> Resent-From: gnats-admin@FreeBSD.org (GNATS Management) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: gnats-admin@FreeBSD.org, Andrey Sverdlichenko Received: from pr.infosec.ru (pr.infosec.ru [194.135.141.98]) by hub.freebsd.org (Postfix) with ESMTP id B928637B6A0 for ; Tue, 19 Dec 2000 06:29:31 -0800 (PST) Received: from xen.infosec.ru.infosec.ru (WS_BLAZE [200.0.0.51]) by pr.infosec.ru with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2650.21) id ZBKH0L0A; Tue, 19 Dec 2000 17:31:26 +0300 Message-Id: <868zpcqyaq.fsf@xen.infosec.ru> Date: 19 Dec 2000 17:29:49 +0300 From: Andrey Sverdlichenko Sender: blaze@xen.infosec.ru To: FreeBSD-gnats-submit@freebsd.org Subject: i386/23643: dlopen() can't link to symbols in main program module Resent-Sender: gnats@FreeBSD.org Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 23643 >Category: i386 >Synopsis: dlopen() can't link to symbols in main program module >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Tue Dec 19 06:30:03 PST 2000 >Closed-Date: >Last-Modified: >Originator: Andrey Sverdlichenko >Release: FreeBSD 4.1.1-STABLE i386 >Organization: NIP "Informzaschita" >Environment: FreeBSD xen.infosec.ru 4.1.1-STABLE FreeBSD 4.1.1-STABLE #4: Mon Oct 30 15:39:57 MSK 2000 blaze@xen.infosec.ru:/var/tmp/src/sys/compile/XEN i386 >Description: Call dlopen(..., RTLD_NOW) returns "Undefined symbol" when shared object uses a symbol from main program. >How-To-Repeat: Makefile ----------- begin Makefile ----------- prog: lib.so main.c gcc -g -fpic -DPIC -Wall -o prog main.c lib.so: lib.c gcc -fpic -DPIC -O -pipe -Wall -c lib.c cc -shared -o lib.so lib.o clean: rm -f prog *.o *.so ----------- end Makefile --------------- main.c ----------- begin main.c --------------- #include #include #include char *str = "ok"; int main() { static void * lib_so; static void (*lib_so_func)(); lib_so = dlopen("./lib.so", RTLD_NOW | RTLD_GLOBAL); if (!lib_so) { fprintf(stderr, "dlopen: %s\n", dlerror()); return 1; } lib_so_func = dlsym(lib_so, "lib_so_func"); if (!lib_so_func) { fprintf(stderr, "dlsym: %s\n", dlerror()); return 1; } lib_so_func(); return 0; } ----------- end main.c ------------ lib.c ----------- begin lib.c ----------- #include extern char *str; int lib_so_func() { printf("%s\n", str); return 1; } ----------- end lib.c ----------- 0:xen:test_so$ make gcc -fpic -DPIC -O -pipe -Wall -c lib.c cc -shared -o lib.so lib.o gcc -g -fpic -DPIC -Wall -o prog main.c 0:xen:test_so$ ./prog dlopen: ./lib.so: Undefined symbol "str" >Fix: >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message