Results 1 to 6 of 6
Hi!
Could anybody answer me why auxiliary vector has different size from call to call of any executable?
(glibc 2.7, Linux 2.6.2
example:
Code:
#include <stdio.h>
#include <elf.h>
main(int argc, ...
- 06-22-2009 #1Just Joined!
- Join Date
- Nov 2008
- Posts
- 15
[SOLVED] Strange length of auxiliary vector of executable file
Hi!
Could anybody answer me why auxiliary vector has different size from call to call of any executable?
(glibc 2.7, Linux 2.6.2
example:
Code:#include <stdio.h> #include <elf.h> main(int argc, char* argv[], char* envp[]){ Elf32_auxv_t *auxv; while(*envp++ != NULL); /*from stack diagram above: *envp = NULL marks end of envp*/ for (auxv = (Elf32_auxv_t *)envp; auxv->a_type != AT_NULL; auxv++) /* auxv->a_type = AT_NULL marks the end of auxv */ { // ddif( auxv->a_type == AT_SYSINFO) printf("addr: %x type: %x is: 0x%x\n", (int)auxv, auxv->a_type, auxv->a_un.a_val); } printf("\n (int)argv[0] - addr = %x - %x = %x\n",(int)argv[0], (int)auxv, (int)argv[0] - (int)auxv); }
- 06-23-2009 #2Just Joined!
- Join Date
- Jun 2009
- Location
- Toronto
- Posts
- 18
There are a few things wrong here. You are subtracting the wrong way, so you will be getting a negative number. You are casting pointers to ints, which may not be the same size (64 bit system). You should cast the pointer difference to an int instead:
Originally Posted by korisk
Code:printf("\n addr - argv = %p - %p = %d\n",argv, auxv, (int)((char**)auxv - argv));
- 06-23-2009 #3Just Joined!
- Join Date
- Nov 2008
- Posts
- 15
ok, thank you for the answer, but it measures just sizefo(auxv[], env[] and argv[]).
another example of mentioned phenomenon:
number of iterations is differ from load to load.Code:#include <stdio.h> int main(int argc, char *argv[], char *env[]){ char b = 1; register int c=0; register char *a = &b; while(1){ *a++ = 1; printf("%x %x\n",(int)a,c++); } return 0; }
- 06-23-2009 #4Just Joined!
- Join Date
- Jun 2009
- Location
- Toronto
- Posts
- 18
Ah, I though I was missing something... Seems like it might be a security feature?
- 06-23-2009 #5Just Joined!
- Join Date
- Nov 2008
- Posts
- 15
i don't know, but it seems security is main goal of the behavior.
it's cloudy.
- 06-24-2009 #6Just Joined!
- Join Date
- Nov 2008
- Posts
- 15
Solved.
Command
sysctl -w kernel.randomize_va_space=0
removes the phenomenon



