Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 12 Feb 2004 19:53:09 +0900
From:      Kimura Fuyuki <fuyuki@nigredo.org>
To:        freebsd-current@freebsd.org
Subject:   relocator oddity?
Message-ID:  <86n07oa7sa.wl%fuyuki@nigredo.org>

next in thread | raw e-mail | index | archive | help
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 <stdio.h>
#include <dlfcn.h>

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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?86n07oa7sa.wl%fuyuki>