SunBo

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

 

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

posted on 2009-08-27 13:18  SunBo  阅读(208)  评论(0编辑  收藏  举报