GDB disassembly filled with zeros

0

When I run objdump -D on my file, I get the assembly code I expect.

kernel.elf:     file format elf32-i386

Disassembly of section .text:

00100000 <__code>:
  100000:       02 b0 ad 1b 03 00       add    0x31bad(%eax),%dh
  100006:       00 00                   add    %al,(%eax)
  100008:       fb                      sti
  100009:       4f                      dec    %edi
  10000a:       52                      push   %edx
  10000b:       e4 00                   in     $0x0,%al
  10000d:       00 10                   add    %dl,(%eax)
  10000f:       00 00                   add    %al,(%eax)
  100011:       00 10                   add    %dl,(%eax)
  100013:       00 00                   add    %al,(%eax)
  100015:       20 10                   and    %dl,(%eax)
  100017:       00 00                   add    %al,(%eax)
  100019:       40                      inc    %eax
  10001a:       10 00                   adc    %al,(%eax)
  10001c:       20 00                   and    %al,(%eax)
  10001e:       10 00                   adc    %al,(%eax)

00100020 <start>:
  100020:       fa                      cli
  100021:       bc 00 40 10 00          mov    $0x104000,%esp
  100026:       53                      push   %ebx
  100027:       e8 02 00 00 00          call   10002e <main>
  10002c:       eb fe                   jmp    10002c <start+0xc>

0010002e <main>:
  10002e:       55                      push   %ebp
  10002f:       89 e5                   mov    %esp,%ebp
  100031:       83 ec 10                sub    $0x10,%esp
  100034:       c7 45 fc 28 23 00 00    movl   $0x2328,-0x4(%ebp)
  10003b:       b8 ef be ad de          mov    $0xdeadbeef,%eax
  100040:       c9                      leave
  100041:       c3                      ret
  100042:       66 90                   xchg   %ax,%ax
  100044:       66 90                   xchg   %ax,%ax
  100046:       66 90                   xchg   %ax,%ax
  100048:       66 90                   xchg   %ax,%ax
  ...

However, when I open the file on GDB (via QEMU and target remote) and run (gdb) disassemble, the same locations hold null values instead of the expected instructions (add %al,(%eax) is equivalent to 00 00).

(gdb) set $pc = mboot
(gdb) disas
Dump of assembler code for function mboot:
=> 0x00100000 <+0>:     add    %al,(%eax)
   0x00100002 <+2>:     add    %al,(%eax)
   0x00100004 <+4>:     add    %al,(%eax)
   0x00100006 <+6>:     add    %al,(%eax)
   0x00100008 <+8>:     add    %al,(%eax)
   0x0010000a <+10>:    add    %al,(%eax)
   0x0010000c <+12>:    add    %al,(%eax)
   0x0010000e <+14>:    add    %al,(%eax)
   0x00100010 <+16>:    add    %al,(%eax)
   0x00100012 <+18>:    add    %al,(%eax)
   0x00100014 <+20>:    add    %al,(%eax)
   0x00100016 <+22>:    add    %al,(%eax)
   0x00100018 <+24>:    add    %al,(%eax)
   0x0010001a <+26>:    add    %al,(%eax)
   0x0010001c <+28>:    add    %al,(%eax)
   0x0010001e <+30>:    add    %al,(%eax)
End of assembler dump.

(gdb) set $pc = start
(gdb) disas
Dump of assembler code for function start:
=> 0x00100020 <+0>:     add    %al,(%eax)
   0x00100022 <+2>:     add    %al,(%eax)
   0x00100024 <+4>:     add    %al,(%eax)
   0x00100026 <+6>:     add    %al,(%eax)
   0x00100028 <+8>:     add    %al,(%eax)
   0x0010002a <+10>:    add    %al,(%eax)
   0x0010002c <+12>:    add    %al,(%eax)
End of assembler dump.

(gdb) set $pc = main
(gdb) disas
Dump of assembler code for function main:
=> 0x0010002e <+0>:     add    %al,(%eax)
   0x00100030 <+2>:     add    %al,(%eax)
   0x00100032 <+4>:     add    %al,(%eax)
   0x00100034 <+6>:     add    %al,(%eax)
   0x00100036 <+8>:     add    %al,(%eax)
   0x00100038 <+10>:    add    %al,(%eax)
   0x0010003a <+12>:    add    %al,(%eax)
   0x0010003c <+14>:    add    %al,(%eax)
   0x0010003e <+16>:    add    %al,(%eax)
   0x00100040 <+18>:    add    %al,(%eax)
End of assembler dump.

Why is this happening? Why doesn't GDB read (load?) the correct values?

operating-system
gdb
kernel
elf
qemu
asked on Stack Overflow Apr 19, 2018 by Jet Blue • edited Apr 19, 2018 by Jet Blue

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0