|
发表于 2012-8-19 13:52:55
|
显示全部楼层
wjkddc.. 发表于 2012-8-19 11:12 ![](static/image/common/back.gif)
大侠,这个有点超出小弟的界线了,完全不懂呀,牙妈嗲
问题是你的需求我也不太明白呀
我举个简单例子吧 以X86平台为例,写的比较烂,见谅
==================================================dump.c=================================================
/*
dump.c A demo file demonstrates objcopy tool in package "binutils".
* Follow example is used as usage:
* [root@localhost ~]# objcopy -V
* GNU objcopy version 2.21.53.0.1-2.fc16 20110716
* Copyright 2011 Free Software Foundation, Inc.
* This program is free software; you may redistribute it under the terms of
* the GNU General Public License version 3 or (at your option) any later version.
* This program has absolutely no warranty.
* [root@localhost ~]# objcopy -I binary -O elf32-i386 -B i386 dump.c dump.o
* [root@localhost ~]# nm dump.o
* xxxxxxxx D _binary_dump_c_end
* xxxxxxxx A _binary_dump_c_size
* 00000000 D _binary_dump_c_start
* [root@localhost ~]# objdump -x dump.o
*
* dump.o: file format elf32-little
* dump.o
* architecture: i386, flags 0x00000010:
* HAS_SYMS
* start address 0x00000000
*
* Sections:
* Idx Name Size VMA LMA File off Algn
* 0 .data xxxxxxxx 00000000 00000000 xxxxxxxx 2**0
* CONTENTS, ALLOC, LOAD, DATA
* SYMBOL TABLE:
* 00000000 l d .data 00000000 .data
* 00000000 g .data 00000000 _binary_dump_c_start
* xxxxxxxx g .data 00000000 _binary_dump_c_end
* xxxxxxxx g *ABS* 00000000 _binary_dump_c_size
*
* [root@localhost ~]# gcc -g dump.c dump.o
* [root@localhost ~]# ./a.out
* .............................dump.c here......................................
* ... ...
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
extern char _binary_dump_c_start[];
extern char _binary_dump_c_end[];
extern void _binary_dump_c_size; /* symbol size in *ABS* segment, we do not use here. */
int main()
{
write(STDOUT_FILENO,_binary_dump_c_start,_binary_dump_c_end-_binary_dump_c_start);
return 0;
}
=========================================================================================================
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|