Advertisement
captmicro

Kernel build script

Dec 10th, 2012
330
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @echo off
  2. echo Compiling kernel...
  3. REM ASSEMBLY FILES
  4. .\nasm.exe -f elf32 -o _kloader.o ../kernel/_kloader.asm
  5. .\nasm.exe -f elf32 -o gdt_flush.o ../kernel/gdt/gdt_flush.asm
  6. .\nasm.exe -f elf32 -o idt_stubs.o ../kernel/intman/idt_stubs.asm
  7.  
  8. REM C FILES
  9. gcc.exe -fno-leading-underscore -mno-stack-arg-probe ^
  10.  -ffreestanding -fno-builtin -c ^
  11.  ^
  12.  ../kernel/portio/portio.c ^
  13.  ../kernel/pic/pic.c ^
  14.  ^
  15.  ../kernel/gdt/gdt.c ^
  16.  ../kernel/intman/idt.c ^
  17.  ../kernel/intman/intman.c ^
  18.  ^
  19.  ../kernel/envvar/envvar.c ^
  20.  ../kernel/vmem/vmem.c ^
  21.  ../kernel/tickcounter/tickcounter.c ^
  22.  ../kernel/serial/serial.c ^
  23.  ../kernel/kvideo/kvideo.c ^
  24.  ^
  25.  ../kernel/dev/dev.c ^
  26.  ../kernel/dev/kb/kb.c ^
  27.  ^
  28.  ../kernel/apps/term/term.c ^
  29.  ../kernel/apps/xedit/xedit.c ^
  30.  ^
  31.  ../kernel/kernel.c
  32.  
  33. echo Making linker script...
  34.  
  35. REM base
  36. echo STARTUP(_kloader.o) > linker.auto
  37. REM c library
  38. echo INPUT(../kernel/mylib/_mylib_min.o) >> linker.auto
  39. REM base modules
  40. echo INPUT(portio.o) >> linker.auto
  41. echo INPUT(pic.o) >> linker.auto
  42. echo INPUT(gdt_flush.o) >> linker.auto
  43. echo INPUT(gdt.o) >> linker.auto
  44. echo INPUT(idt_stubs.o) >> linker.auto
  45. echo INPUT(idt.o) >> linker.auto
  46. echo INPUT(intman.o) >> linker.auto
  47. REM kernel modules
  48. echo INPUT(envvar.o) >> linker.auto
  49. echo INPUT(vmem.o) >> linker.auto
  50. echo INPUT(tickcounter.o) >> linker.auto
  51. echo INPUT(serial.o) >> linker.auto
  52. echo INPUT(kvideo.o) >> linker.auto
  53. REM dev-like (/dev)
  54. echo INPUT(dev.o) >> linker.auto
  55. echo INPUT(kb.o) >> linker.auto
  56. REM applications
  57. echo INPUT(term.o) >> linker.auto
  58. echo INPUT(xedit.o) >> linker.auto
  59. REM kernel
  60. echo INPUT(kernel.o) >> linker.auto
  61.  
  62. echo ENTRY(_kloader) >> linker.auto
  63. echo SECTIONS >> linker.auto
  64. echo { >> linker.auto
  65. echo    .text 0x00100000 : { >> linker.auto
  66. echo        kernel_start = .; >> linker.auto
  67. echo        *(.text) >> linker.auto
  68. echo        . = ALIGN(4096); >> linker.auto
  69. echo    } >> linker.auto
  70. echo    .data : { >> linker.auto
  71. echo        *(.data) >> linker.auto
  72. echo        . = ALIGN(4096); >> linker.auto
  73. echo    } >> linker.auto
  74. echo    .rodata : { >> linker.auto
  75. echo        *(.rodata) >> linker.auto
  76. echo        . = ALIGN(4096); >> linker.auto
  77. echo    } >> linker.auto
  78. echo    .bss : { >> linker.auto
  79. echo        *(.bss) >> linker.auto
  80. echo        . = ALIGN(4096); >> linker.auto
  81. echo        kernel_end = .; >> linker.auto
  82. echo    } >> linker.auto
  83. echo } >> linker.auto
  84. echo OUTPUT(kernel.bin) >> linker.auto
  85.  
  86. echo Linking kernel...
  87. ld.exe -T linker.auto
  88. objcopy.exe -O binary kernel.bin
  89. echo Moving binary to ../_output
  90. move kernel.bin ../_output/KERNEL.BIN
  91. echo Completed, press any key to exit.
  92. pause >nul
  93. del *.o
  94. del linker.auto
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement