Skip to content

Commit 9682113

Browse files
committed
lesson 14
1 parent 4299cf9 commit 9682113

File tree

4 files changed

+13
-8
lines changed

4 files changed

+13
-8
lines changed

14-checkpoint/Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,20 @@ CFLAGS = -g
1212
os-image.bin: boot/bootsect.bin kernel.bin
1313
cat $^ > os-image.bin
1414

15-
kernel.bin: kernel.elf
15+
kernel.bin: boot/kernel_entry.o ${OBJ}
1616
i386-elf-ld -o $@ -Ttext 0x1000 $^ --oformat binary
1717

18+
# Used for debugging purposes
19+
kernel.elf: boot/kernel_entry.o ${OBJ}
20+
i386-elf-ld -o $@ -Ttext 0x1000 $^
21+
1822
run: os-image.bin
1923
qemu-system-i386 -fda os-image.bin
2024

2125
debug: os-image.bin kernel.elf
2226
qemu-system-i386 -s -fda os-image.bin &
2327
${GDB} -ex "target remote localhost:1234" -ex "symbol-file kernel.elf"
2428

25-
# To build the kernel: make all objects first
26-
kernel.elf: boot/kernel_entry.o ${OBJ}
27-
i386-elf-ld -o $@ -Ttext 0x1000 $^
28-
2929
# To make an object, always compile from its .c
3030
%.o: %.c ${HEADERS}
3131
${CC} ${CFLAGS} -ffreestanding -c $< -o $@

14-checkpoint/README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,12 @@ make
3131
make install
3232
```
3333

34-
Check out the Makefile target `make debug`. We can take
35-
advantage of this cool qemu feature. Type `make debug` and, on the gdb shell:
34+
Check out the Makefile target `make debug`. This target uses builds `kernel.elf`, which
35+
is an object file (not binary) with all the symbols we generated on the kernel, thanks to
36+
the `-g` flag on gcc. Please examine it with `xxd` and you'll see some strings. Actually,
37+
the correct way to examine the strings in an object file is by `strings kernel.elf`
38+
39+
We can take advantage of this cool qemu feature. Type `make debug` and, on the gdb shell:
3640

3741
- Set up a breakpoint in `kernel.c:main()`: `b main`
3842
- Run the OS: `continue`
@@ -44,7 +48,8 @@ advantage of this cool qemu feature. Type `make debug` and, on the gdb shell:
4448
- `next` to put there our 'X'
4549
- Let's make sure: `print *video_memory` and look at the qemu screen. It's definitely there.
4650

47-
Now is a good time to read some tutorial on `gdb`!
51+
Now is a good time to read some tutorial on `gdb` and learn super useful things like `info registers`
52+
which will save us a lot of time in the future!
4853

4954

5055
Strategy

14-checkpoint/boot/bootsect.bin

512 Bytes
Binary file not shown.

14-checkpoint/kernel/kernel.o

1.89 KB
Binary file not shown.

0 commit comments

Comments
 (0)