How2Code
Linux内核的实现,简直赏心悦目
https://tools.ietf.org/html/rfc1982 现在回头看看这个算术的定义再看看实现,更觉得赏心悦目了。
研究了一下s2e,居然是用qemu和preload机制实现了一个kvm,这才是终极套娃。
http://s2e.systems/docs/DesignAndImplementation/KvmInterface.html
http://s2e.systems/docs/DesignAndImplementation/KvmInterface.html
https://blog.lazym.io/2021/04/16/Run-ARM-MIPS-Debian-on-QEMU/
https://blog.ihomura.cn/2020/11/12/%E5%9C%A8qemu-system%E4%B8%8A%E8%B7%91arm-Debian/
时隔小半年终于把英文的翻译好了,写博客真是撂下笔就再也不想动
https://blog.ihomura.cn/2020/11/12/%E5%9C%A8qemu-system%E4%B8%8A%E8%B7%91arm-Debian/
时隔小半年终于把英文的翻译好了,写博客真是撂下笔就再也不想动
Lazymio's Blog
Run ARM/MIPS Debian on QEMU
IntroductionAs is often the case, IoT security engineers would like to emulate and debug a binary or rootfs of an uncommon architecture, like ARM or MIPS. This post would like to introduce a good way
发现一个很有意思的事情。
我们知道对于std::function或者lambda来说只有没有捕获外层变量才能退化成函数指针,但是在Python对C风格函数指针进行FFI调用的时候却可以随意捕获变量(生成闭包),比如对于
对于其中的原因我思考了很久才发现了华点:Python本身自带一个编译器,所以在运行期也可以动态编译闭包,而C++运行期并没有这种可能。动态语言真是太好辣.jpg
我们知道对于std::function或者lambda来说只有没有捕获外层变量才能退化成函数指针,但是在Python对C风格函数指针进行FFI调用的时候却可以随意捕获变量(生成闭包),比如对于
void register_callback(callback_fn callback)
这样的C函数签名,在Python代码里可以传入任意闭包。对于其中的原因我思考了很久才发现了华点:Python本身自带一个编译器,所以在运行期也可以动态编译闭包,而C++运行期并没有这种可能。动态语言真是太好辣.jpg
How2Code
发现一个很有意思的事情。 我们知道对于std::function或者lambda来说只有没有捕获外层变量才能退化成函数指针,但是在Python对C风格函数指针进行FFI调用的时候却可以随意捕获变量(生成闭包),比如对于 void register_callback(callback_fn callback) 这样的C函数签名,在Python代码里可以传入任意闭包。 对于其中的原因我思考了很久才发现了华点:Python本身自带一个编译器,所以在运行期也可以动态编译闭包,而C++运行期并没有这种可能。动态语言真是太好辣.jpg
Lazymio's Blog
Cast a Closure to a Function Pointer -- How libffi closure works
CallbacksThis post also has a Chinese version: 把闭包变成函数指针——libffi 闭包原理解析. As is often the case, a lib written in C may expose an API which accepts a function pointer as a callback function like: 123typ
How2Code
勘误:Python并不是动态编译闭包,而是 libffi 提供了把闭包变成函数指针的能力。我写了文章和demo验证这点。 英文版 中文版 Demo
Update: 这篇文章居然被libffi作者注意到了。。。尴尬的是我图错了 草
被linker坑傻了,重名符号但是在不同的static lib里,链接的时候不报错。
https://stackoverflow.com/questions/59978787/same-object-file-in-different-static-libraries-when-linking
https://stackoverflow.com/questions/59978787/same-object-file-in-different-static-libraries-when-linking
Stack Overflow
Same object file in different static libraries when linking
clang++ ... foo.cpp ... -o dir1/foo.o
clang++ ... foo.cpp ... -o dir2/foo.o
//The only difference beween the above two clang++ command lines
//is the output directory
llvm-ar ... dir1/lib1.a ... d...
clang++ ... foo.cpp ... -o dir2/foo.o
//The only difference beween the above two clang++ command lines
//is the output directory
llvm-ar ... dir1/lib1.a ... d...