misc 杂记
ps: 可以忽视之 , 仅为自己杂乱记录而已
cat /etc/*-release 可以 show 多个文件的内容, 用于多个文件之间进行字符串搜索或者操纵字符串等
root@iZ2zee0spkwcgvz4do5kt2Z:/etc# cat /etc/*-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=14.04
DISTRIB_CODENAME=trusty
DISTRIB_DESCRIPTION="Ubuntu 14.04.5 LTS"
NAME="Ubuntu"
VERSION="14.04.5 LTS, Trusty Tahr"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 14.04.5 LTS"
VERSION_ID="14.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
root@iZ2zee0spkwcgvz4do5kt2Z:/etc# ls -la /etc/*-release
-rw-r--r-- 1 root root 105 Aug 1 2016 /etc/lsb-release
-rw-r--r-- 1 root root 249 Aug 1 2016 /etc/os-release
root@iZ2zee0spkwcgvz4do5kt2Z:/etc# cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=14.04
DISTRIB_CODENAME=trusty
DISTRIB_DESCRIPTION="Ubuntu 14.04.5 LTS"
root@iZ2zee0spkwcgvz4do5kt2Z:/etc# cat /etc/os-release
NAME="Ubuntu"
VERSION="14.04.5 LTS, Trusty Tahr"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 14.04.5 LTS"
VERSION_ID="14.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
[转]
1、“=”
make会将整个makefile展开后,再决定变量的值。也就是说,变量的值将会是整个makefile中最后被指定的值。看例子:
x = foo
y = $(x) bar
x = xyz
在上例中,y的值将会是 xyz bar ,而不是 foo bar 。
2、“:=”
“:=”表示变量的值决定于它在makefile中的位置,而不是整个makefile展开后的最终值。
x := foo
y := $(x) bar
x := xyz
在上例中,y的值将会是 foo bar ,而不是 xyz bar 了。
2、export行是shell命令;对每一行shell命令,make将启动一个新的进程执行这行shell命令。由于新启动的子 进程的环境变量完全跟父进程不相干,因此export并不能改变父进程的环境变量,进而也不能改变父进程以后启动的子进程,或曰“弟弟进程”的环境变量
nasm 写汇编的时候比较清楚怎么写 怎么编译 32 或者 64 位的汇编代码
但是在 as ld 有时候就容易忘记 这里给个案例 帮助记忆一下怎么 **as ld ** 怎么编译 链接生成 32 位的汇编的代码
zhangji16@zhangji16vm:~/c_study/diy_os/free_study/prj_call_printf$ cat cpuid_use_printf.s
# print the CPUID Vendor ID by C library calls
.section .data
output:
# .asciz 与ascii 不同在于,.asciz会在末尾添加空字符(0)
.asciz "The processor Vendor ID is '%s'\n"
.section .bss
.lcomm buffer, 12
.section .text
.global _start
_start:
nop
movl $0, %eax
cpuid
movl $buffer,%edi
movl %ebx, (%edi)
movl %edx, 4(%edi)
movl %ecx, 8(%edi)
pushl $buffer
pushl $output
call printf
addl $8, %esp
pushl $0
call exit
zhangji16@zhangji16vm:~/c_study/diy_os/free_study/prj_call_printf$ cat Makefile
all: cpuid_use_printf
cpuid_use_printf: cpuid_use_printf.o
ld -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 -o $@ -lc $<
cpuid_use_printf.o: cpuid_use_printf.s
as --32 -o $@ $<
clean:
rm ./cpuid_use_printf ./cpuid_use_printf.o ./cpuid_use_printf.s~
python 终端中处理中文
Python>os.getcwd().decode("gbk")
F:\kalizhangji\比赛\hitcon2018\hitcon-2018\abyss\abyss\release
Python>os.getcwd()
F:\kalizhangji\����\hitcon2018\hitcon-2018\abyss\abyss\release
权限
在执行代码前为了测试方便,我们可以先**去掉 ** testfile 文件的写权限,命令如下:
chmod -w testfile
看返回值
root@iZ2zee0spkwcgvz4do5kt2Z:~/docker_use/os_study/int80_prj1# ./asmsyscall_int80
root@iZ2zee0spkwcgvz4do5kt2Z:~/docker_use/os_study/int80_prj1# echo $?
99
调用约定
1. 用户程序使用%rdi, %rsi, %rdx, %rcx, %r8 和 %r9寄存器传递参数序列,内核接口使用%rdi, %rsi, %rdx, %r10, %r8 和 %r9寄存器。
2. syscall指令完成系统调用,内核会破坏%rcx 和 %r11寄存器值。
3. 系统调用号用%rax寄存器传递。
4. 系统调用最多6个参数,不能用直接用栈传递。
5. syscall的返回结果保存在%rax寄存器中。-4095到-1的值表示错误,他是错误号。
6. 只能传递整数或者内存值到内核。
执行完elf1 才能执行 elf2 的demo
zhangji16@zhangji16vm:~/c_study/hw_idarling/support_prj/database$ chmod +x demo_step1.py
zhangji16@zhangji16vm:~/c_study/hw_idarling/support_prj/database$ python demo_init.py | ./demo_step1.py
执行完 demo_init.py
后,再执行 demo_step1.py