Dynamically load executable
在一个可执行程序里面可以以load动态库的形式执行另外一个程序:
$ cat 1.c #include <stdio.h>int main(void)
{printf("hello,world\n");return 0;
}
gcc 1.c -g -o 1 -fPIC -pie
fPIC 和 pie选项是为了让 executable成为一个 shared object.
$ cat 0.c
#include <dlfcn.h>
#include <stdio.h>typedef int (*myMainType)(void);
int main(void)
{void *handle = dlopen("./1", RTLD_LAZY );if(handle == 0){printf("%s\n", dlerror());}myMainType pMain = dlsym(handle, "main");pMain();return 0;
}
gcc 0.c -g -o 0 -ldl
$ ./0
hello,world
Dynamically load executable相关推荐
- cannot dynamically load executable的尴尬经历
cannot dynamically load executable的尴尬经历 运行新编译的程序时报错: ./sdktest: error while loading shared libraries ...
- Vue报错 Are you meant to dynamically load options? You need to use “loadOptions“ pro
vue date中修改对应loadOptions参数不为空即可 data() {return {//修改前deptOptions: undefined,//修改后deptOptions: [],} }
- Howto Dynamically Insert Javascript And CSS
2019独角兽企业重金招聘Python工程师标准>>> This is a short and sweet little tutorial to show you how to dy ...
- PX4 CMakeLists.txt 文件剖析
PX4 CMakeLists.txt 文件剖析 前面对于 PX4 的 Makefile 已经做了比较详细的分析, 见这里, 这里进一步对 PX4 的 CMakeLists.txt 文件结构进行进一步的 ...
- [memo] dlopen 与 --export-dynamic
先看看状况(小心头疼) client.c 编译得到 client:在 client 的 main 中用 dlopen( "./liba.so", RTLD_LAZY|RTLD_GL ...
- A comparison of C# vs. java
转发上:http://www.25hoursaday.com/CsharpVsJava.html#friends A COMPARISON OF MICROSOFT'S C# PROGRAMMING ...
- Driver Development Part 1: Introduction to Drivers
//来自codeproject的文章,共有六篇,感觉写的挺好的.因为不想经常翻墙,所以先收藏. //对于初学者是不错的文章,虽然是英文但是咬咬牙还是可以看懂的,建议不要百度.google翻译了 //M ...
- Replacing JNI Crashes by Exceptions on Android【转】
原文地址:http://blog.httrack.com/blog/2013/08/23/catching-posix-signals-on-android/ Replacing JNI Crashe ...
- 【翻译】ILR-我的Gadgets去哪里了——ILR: Where’d My Gadgets Go?
ILR-我的Gadgets去哪里了 [文章为google-translate的直译结果,最近暂时没有时间修改翻译内容.google-translate的翻译结果中有很多明显的错误,遇到类似的问题,请读 ...
最新文章
- java线程钥匙_Java多线程并发编程/锁的理解
- uses 子句的写法
- zabbix工作流程(自定义添加监控项目)
- 利用Servlet实现用户永久登录
- 浅谈MVC设计模式和SSH框架的关系
- iOS使用NSURLConnection发送同步和异步HTTP Request
- 剑指offer之把字符串里面空格替换成百分之20[时间复杂度是O(n)]
- 高性能 php api 开发,ThinkPHP 3.2 性能优化,实现高性能API开发
- Flipping elements with WPF
- HTML复选框可以设置为只读吗?
- LeetCode 236. 二叉树的最近公共祖先(递归)
- 如果处理vim产生的swp文件 以及diff功能的使用
- kindeditor上传图片php,kindeditor上传图片与上传文件js
- 《Python零基础快乐学习之旅》学习笔记9——字典(dict)
- Win11怎么设置开机启动项?
- Matlab计算相关系数
- QQ的群消息关键字屏蔽
- 如何利用爬虫工具实现竞品价格监控
- 【python :编译错误】 IndentationError:unexpected indent(缩进问题)
- python魔术师算法
热门文章
- 哪些开源协议的项目可以在商业项目中使用
- DWORD 代表 unsigned long
- 这样优化Spring Boot,启动速度快到飞起!
- ES 插入文档报错:Rejecting mapping update to [testindex] as the final mapping would have more than 1 type
- 覆盖率(covergroup触发、覆盖率数据采样(条件、翻转、wailcard、忽略))-sv
- 提问:如何评估产品内容的价值?
- 电磁波和声波对比实验
- cs231n训练营学习笔记(1)
- php解摩斯电码,PHP摩尔斯电码转换器
- 2022年ccpc桂林站