Browse Source

modify kernel link script (#373)

put rust text between _text and _etext, so rust symbols are included in
kallsyms, traceback could use them.

modify grub_auto_install.sh to add arch linux support
zhaoyao73 1 year ago
parent
commit
285de542f3
2 changed files with 30 additions and 16 deletions
  1. 7 3
      kernel/src/link.lds
  2. 23 13
      tools/grub_auto_install.sh

+ 7 - 3
kernel/src/link.lds

@@ -25,9 +25,13 @@ SECTIONS
 	.text (text_start_pa): AT(text_start_pa - KERNEL_VMA)
 	{
 		_text = .;
-		
+
+		/* any files' .text */
 		*(.text)
-		
+
+		/* any files' .text.*, for example: rust .text._ZN* */
+		*(.text.*)
+
 		_etext = .;
 	}
 	. = ALIGN(32768);
@@ -73,4 +77,4 @@ SECTIONS
 		*(.eh_frame)
 		
 	}
-}
+}

+ 23 - 13
tools/grub_auto_install.sh

@@ -20,8 +20,27 @@ export OBJCOPY=objcopy
 if [ -d ${grub_dir_i386_efi}/bin ] && [ -d ${grub_dir_i386_legacy}/bin ] && [ -d ${grub_dir_x86_64_efi}/bin ] ; then
 	exit 0
 fi
-#仅支持Ubuntu/Debain下的自动安装
-if ! hash 2>/dev/null apt-get; then
+#仅支持Ubuntu/Debain, Arch下的自动安装
+supported_package_manager="apt-get pacman"
+packages=("make binutils bison gcc gettext flex bison automake autoconf wget" \
+          "make binutils bison gcc gettext flex bison automake autoconf wget")
+update_options=("update" \
+                "-Sy")
+install_options=("install -y" \
+                 "-S --needed --noconfirm")
+found_pm=0
+pm_index=0
+for pm in ${supported_package_manager}; do
+    if hash 2>/dev/null ${pm}; then
+        found_pm=1
+        break
+    fi
+    let pm_index=$pm_index+1
+done
+if [ ${found_pm} = "1" ]; then
+	echo "found package manager: ${pm}"
+else
+	echo "找不到任何支持的包管理器: ${supported_package_manager}"
 	echo "脚本暂不支持对该系统下grub的安装,请手动完成"
 	exit 0
 fi
@@ -35,17 +54,8 @@ fi
 
 tar xvf grub-2.06.tar.xz
 #安装对应依赖
-sudo apt-get update
-sudo apt-get install -y \
-	make 	\
-  	binutils \
-  	bison 	\
-  	gcc 	\
-  	gettext \
-	flex	\
-	bison	\
-	automake	\
-	autoconf	
+sudo ${pm} ${update_options[$pm_index]}
+sudo ${pm} ${install_options[$pm_index]} ${packages[$pm_index]}
 	
 cd grub-2.06
 echo "开始安装grub2.06"