打印自己的c代码

来源:互联网 发布:购买备案域名可以用吗? 编辑:程序博客网 时间:2024/05/16 01:20

很有趣,在一些场合也很有用的东西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很方便的可以把文本文件做成可以连接器可以连接的对象,进而链进可执行程序里面。