title: wrong memory locations when debugging in qemu with gdb
body: <p>I'm writing a little kernel in assembler. I'm running it in QEMU and have some problems with some bugs. Now I want to debug the kernel with dbg. So I assembled it like so:</p>
  
  <pre><code>$ nasm -g -f elf -o myos.elf myos.asm
  $ objcopy --only-keep-debug myos.elf myos.sym
  $ objcopy -O binary myos.elf myos.bin
  </code></pre>
  
  <p>Then I run it in QEMU with:</p>
  
  <pre><code>$ qemu-system-i386 -s -S myos.bin
  </code></pre>
  
  <p>Then I connect with gdb:</p>
  
  <pre><code>$ gdb
  (gdb) target remote localhost:1234
  Remote debugging using localhost:1234
  0x0000fff0 in ?? ()
  symbol-file myos.sym
  Reading symbols from /home/sven/Projekte/myos/myos.sym...done.
  </code></pre>
  
  <p>I have a label named <code>welcome</code> in my kernel that points to a string. While testing I tried to look at that string, which gave the following result:</p>
  
  <pre><code>(gdb) x/32b welcome
  0x1e &lt;welcome&gt;: 0x00    0xf0    0xa5    0xfe    0x00    0xf0    0x87    0xe9
  0x26:   0x00    0xf0    0x6e    0xc9    0x00    0xf0    0x6e    0xc9
  0x2e:   0x00    0xf0    0x6e    0xc9    0x00    0xf0    0x6e    0xc9
  0x36:   0x00    0xf0    0x57    0xef    0x00    0xf0    0x6e
  </code></pre>
  
  <p>The label is defined like this:</p>
  
  <pre><code>welcome: db "System started. Happy hacking!", 10, 0
  </code></pre>
  
  <p>So you can see, gdb is pretending welcome starts with a null byte but by definition it's not. However the kernel uses the label correctly, so it doesn't seem like a poblem with my code. Examining other parts of the memory doesn't match the loaded kernel at all.</p>
  
  <p>Does anyone know why the memory of the virtual machine doesn't match the loaded kernel, while the machine still behaves corectly?</p>