void return_input (void) { char array[30]; gets (array); printf("%s\n", array); }
Dopo aver compilato in gcc, questa funzione viene convertita al seguente codice Assembly:Qual è% gs in Assemblea
push %ebp mov %esp,%ebp sub $0x28,%esp mov %gs:0x14,%eax mov %eax,-0x4(%ebp) xor %eax,%eax lea -0x22(%ebp),%eax mov %eax,(%esp) call 0x8048374 lea -0x22(%ebp),%eax mov %eax,(%esp) call 0x80483a4 mov -0x4(%ebp),%eax xor %gs:0x14,%eax je 0x80484ac call 0x8048394 leave ret
Non capisco due linee:
mov %gs:0x14,%eax xor %gs:0x14,%eax
Cos'è% gs e cosa fanno esattamente queste due linee?
Questo è il comando di compilazione:
cc -c -mpreferred-stack-boundary=2 -ggdb file.c
Suppongo che si tratti di registri di segmento SS, DS, CS, ES, FS, GS. Se ho capito bene –
Possibile duplicato di [Qual è il registro "FS"/"GS" destinato?] (Http://stackoverflow.com/questions/10810203/what-is-the-fs-gs-register-intended-for) –