Issues with Arc4random

Robert Connolly robert at linuxfromscratch.org
Sat Dec 31 23:56:47 PST 2005


I'll fix it. Thanks.

robert

On December 30, 2005 06:24 pm, Maarten Lankhorst wrote:
> I tried compiling a simple test program with arc4random (HLFS
> SVN-20051221):
>
> #include <stdlib.h>
> #include <stdio.h>
>
> int main(void) {
>  int random_number;
>  random_number = arc4random() % 65536;
>  printf("A random number between 0 and 65536 is %d\n", random_number);
>  return 0;
> }
>
> /tmp/cceNQEwU.o: In function `main':
> arc4random.c:(.text+0x34): undefined reference to `arc4random'
> collect2: ld returned 1 exit status
>
> To my surprise, it failed, first thing I did was seeing if it was the
> same for my HLFS host, and it was.
>
> Since I was still in early chapter 6 phase, I redownloaded glibc source
> again, and applied patches.To see wether it should work or that I messed
> up somewhere, I carefully applied all patches, and found the first
> issue, SSP doesn't use arc4random in current book any more due to a
> wrong ifdef:
>
> In glibc-2.3.6-ssp-1.patch:
> +#if defined(HAVE_ARC4RANDOM) /* From <stdlib.h> */
> should be
> +#if defined(LIBC_HAS_ARC4RANDOM) /* From <stdlib.h>
>
> http://www.mail-archive.com/patches@linuxfromscratch.org/msg00474.html
> is the reason why SSP was wrong, it was probably overlooked.
>
> Secondly, glibc wasn't actually exporting the arc4random* functions, by
> looking for all references to memfrob, I found out why:
> The declarations in stdlib/Versions were missing in
> glibc-2.3.6-arc4random-1.patch, so I added them here:
>
> --- glibc-2.3.6-old/stdlib/Versions     2004-05-03 23:25:53.000000000 +0200
> +++ glibc-2.3.6/stdlib/Versions 2005-12-31 00:17:28.000000000 +0100
> @@ -11,6 +11,8 @@
>
>      # a*
>      a64l; abort; abs; atexit; atof; atoi; atol; atoll;
> +    arc4random_stir; arc4random_addrandom; arc4random;
> +    arc4random_stirII; arc4random_addrandomII; arc4randomII;
>
>      # b*
>      bsearch;
>
> After recompiling glibc, and copying glibc.so.6 to /lib, my test program
> compiled correctly.



More information about the hlfs-dev mailing list