您的位置:首页 > 运维架构 > Linux

一个有意思的东东 linux c打印自己的程序

2009-08-27 13:18 441 查看
test.c

# include < stdio. h>
# include < stdlib. h>

extern char * _binary_test_c_start;
int main( )
{
printf ( "%s" , ( char * ) & _binary_test_c_start) ;


printf("hahah/n");
}


Makefile

SRC = test . c
TAR = test
ALL: test . c
objcopy - I binary - O elf32- i386 - B i386 test . c test . bin
gcc - o test test . c test . bin


objcopy很方便的可以把文本文件做成可以连接器可以连接的对象,进而链进可执行程序里面。

[root@kenthy c_par]# ./test
#include <stdio.h>
#include <stdlib.h>

extern char* _binary_test_c_start;

int main()
{
printf("%s", (char *)&_binary_test_c_start);
printf("hahah/n");
return 0;
}
hahah

有点小意思!!!都还没用过objcopy呢^_^

原文:http://blog.chinaunix.net/u/1574/showart_2032979.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐