鏋勫缓璋冭瘯Linux鍐呮牳缃戠粶浠g爜鐨勭幆澧僊enuOS绯荤粺
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了鏋勫缓璋冭瘯Linux鍐呮牳缃戠粶浠g爜鐨勭幆澧僊enuOS绯荤粺相关的知识,希望对你有一定的参考价值。
鏍囩锛?a href='http://www.mamicode.com/so/1/%e4%bb%a3%e7%a0%81' title='浠g爜'>浠g爜 ssl code append gdb group linux鍐呮牳 铏氭嫙 margin
涓€銆佹瀯寤鸿皟璇曠郴缁?/p>
銆€銆€涓嬭浇鍐呮牳锛?/p>
make -p /lab3/linuxkernel //杩欓噷鍙互閫夋嫨浠庡浗鍐呴暅鍍忎笅杞藉唴鏍革紝瀹樼綉涓嬭浇閫熷害澶參锛屽浗鍐呴暅鍍忓湴鍧€ //http://mirror.bjtu.edu.cn/kernel/linux/kernel/v5.x/linux5.0.1.tar.xz wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux5.0.1.tar.xz //瑙e帇杩涘叆 xz -d linux-5.0.1.tar.xz tar -xvf linux-5.0.1.tar cd linux-5.0.1
銆€銆€瀹夎鍐呮牳缂栬瘧宸ュ叿锛岃繖閲岄渶瑕佹敞鎰忕殑鏄垜浠娇鐢ㄧ殑鏄痗entOS8锛屽拰鑰佸笀缁欑殑瀹為獙鎸囧鐢ㄧ殑Ubuntu瀹夎鍛戒护鏄笉鍚岀殑锛宑entOS瀹夎鎸囦护涓簓um锛屼笖瀹夎鐨勫寘鍚嶆槸鏈夊彉鍖栫殑锛?/p>
銆€銆€Ubuntu涓嬶細
1銆€銆€ sudo apt install build-essential flex bison libssl-dev libelf-dev libncurses-dev
銆€銆€centOS涓嬶細
1 yum groupinstall "Development Tools" 2 yum install openssl-devel elfutils-libelf-devel ncurses-libs ncurses-devel
銆€銆€閰嶇疆缂栬瘧鍐呮牳锛?/p>
銆€銆€make i386_defconfig 銆€銆€// configuration written to .config 銆€銆€make menuconfig//鍦ㄨ彍鍗曟ā寮忎笅閫夋嫨寮€鍚摢浜涘唴鏍稿姛鑳? //杩欓噷瑕佹敞鎰忓皢Compile the kernel with debug info閫変笂锛岃繖鏍蜂細鏈夎皟璇曚俊鎭?/span> 銆€銆€make //缂栬瘧鍐呮牳
銆€銆€瀹夎QEMU铏氭嫙鏈猴細
1 yum -y install qemu-kvm
銆€銆€鏋勯€爉enuOS锛?/p>
1 git clone https://github.com/mengning/menu.git 2 cd menu 3 sudo yum install libc6-dev-i386 // 鍦?4浣嶇幆澧冧笅缂栬瘧32浣嶉渶瀹夎 4 make rootfs 5 //娉ㄦ剰杩欓噷缂栬瘧鍙兘浼氬嚭闂锛岀己灏慶鐨勯潤鎬佸簱锛屽畨瑁呭嵆鍙?/span> 6 cd .. 7 qemu-system-i386 -kernel linux-5.0.1/arch/x86/boot/bzImage - initrd rootfs.img 8 qemu-system-x86_64 -kernel linux5.0.1/arch/x86_64/boot/bzImage -initrd rootfs.img
銆€銆€鑷虫锛岃皟璇曠幆澧僲enuOS灏辨惌寤哄ソ浜嗭紱
浜屻€乵enuOS涓婅繍琛岀綉缁滅▼搴?/h2>
銆€銆€灏嗘湇鍔$绋嬪簭鍔犺浇鍒癿enuOS锛?/p>
1 cd ~/LinuxKernel 2 git clone https://github.com/mengning/linuxnet.git 3 cd linuxnet/lab2 4 make 5 cd ../../menu/ 6 make rootfs
銆€銆€灏嗗鎴风绋嬪簭鍔犺浇鍒癿enuOS锛?/p>
1 cd ~/LinuxKernel 2 cd linuxnet/lab3 3 make rootfs
銆€銆€杩欓噷闇€瑕佹敞鎰忕殑鏄笂杩板厠闅嗕笅鏉ョ殑鏂囦欢涓紝瑕佸皢Makefile鏂囦欢閲屽叧浜嶭inux鐨勭増鏈慨鏀逛负褰撳墠鐗堟湰锛屽嵆menuOS鐢ㄧ殑Linux鍐呮牳锛屼负linux 5.0.1锛?/p>
銆€銆€鐒跺悗menuOS绯荤粺灏卞嚭鐜颁簡reolyhi鍜宧ello鍛戒护锛屾墽琛岋紝鍙戠幇鍙互瀹屾垚閫氫俊锛?/p>
涓夈€侀€氳繃gdb鍙互璺熻釜鍒板唴鏍镐唬鐮?/h2>
cd ~/linuxlab/menu
vim Makefile
//淇敼鍏朵腑鐨勫弬鏁帮紝鍦╭emu鍚庨潰鍔犱笂-append nokaslr -s -S鍙傛暟
make rootfs
//鎵ц瀹屽悗鍑虹幇涓€涓猻top鐨剄emu锛屽浜庣瓑寰呰繛鎺ョ姸鎬?
//閲嶆柊鎵撳紑涓€涓粓绔?/span>
gdb
file ~/lib3/linuxkernel/linux-5.0.1/vmlinux
//杩炴帴鍒氬垰鍋滄鐨剄emu
target remote:1234
//鍦╯tart_kernel澶勮缃柇鐐?/span>
b start_kernel
run
//鍙互鐪嬪埌宸茬粡鍦╯tart_kernel鍑芥暟澶勫仠姝㈣繍琛屼簡
cd ~/linuxlab/menu vim Makefile //淇敼鍏朵腑鐨勫弬鏁帮紝鍦╭emu鍚庨潰鍔犱笂-append nokaslr -s -S鍙傛暟 make rootfs //鎵ц瀹屽悗鍑虹幇涓€涓猻top鐨剄emu锛屽浜庣瓑寰呰繛鎺ョ姸鎬? //閲嶆柊鎵撳紑涓€涓粓绔?/span> gdb file ~/lib3/linuxkernel/linux-5.0.1/vmlinux //杩炴帴鍒氬垰鍋滄鐨剄emu target remote:1234 //鍦╯tart_kernel澶勮缃柇鐐?/span> b start_kernel run //鍙互鐪嬪埌宸茬粡鍦╯tart_kernel鍑芥暟澶勫仠姝㈣繍琛屼簡
銆€銆€濡傛湁闇€瑕侊紝鍙互璁剧疆鏇村鏂偣鐢ㄤ互璋冭瘯绋嬪簭锛屼緥濡傚彲浠ラ€氳繃break rest_init锛屽湪rest_init澶勮缃柇鐐癸紝骞跺彲浠ヤ娇鐢╨ist鍙互鏌ョ湅鍒皉est_init鍓嶅悗鐨勪唬鐮?/p>
以上是关于鏋勫缓璋冭瘯Linux鍐呮牳缃戠粶浠g爜鐨勭幆澧僊enuOS绯荤粺的主要内容,如果未能解决你的问题,请参考以下文章