From owner-freebsd-current@FreeBSD.ORG Fri Feb 13 18:03:43 2004 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C1D5E16A4CF; Fri, 13 Feb 2004 18:03:43 -0800 (PST) Received: from mgate12.so-net.ne.jp (mgate12.so-net.ne.jp [210.139.254.159]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4140843D1F; Fri, 13 Feb 2004 18:03:43 -0800 (PST) (envelope-from fuyuki@nigredo.org) Received: from mail.dg8.so-net.ne.jp (mspool12.so-net.ne.jp [210.139.248.12]) by mgate12.so-net.ne.jp with ESMTP id i1E23c904430; Sat, 14 Feb 2004 11:03:39 +0900 (JST) Received: from ns.nigredo.org (p6242d5.spprac00.ap.so-net.ne.jp [219.98.66.213]) by mail.dg8.so-net.ne.jp with ESMTP id i1E23cE07751; Sat, 14 Feb 2004 11:03:38 +0900 (JST) Received: from ns.nigredo.org (localhost [IPv6:::1]) by ns.nigredo.org (Postfix) with ESMTP id E5C2420A9; Sat, 14 Feb 2004 11:03:37 +0900 (JST) Date: Sat, 14 Feb 2004 11:03:37 +0900 Message-ID: <86isiaa03q.wl%fuyuki@nigredo.org> From: Kimura Fuyuki To: freebsd-current@freebsd.org In-Reply-To: <86n07oa7sa.wl%fuyuki@nigredo.org> References: <86n07oa7sa.wl%fuyuki@nigredo.org> User-Agent: Wanderlust/2.10.1 (Watching The Wheels) Emacs/21.3 Mule/5.0 (SAKAKI) X-Public-Key: http://www.nigredo.org/fuyuki/public.key X-Fingerprint: 8D68 1138 1A85 8556 C6A9 274B 2C72 2E56 3AF7 3D89 MIME-Version: 1.0 (generated by SEMI 1.14.5 - "Awara-Onsen") Content-Type: text/plain; charset=US-ASCII cc: kan@FreeBSD.ORG cc: jdp@polstra.com Subject: dynamic linker problem X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Feb 2004 02:03:43 -0000 OK, I more clearly point out the problem; run the following test and think that behavior is secure/modular/comfortable or not. BEGIN--cut here--cut here #!/bin/sh cat <<'[EOF]' >crypt.c /* Define this function since I want to do so! */ char *crypt_md5(const char *pw, const char *salt) { return "imbogus"; } [EOF] cat <<'[EOF]' >dltest.c #include #include int main(void) { void *h; char *(*crypt)(const char *, const char *); h = dlopen("/lib/libcrypt.so", 0); crypt = dlsym(h, "crypt"); printf("%s\n", crypt("imthekey", "$1$salt")); } [EOF] cc -shared -o crypt.so crypt.c # Link against crypt.so since I want to do so! cc dltest.c -o dltest ./crypt.so ./dltest END--cut here--cut here At Thu, 12 Feb 2004 19:53:09 +0900, Kimura Fuyuki wrote: > > Someone please run the test below and tell me why dltest[12] show the > different results on my 5.2.1-RC2 box. At least NetBSD 1.5.2 and some > sort of Linux pass the test. > > #!/bin/sh > > cat <<[EOF] >shared.c > double sin(double d) {return 9;} > double faked_sin(double d) {return sin(d);} > [EOF] > > cat <<[EOF] >dltest.c > #include > #include > > int main(void) > { > void *h; > double (*faked_sin)(double); > > h = dlopen("./shared.so", RTLD_LAZY); > faked_sin = dlsym(h, "faked_sin"); > printf("%f\n", faked_sin(0)); > } > [EOF] > > cc -shared -o shared.so shared.c > > cc dltest.c -o dltest1 > ./dltest1 >result1 > > cc dltest.c -o dltest2 -lm > ./dltest2 >result2 > > if diff result1 result2 >/dev/null; then > echo "You are very talented." > else > echo "Please tell me what's happening!" > fi -- fuyuki