Chinaunix首页 | 论坛 | 博客
  • 博客访问: 15490585
  • 博文数量: 112
  • 博客积分: 11195
  • 博客等级: 上将
  • 技术积分: 1989
  • 用 户 组: 普通用户
  • 注册时间: 2005-06-20 11:04
文章分类

全部博文(112)

文章存档

2013年(2)

2012年(27)

2011年(6)

2010年(11)

2009年(6)

2007年(7)

2006年(23)

2005年(30)

分类: C/C++

2009-08-20 16:01:14

 

很有趣,在一些场合也很有用的东西,昨天从老张那里淘来了。

test.c

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

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

 

Makefile

 

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

 

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

阅读(179210) | 评论(14) | 转发(30) |
给主人留下些什么吧!~~

ahocat2011-07-11 11:47:38

在链接环节做手脚,有“作弊”嫌疑。

piaoliuzaiwai2011-06-21 16:13:09

菜鸟的路过,只知道博大精深

haomarlin2011-05-10 21:30:21

真的很不错~这个自动变量也很神奇~
_binary_test_c_start

kinfinger2011-05-06 18:57:13

bzhao: As per man page of objcopy, you can include your picture file and show it in your program. that make a sense......
值得自己玩味一下,呵呵

SpringfieldKing2011-03-14 11:24:28

是做木马么,能不能再详细点。。