Browse Source

chore: use qemu for debugging

greatbridf 3 years ago
parent
commit
d6716c631d
2 changed files with 7 additions and 5 deletions
  1. 7 2
      CMakeLists.txt
  2. 0 3
      make_symbol_table.sh

+ 7 - 2
CMakeLists.txt

@@ -62,13 +62,18 @@ add_custom_command(OUTPUT extracted_kernel_main
     COMMAND ar xf ${PROJECT_BINARY_DIR}/libkernel_main.a --output=${EXTRACT_DIR}
 )
 
-add_custom_target(boot.img
+add_custom_target(kernel.out
     DEPENDS extracted_bootloader
     DEPENDS extracted_kernel_main
     COMMAND ld -T ${CMAKE_SOURCE_DIR}/ldscript.ld ${EXTRACT_DIR}/*.o
-    -melf_i386 --oformat=binary -o ${CMAKE_BINARY_DIR}/boot.img
+    -melf_i386 -o ${CMAKE_BINARY_DIR}/kernel.out
 )
 
+add_custom_target(boot.img
+    DEPENDS kernel.out
+    COMMAND objcopy --strip-debug -O binary
+    ${CMAKE_BINARY_DIR}/kernel.out boot.img)
+
 add_custom_command(OUTPUT run
     POST_BUILD
     DEPENDS boot.img

+ 0 - 3
make_symbol_table.sh

@@ -1,10 +1,7 @@
 #!/bin/sh
 
-ld -T ./ldscript.ld ./build/extract/*.o -melf_i386 --oformat=elf32-i386 -o ./build/kernel.out
-
 objdump -t ./build/kernel.out | dd of=./build/dump.txt
 
 awk '($1 ~ /[0-9]/) && ($4 != "*ABS*") && ($4 != ".text.bootsect") && ($3 != ".text.bootsect") && ($4 != ".magicnumber") {print $1 " " $NF}' ./build/dump.txt | dd of=./build/kernel.sym
 
-#rm ./build/kernel.out
 rm ./build/dump.txt