Carlos Fenollosa %!s(int64=10) %!d(string=hai) anos
pai
achega
968211392d
Modificáronse 4 ficheiros con 13 adicións e 8 borrados
  1. 5 5
      14-checkpoint/Makefile
  2. 8 3
      14-checkpoint/README.md
  3. BIN=BIN
      14-checkpoint/boot/bootsect.bin
  4. BIN=BIN
      14-checkpoint/kernel/kernel.o

+ 5 - 5
14-checkpoint/Makefile

@@ -12,9 +12,13 @@ CFLAGS = -g
 os-image.bin: boot/bootsect.bin kernel.bin
 	cat $^ > os-image.bin
 
-kernel.bin: kernel.elf
+kernel.bin: boot/kernel_entry.o ${OBJ}
 	i386-elf-ld -o $@ -Ttext 0x1000 $^ --oformat binary
 
+# Used for debugging purposes
+kernel.elf: boot/kernel_entry.o ${OBJ}
+	i386-elf-ld -o $@ -Ttext 0x1000 $^ 
+
 run: os-image.bin
 	qemu-system-i386 -fda os-image.bin
 
@@ -22,10 +26,6 @@ debug: os-image.bin kernel.elf
 	qemu-system-i386 -s -fda os-image.bin &
 	${GDB} -ex "target remote localhost:1234" -ex "symbol-file kernel.elf"
 
-# To build the kernel: make all objects first
-kernel.elf: boot/kernel_entry.o ${OBJ}
-	i386-elf-ld -o $@ -Ttext 0x1000 $^ 
-
 # To make an object, always compile from its .c
 %.o: %.c ${HEADERS}
 	${CC} ${CFLAGS} -ffreestanding -c $< -o $@

+ 8 - 3
14-checkpoint/README.md

@@ -31,8 +31,12 @@ make
 make install
 ```
 
-Check out the Makefile target `make debug`. We can take
-advantage of this cool qemu feature. Type `make debug` and, on the gdb shell:
+Check out the Makefile target `make debug`. This target uses builds `kernel.elf`, which
+is an object file (not binary) with all the symbols we generated on the kernel, thanks to
+the `-g` flag on gcc. Please examine it with `xxd` and you'll see some strings. Actually,
+the correct way to examine the strings in an object file is by `strings kernel.elf`
+
+We can take advantage of this cool qemu feature. Type `make debug` and, on the gdb shell:
 
 - Set up a breakpoint in `kernel.c:main()`: `b main`
 - Run the OS: `continue`
@@ -44,7 +48,8 @@ advantage of this cool qemu feature. Type `make debug` and, on the gdb shell:
 - `next` to put there our 'X'
 - Let's make sure: `print *video_memory` and look at the qemu screen. It's definitely there.
 
-Now is a good time to read some tutorial on `gdb`!
+Now is a good time to read some tutorial on `gdb` and learn super useful things like `info registers`
+which will save us a lot of time in the future!
 
 
 Strategy

BIN=BIN
14-checkpoint/boot/bootsect.bin


BIN=BIN
14-checkpoint/kernel/kernel.o