gencode.sh
来自「南京航空航天大学开发的一个类Unix和Linux的操作系统,好不好看看就知道了,」· Shell 代码 · 共 53 行
SH
53 行
#!/bin/shcat <<\! > idletaskcode.S #include "../lib/unistd.h" .text .global _start_start: movl $__NR_fork,%eax int $0x80 cmpl $0,%eax jne 1f /* child process */ movl $__NR_setup,%eax int $0x80 movl $__NR_execve,%eax movl $path,%ebx movl $argv,%ecx movl $envp,%edx int $0x801: /* parent process */ movl $__NR_nice,%eax int $0x80 jmp 1bpath: .asciz "/sbin/init"arg0: .asciz "init"argv: .long arg0,0env0: .asciz "bee=sparrow"envp: .long env0,0!cc -c -o idletaskcode.o idletaskcode.Sld -Ttext 0x1000 idletaskcode.o -o idletaskcode# readelf output format: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Alignexec > idletaskcode.hecho "/* this file is auto generated by gencode.sh */"echo "#define IDLETASKSTART 0x1000 /* ld depend this */"echo "#define IDLETASKEND 0x2000 /* ld depend this */"offset=$(readelf --segments idletaskcode | awk '/LOAD/ { print $2; exit; }')filesz=$(readelf --segments idletaskcode | awk '/LOAD/ { print $5; exit; }')od --width=1 --output-duplicates --skip-bytes=$offset --read-bytes=$filesz \-t x1 idletaskcode | awk 'BEGIN { tab = 0 print "char idletaskcode[] = {" }// { if (NF == 2) { printf("0x%s, ",$2) if ((tab++ % 8) == 7) printf("\n") } }END { print "};" }'rm -f idletaskcode.S idletaskcode.o idletaskcode
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?