Date: Wed, 10 Aug 2016 09:44:21 +0900 From: =?UTF-8?B?5bKh6YOoIOWLneW5uA==?= <HGC02147@nifty.com> To: freebsd-users-jp@freebsd.org Subject: [FreeBSD-users-jp 95919] Re: =?utf-8?b?TERfUFJFTE9BRCDjgYzjgYbjgb7jgY/jgYTjgYvjgarjgYQ=?= Message-ID: <d5013ed9-cdaf-c8a2-2fca-8ade8d334207@nifty.com> In-Reply-To: <20160807030939.GA24330@ns.ribbon.or.jp> References: <20160807030939.GA24330@ns.ribbon.or.jp>
next in thread | previous in thread | raw e-mail | index | archive | help
$B2,It$G$9!#(B 9.3-RELEASE$B$G$O$J$/(B10.3-STABLE$B$G$9$,!"(BLD_PRELOAD$B$N@_DjH?1G$5$l$^$9$h!#(B $B%=!<%9$NJ}$KDV$j4V0c$(Ey$"$j$^$;$s$+!)(B $B0J2<!";n$7$?FbMF$G$9!#(B > % cat random_num.c > #include <stdio.h> > #include <stdlib.h> > #include <time.h> > > int > main(int argc, char **argv) > { > srand(time(NULL)); > int i = 10; > while (i--) > printf("%d\n", rand()); > return 0; > } > > % cc -o random_num random_num.c > % ./random_num > 2016130939 > 2115726213 > 976251671 > 1086788223 > 1301263032 > 354334582 > 329183349 > 666688777 > 1616105446 > 511080472 > % cat unrandom.c > #include <stdlib.h> > > int > rand(void) > { > return 42; > } > > % cc -shared -fPIC -o unrandom.so unrandom.c > % LD_PRELOAD=./unrandom.so ./random_num > 42 > 42 > 42 > 42 > 42 > 42 > 42 > 42 > 42 > 42 > % LD_PRELOAD=./unrandom.so ldd ./random_num > ./random_num: > libc.so.7 => /lib/libc.so.7 (0x800a21000) > % ---- $B2,It(B $B>!9,(B On 2016/08/07 12:09, User Ribbon wrote: > $B<B9T;~$KF0E*%i%$%V%i%j$r:9$7BX$($k<jCJ$H$7$F!"(BLD_PRELOAD $B4D6-JQ?t(B > $B$,$"$j$^$9!#;HMQNc$H$7$F$O!"(B > > https://siguniang.wordpress.com/2015/05/15/override-functions-with-ld_preload/ > > $B$J$I$,$"$j$^$9!#(B > FreeBSD$B$G$bF0$/$H;W$C$F$F%9%H$7$F$_$?$N$G$9$,F0$-$^$;$s$G$7$?!#(B > > $B>e5-(BURL$B$K$"$k%5%s%W%k%W%m%0%i%`$r;H$$!"(B > > setenv LD_PRELOAD ./unrandom.so > > $B$r$7$?$"$H!"(B > %ldd random_num > $B$H$7$F$b!"(B > random_num: > libc.so.7 => /lib/libc.so.7 (0x800a1b000) > > $B$H$J$j!"(BLD_PRELOAD $B$7$?7k2L$,H?1G$5$l$^$;$s!#(B > $BF0:n4D6-$O(B > FreeBSD bsd09-64 9.3-RELEASE-p43 FreeBSD 9.3-RELEASE-p43 #0: Sat May 28 00:19:32 UTC 2016 > $B$G$9!#(B > > $B2?$+$[$+$K@_Dj$7$J$$$HF0$+$J$$$N$G$7$g$&$+!#(B > > ribbon
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?d5013ed9-cdaf-c8a2-2fca-8ade8d334207>