This is just a question about general fonctionnality of C language.
How can i know the size that the code of a function use in memory.
For example :
Code: Select all
int example (void){
int i = 0;
print(i);
return 1;
}
Thanks
Code: Select all
int example (void){
int i = 0;
print(i);
return 1;
}
Code: Select all
1- memcpy((char*) 0x30000, @funct1, 1000);
2- asm(" cli \n \
push $0x33 \n \
push $0x2FFF0 \n \
pushfl \n \
popl %%eax \n \
orl $0x200, %%eax \n \
and $0xffffbfff, %%eax \n \
push %%eax \n \
push $0x23 \n \
push $0x0 \n \
movl $0x1FFF0, %0 \n \
movw $0x2B, %%ax \n \
movw %%ax, %%ds \n \
iret" : "=m" (default_tss.esp0) : );
Nothing is in the bss or data section for local integer variables.Solar wrote:2) The function doesn't end up as a single block in the executable. Your code resides in the .text section, your "i = 0" reserved space in the .bss section (which doesn't even exist anywhere until after the executable is loaded for execution), and if you had a "i = 42" in there the 42 would be in the .data section. Oh, and if you added a string, it would be in the .rodata section. Now, which size would you want? (And do you want it well done or medium?)