#SystemProgramming
小trick 1: makefile编译的时候LDFLAG最好放在-o之后。比如要写成
g++ -I/usr/local/include $^ -o $@ -L/usr/local/lib -lunwind
而不要写成:
g++ -I/usr/local/include -L/usr/local/lib -lunwind $^ -o $@
小trick 2: LD_PRELOAD={full_path of the target shared object file}
在说一个大家都知道但我还不知道的事情,在x86架构里,e开头的寄存器(例如$eip)是intel 32位处理器的寄存器,r开头的寄存器(例如$rip)是intel 64位处理器的寄存器。#SystemProgramming
#SystemProgramming linux 有一个command叫watch,watch -b ./executable的话,该程序以非exit(0)的状态退出,你的terminal就会发出beep的声音。适合我这种一边码字一边跑实验的人orz
继续#SystemProgramming , patchelf --set-interpreter /lib64/ld-linux-x86-64.so.2 <binary> ,可以用来修复一个程序的interpreter。
the interpreter is the program that “launches” the executable file. For a regular binary it’s the loader, i.e., /lib64/ld-linux-x86-64.so.2. For a script it would be the script interpreter (bash, python, etc). #systemProgramming
Kateです。アメリカのペン大でコンピューターシステムを研究している大学院生です。日本語を勉強しているから少し話せます。ビデオゲームが大好きです。
FC:SW-8149-0004-0143
PSN:kate0115