瀏覽代碼

Kernel: Split debug symbols into a separate file

This speeds up the boot process considerably when specifying the kernel
image via -initrd.
Gunnar Beutner 4 年之前
父節點
當前提交
98f8ecd9d2

+ 5 - 1
Kernel/CMakeLists.txt

@@ -418,10 +418,14 @@ add_custom_command(
     COMMAND ${CMAKE_OBJCOPY} -O elf32-i386 ${CMAKE_CURRENT_BINARY_DIR}/${KERNEL_TARGET} ${CMAKE_CURRENT_BINARY_DIR}/Kernel
     COMMAND ${CMAKE_OBJCOPY} -O elf32-i386 ${CMAKE_CURRENT_BINARY_DIR}/${KERNEL_TARGET} ${CMAKE_CURRENT_BINARY_DIR}/Kernel
     COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/mkmap.sh
     COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/mkmap.sh
     COMMAND ${CMAKE_COMMAND} -E env OBJCOPY=${CMAKE_OBJCOPY} sh ${CMAKE_CURRENT_SOURCE_DIR}/embedmap.sh
     COMMAND ${CMAKE_COMMAND} -E env OBJCOPY=${CMAKE_OBJCOPY} sh ${CMAKE_CURRENT_SOURCE_DIR}/embedmap.sh
-    BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/Kernel ${CMAKE_CURRENT_BINARY_DIR}/kernel.map
+    COMMAND ${CMAKE_OBJCOPY} --only-keep-debug Kernel Kernel.debug
+    COMMAND ${CMAKE_OBJCOPY} --strip-debug Kernel
+    COMMAND ${CMAKE_OBJCOPY} --add-gnu-debuglink=Kernel.debug Kernel
+    BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/kernel.map
 )
 )
 
 
 install(FILES "${CMAKE_CURRENT_BINARY_DIR}/Kernel" DESTINATION boot)
 install(FILES "${CMAKE_CURRENT_BINARY_DIR}/Kernel" DESTINATION boot)
+install(FILES "${CMAKE_CURRENT_BINARY_DIR}/Kernel.debug" DESTINATION boot)
 install(FILES "${CMAKE_CURRENT_BINARY_DIR}/kernel.map" DESTINATION res)
 install(FILES "${CMAKE_CURRENT_BINARY_DIR}/kernel.map" DESTINATION res)
 
 
 serenity_install_headers(Kernel)
 serenity_install_headers(Kernel)

+ 1 - 0
Meta/build-root-filesystem.sh

@@ -97,6 +97,7 @@ fi
 
 
 chmod 0400 mnt/res/kernel.map
 chmod 0400 mnt/res/kernel.map
 chmod 0400 mnt/boot/Kernel
 chmod 0400 mnt/boot/Kernel
+chmod 0400 mnt/boot/Kernel.debug
 chmod 600 mnt/etc/shadow
 chmod 600 mnt/etc/shadow
 chmod 755 mnt/res/devel/templates/*.postcreate
 chmod 755 mnt/res/devel/templates/*.postcreate
 echo "done"
 echo "done"

+ 1 - 1
Userland/DevTools/HackStudio/Debugger/DisassemblyModel.cpp

@@ -31,7 +31,7 @@ DisassemblyModel::DisassemblyModel(const Debug::DebugSession& debug_session, con
     const ELF::Image* elf = nullptr;
     const ELF::Image* elf = nullptr;
 
 
     if (containing_function.value().address_low >= 0xc0000000) {
     if (containing_function.value().address_low >= 0xc0000000) {
-        auto file_or_error = MappedFile::map("/boot/Kernel");
+        auto file_or_error = MappedFile::map("/boot/Kernel.debug");
         if (file_or_error.is_error())
         if (file_or_error.is_error())
             return;
             return;
         kernel_elf = make<ELF::Image>(file_or_error.value()->bytes());
         kernel_elf = make<ELF::Image>(file_or_error.value()->bytes());

+ 1 - 1
Userland/DevTools/Profiler/DisassemblyModel.cpp

@@ -42,7 +42,7 @@ DisassemblyModel::DisassemblyModel(Profile& profile, ProfileNode& node)
     FlatPtr base_address = 0;
     FlatPtr base_address = 0;
     if (m_node.address() >= 0xc0000000) {
     if (m_node.address() >= 0xc0000000) {
         if (!m_kernel_file) {
         if (!m_kernel_file) {
-            auto file_or_error = MappedFile::map("/boot/Kernel");
+            auto file_or_error = MappedFile::map("/boot/Kernel.debug");
             if (file_or_error.is_error())
             if (file_or_error.is_error())
                 return;
                 return;
             m_kernel_file = file_or_error.release_value();
             m_kernel_file = file_or_error.release_value();

+ 1 - 1
Userland/DevTools/Profiler/Profile.cpp

@@ -201,7 +201,7 @@ Result<NonnullOwnPtr<Profile>, String> Profile::load_from_perfcore_file(const St
 
 
     auto& object = json.value().as_object();
     auto& object = json.value().as_object();
 
 
-    auto file_or_error = MappedFile::map("/boot/Kernel");
+    auto file_or_error = MappedFile::map("/boot/Kernel.debug");
     OwnPtr<ELF::Image> kernel_elf;
     OwnPtr<ELF::Image> kernel_elf;
     if (!file_or_error.is_error())
     if (!file_or_error.is_error())
         kernel_elf = make<ELF::Image>(file_or_error.value()->bytes());
         kernel_elf = make<ELF::Image>(file_or_error.value()->bytes());

+ 1 - 1
Userland/Libraries/LibSymbolication/Symbolication.cpp

@@ -84,7 +84,7 @@ Vector<Symbol> symbolicate_thread(pid_t pid, pid_t tid)
     regions.append(RegionWithSymbols {
     regions.append(RegionWithSymbols {
         .base = 0xc0000000,
         .base = 0xc0000000,
         .size = 0x3fffffff,
         .size = 0x3fffffff,
-        .path = "/boot/Kernel",
+        .path = "/boot/Kernel.debug",
         .is_relative = false });
         .is_relative = false });
 
 
     {
     {