On Thu, 2014-07-17 at 13:11 +0000, Thorsten Glaser wrote:
> Ben Hutchings wrote:
>
> >Since Linux 2.6.29, you get 128 random bits at each execve(), which you
> >can access like this:
>
> getauxval() is only in (e)glibc, not in dietlibc or klibc, though.
True, and it was only added in glibc 2.16. So here's a (probably)
portable implementation:
unsigned long my_getauxval(unsigned long type)
{
extern char **environ;
struct my_elf_auxv {
unsigned long a_type;
unsigned long a_val;
} *auxp;
char **envp;
for (envp = environ; *envp; envp++)
;
++envp;
for (auxp = (struct my_elf_auxv *)envp; auxp->a_type; auxp++)
if (auxp->a_type == type)
return auxp->a_val;
return 0;
}
> Also, glibc already uses all 128 bits in some other place.
I already said that.
Ben.
--
Ben Hutchings
Kids! Bringing about Armageddon can be dangerous. Do not attempt it in
your own home. - Terry Pratchett and Neil Gaiman, `Good Omens'
Attachment:
signature.asc
Description: This is a digitally signed message part