Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3427284
  • 博文数量: 864
  • 博客积分: 14125
  • 博客等级: 上将
  • 技术积分: 10634
  • 用 户 组: 普通用户
  • 注册时间: 2007-07-27 16:53
个人简介

https://github.com/zytc2009/BigTeam_learning

文章分类

全部博文(864)

文章存档

2023年(1)

2021年(1)

2019年(3)

2018年(1)

2017年(10)

2015年(3)

2014年(8)

2013年(3)

2012年(69)

2011年(103)

2010年(357)

2009年(283)

2008年(22)

分类: LINUX

2010-11-15 13:16:25

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
#include

extern char* _binary_test_c_start;

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

有点小意思!!!都还没用过objcopy呢^_^
阅读(668) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~