Advertisement
Guest User

Untitled

a guest
Jan 19th, 2020
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.75 KB | None | 0 0
  1. diff --git a/Kernel/Arch/i386/Boot/boot.S b/Kernel/Arch/i386/Boot/boot.S
  2. index 5ae068c7..2e334825 100644
  3. --- a/Kernel/Arch/i386/Boot/boot.S
  4. +++ b/Kernel/Arch/i386/Boot/boot.S
  5. @@ -5,7 +5,7 @@
  6. .set multiboot_flags, MULTIBOOT_PAGE_ALIGN | MULTIBOOT_MEMORY_INFO | MULTIBOOT_VIDEO_MODE
  7. .set multiboot_checksum, -(MULTIBOOT_MAGIC + multiboot_flags)
  8.  
  9. -.section .multiboot
  10. +.section .multiboot, "", @progbits
  11. .align 4
  12.  
  13. .long MULTIBOOT_MAGIC
  14. @@ -36,7 +36,7 @@ stack_top:
  15. page_tables_start:
  16. .skip 4096*9
  17.  
  18. -.section .text
  19. +.section .text.startup
  20.  
  21. .global start
  22. .type start, @function
  23. diff --git a/Kernel/Makefile b/Kernel/Makefile
  24. index 6bee3dd5..5875f6d2 100644
  25. --- a/Kernel/Makefile
  26. +++ b/Kernel/Makefile
  27. @@ -117,13 +117,14 @@ EXTRA_OBJS = Arch/i386/Boot/boot.ao
  28. KERNEL = 1
  29.  
  30. PROGRAM = kernel
  31. -
  32. -SUBPROJECT_CXXFLAGS += -pie -fPIE -ffreestanding -mno-80387 -mno-mmx -mno-sse -mno-sse2 -fno-asynchronous-unwind-tables
  33. +VERBOSE = 1
  34. +SUBPROJECT_CXXFLAGS += -fPIC -ffreestanding -mno-80387 -mno-mmx -mno-sse -mno-sse2 -fno-asynchronous-unwind-tables
  35. SUBPROJECT_CXXFLAGS += -nostdlib -nostdinc -nostdinc++ -g3
  36. SUBPROJECT_CXXFLAGS += -I../Toolchain/Local/i686-pc-serenity/include/c++/9.2.0/
  37. SUBPROJECT_CXXFLAGS += -I../Toolchain/Local/i686-pc-serenity/include/c++/9.2.0/i686-pc-serenity/
  38.  
  39. -LDFLAGS += -Ttext 0x100000 -Wl,-T linker.ld -nostdlib -lgcc -lstdc++ -g3
  40. +LDFLAGS += -Wl,-e,start -nostdlib -lgcc -lstdc++ -g3 -pie -shared
  41. +#LDFLAGS += -Wl,-T linker.ld
  42.  
  43. all: $(PROGRAM) $(MODULE_OBJS) kernel.map
  44.  
  45. diff --git a/Kernel/VM/MemoryManager.cpp b/Kernel/VM/MemoryManager.cpp
  46. index c764a4c1..4e6a4ce7 100644
  47. --- a/Kernel/VM/MemoryManager.cpp
  48. +++ b/Kernel/VM/MemoryManager.cpp
  49. @@ -76,20 +76,20 @@ void MemoryManager::initialize_paging()
  50. }
  51.  
  52. // Disable writing to the kernel text and rodata segments.
  53. - extern u32 start_of_kernel_text;
  54. - extern u32 start_of_kernel_data;
  55. - for (size_t i = (u32)&start_of_kernel_text; i < (u32)&start_of_kernel_data; i += PAGE_SIZE) {
  56. - auto& pte = ensure_pte(kernel_page_directory(), VirtualAddress(i));
  57. - pte.set_writable(false);
  58. - }
  59. + //extern u32 start_of_kernel_text;
  60. + //extern u32 start_of_kernel_data;
  61. + //for (size_t i = (u32)&start_of_kernel_text; i < (u32)&start_of_kernel_data; i += PAGE_SIZE) {
  62. + // auto& pte = ensure_pte(kernel_page_directory(), VirtualAddress(i));
  63. + // pte.set_writable(false);
  64. + //}
  65.  
  66. if (g_cpu_supports_nx) {
  67. // Disable execution of the kernel data and bss segments.
  68. - extern u32 end_of_kernel_bss;
  69. - for (size_t i = (u32)&start_of_kernel_data; i < (u32)&end_of_kernel_bss; i += PAGE_SIZE) {
  70. - auto& pte = ensure_pte(kernel_page_directory(), VirtualAddress(i));
  71. - pte.set_execute_disabled(true);
  72. - }
  73. + //extern u32 end_of_kernel_bss;
  74. + //for (size_t i = (u32)&start_of_kernel_data; i < (u32)&end_of_kernel_bss; i += PAGE_SIZE) {
  75. + // auto& pte = ensure_pte(kernel_page_directory(), VirtualAddress(i));
  76. + // pte.set_execute_disabled(true);
  77. + //}
  78. }
  79.  
  80. // FIXME: We should move everything kernel-related above the 0xc0000000 virtual mark.
  81. diff --git a/Kernel/init.cpp b/Kernel/init.cpp
  82. index 7b3c0ee7..14f45ec1 100644
  83. --- a/Kernel/init.cpp
  84. +++ b/Kernel/init.cpp
  85. @@ -320,8 +320,8 @@ extern "C" [[noreturn]] void init(u32 physical_address_for_kernel_page_tables)
  86. idt_init();
  87.  
  88. // call global constructors after gtd and itd init
  89. - for (ctor_func_t* ctor = &start_ctors; ctor < &end_ctors; ctor++)
  90. - (*ctor)();
  91. + //for (ctor_func_t* ctor = &start_ctors; ctor < &end_ctors; ctor++)
  92. + // (*ctor)();
  93.  
  94. keyboard = new KeyboardDevice;
  95. ps2mouse = new PS2MouseDevice;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement