Subject: lib/8572: dlsym() returns same address for same symbol in different modules
To: None <gnats-bugs@gnats.netbsd.org>
From: None <ezy@panix.com>
List: netbsd-bugs
Date: 10/06/1999 14:36:01
>Number: 8572
>Category: lib
>Synopsis: dlsym() returns same address for same symbol in different modules
>Confidential: no
>Severity: serious
>Priority: high
>Responsible: lib-bug-people (Library Bug People)
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed Oct 6 14:35:01 1999
>Last-Modified:
>Originator: Ezra Story
>Organization:
>Release: 1.4 - i386 - current ld.elf_so from Sept 6th
>Environment:
System: NetBSD black 1.4K NetBSD 1.4K (BLACK) #14: Tue Oct 5 17:27:34 EDT 1999 ezy@black:/usr/src/cvs/syssrc/sys/arch/i386/compile/BLACK i386
>Description:
Sep 6 22:43 ld.elf_so
See PR#2791 for i386/a.out version and possible fix.
>How-To-Repeat:
Unpack the shar below make and run testmod.
# This is a shell archive. Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file". Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
# Makefile
# main.c
# mod1.c
# mod2.c
#
echo x - Makefile
sed 's/^X//' >Makefile << 'END-of-Makefile'
XCC = cc
XCFLAGS = -g $(SHARED_CFLAGS)
XSHARED_CFLAGS = -fpic
X.SUFFIXES: .so
X
XMODULE_SOURCES = mod1.c mod2.c
X
XMODULES = mod1.so mod2.so
X
XMAIN_SOURCE = main.c
X
XPROG = testmod
X
Xall: $(PROG) $(MODULES)
X
X
X
X$(PROG): $(MAIN_SOURCE)
X $(CC) -o $(PROG) $(MAIN_SOURCE)
X
Xshar testmod.shar: Makefile $(MODULE_SOURCES) $(MAIN_SOURCE)
X shar Makefile $(MODULE_SOURCES) $(MAIN_SOURCE) > testmod.shar
X
X.c.so:
X $(CC) -o tmp.o -c $(CFLAGS) $<
X $(LD) -Bshareable -o $@ tmp.o
X
END-of-Makefile
echo x - main.c
sed 's/^X//' >main.c << 'END-of-main.c'
X#include <stdio.h>
X#include <dlfcn.h>
X
Xtypedef void (*initmodule_funcptr)(void);
X
Xvoid
Xmain(int argc, char *argv[])
X{
X void *module;
X initmodule_funcptr moduleInit;
X
X printf("Opening modules...\n");
X
X /* Open and initialize 1st module */
X module = dlopen("./mod1.so", DL_LAZY);
X if (module == NULL) {
X perror("dlopen(mod1.so)");
X exit(1);
X }
X moduleInit = dlsym(module, "init_module");
X if (moduleInit == NULL) {
X perror("dlsym()");
X exit(1);
X }
X (*moduleInit)();
X
X
X /* Open and initialize 2n module */
X module = dlopen("./mod2.so", DL_LAZY);
X if (module == NULL) {
X perror("dlopen(mod2.so)");
X exit(1);
X }
X moduleInit = dlsym(module, "init_module");
X if (moduleInit == NULL) {
X perror("dlsym()");
X exit(1);
X }
X (*moduleInit)();
X
X exit(0);
X}
X
X
END-of-main.c
echo x - mod1.c
sed 's/^X//' >mod1.c << 'END-of-mod1.c'
X#include <stdio.h>
X
Xvoid
Xinit_module(void)
X{
X printf("init module 1\n");
X}
X
X
END-of-mod1.c
echo x - mod2.c
sed 's/^X//' >mod2.c << 'END-of-mod2.c'
X#include <stdio.h>
X
Xvoid
Xinit_module(void)
X{
X printf("init module 2\n");
X}
X
X
X
END-of-mod2.c
exit
>Fix:
no workaround. PR#2791?
>Audit-Trail:
>Unformatted: