title: What is %gs in Assembly
body: <pre>
  void return_input (void)
  { 
     char array[30]; 
  
     gets (array); 
     printf("%s\n", array); 
  }
  </pre>
  
  <p>After compiling it in gcc, this function is converted to the following Assembly code:</p>
  
  <pre>
  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  
  </pre>
  
  <p>I don't understand two lines:</p>
  
  <pre>
  mov    %gs:0x14,%eax
  xor    %gs:0x14,%eax
  </pre>
  
  <p>What is %gs, and what exactly these two lines do?</p>
  
  <p>This is compilation command:</p>
  
  <pre>
  cc -c -mpreferred-stack-boundary=2 -ggdb file.c
  </pre>