URN Logo
UNIX Resources » Linux » China Linux Forum » CPU 与 编译器 » 11 » 用什么命令可以把一个elf文件中的一个段copy到一个新的文件中?
announcement 声明: 本页内容为中国Linux论坛的内容镜像,文章的版权以及其他所有的相关权利属于中国Linux论坛和相应文章的作者,如果转载,请注明文章来源及相关版权信息。
Resources
China Linux Forum(finished)
Linux Forum(finished)
FreeBSD China(finished)
linuxforum.net
  业界新闻与评论
  自由软件杂谈
  IT 人生
  Linux软件快递
  翻译作坊
  Linux图书与评论
  GNU Emacs/XEmacs
  Linux 中文环境和中文化
  Linux桌面与办公软件
  Linux 多媒体与娱乐版
  自由之窗Mozilla
  笔记本电脑上的Linux
  Gentoo
  Debian 一族
  网络管理技术
  Linux 安装与入门
  WEB服务器和FTP服务器
  域名服务器和邮件服务器
  Linux防火墙和代理服务器应用
  文件及打印服务器
  技术培训与认证
  Linux内核技术
  Linux 嵌入技术
  Linux设备驱动程序
  Linux 集群技术
  LINUX平台数据库
  系统和网络安全
  CPU 与 编译器
  系统计算研究所专栏
  Linux下的GUI软件开发
  C/C++编程版
  PHP 技 术
  Java&jsp技术
  Shell编程技术
  Perl 编 程
  Python 编 程
  XML/Web Service 技术
  永远的Unix
  FreeBSD世界
   
用什么命令可以把一个elf文件中的一个段copy到一个新的文件中?
 
 
 
 
 
Did you try objdump ? - gangchen_sh [2005-01-23 08:47 | 226 byte(s)]
 
Subject: 用什么命令可以把一个elf文件中的一个段copy到一个新的文件中?
Author: qiyoa    Posted: 2005-01-22 22:09    Length: 1,845 byte(s)
[Original] [Print] [Top]
我想把elf文件的若干段copy出来,我这样的
1
[qiyao@localhost helloworld]$ readelf -S helloworld
There are 34 section headers, starting at offset 0x2e10:

Section Headers:
[Nr] Name Type Addr Off Size ES Flg Lk Inf Al
[ 0] NULL 00000000 000000 000000 00 0 0 0
[23] .comment PROGBITS 00000000 000530 000132 00 0 0 1
[24] .debug_aranges PROGBITS 00000000 000668 000098 00 0 0 8
[25] .debug_pubnames PROGBITS 00000000 000700 00004a 00 0 0 1
[26] .debug_info PROGBITS 00000000 00074a 00165e 00 0 0 1
[27] .debug_abbrev PROGBITS 00000000 001da8 0002a2 00 0 0 1
[28] .debug_line PROGBITS 00000000 00204a 000369 00 0 0 1
[29] .debug_frame PROGBITS 00000000 0023b4 000060 00 0 0 4
[30] .debug_str PROGBITS 00000000 002414 0008cf 01 MS 0 0 1
[31] .shstrtab STRTAB 00000000 002ce3 00012b 00 0 0 1
[32] .symtab SYMTAB 00000000 003360 0006d0 10 33 54 4
[33] .strtab STRTAB 00000000 003a30 0003fd 00 0 0 1
2因为debug_aranges段是24
[qiyao@localhost helloworld]$ readelf -x 24 helloworld > helloworld.debug_arranges.bin
但是helloworld.debug_arranges.bin的大小不是0x98,
[qiyao@localhost helloworld]$ ll helloworld.debug_arranges.bin
-rw-rw-r-- 1 qiyao qiyao 691 Jan 22 22:08 helloworld.debug_arranges.bin

这是为什么啊?应该用什么命令可以把elf中一个段dump出来,谢谢高手了!
[Original] [Print] [Top]
Subject: Did you try objdump ?
Author: gangchen_sh    Posted: 2005-01-23 08:47    Length: 226 byte(s)
[Original] [Print] [Top]
May be you would like to try this:

objdump -j <section name> -d <object/executeble file>

See objdump --help for details.

Good luck.
[Original] [Print] [Top]
Subject: Re: 用什么命令可以把一个elf文件中的一个段copy到一个新的文件中?
Author: teawater    Posted: 2005-01-23 09:48    Length: 7 byte(s)
[Original] [Print] [Top]
objcopy
----
读了这么多年的书 还是觉得幼儿园好混
[Original] [Print] [Top]
Subject: Re: 用什么命令可以把一个elf文件中的一个段copy到一个新的文件中?
Author: qiyoa    Posted: 2005-01-23 12:51    Length: 439 byte(s)
[Original] [Print] [Top]
谢谢二位的回答,不过我先说一句objdump中根本没有-j的option。
我现在是这样做的
在j参数后边我用的是.debug_abbrev,我不知道段的名称前边是否有那个点。
[qiyao@localhost helloworld]$ objcopy -j .debug_abbrev helloworld > helloworld.debug_abbrev.bin
objcopy: Warning: Output file cannot represent architecture UNKNOWN!


如果有人做过这个操作,进来指点一下,谢谢了。
[Original] [Print] [Top]
Subject: Re: 用什么命令可以把一个elf文件中的一个段copy到一个新的文件中?
Author: gangchen_sh    Posted: 2005-01-24 06:22    Length: 4,116 byte(s)
[Original] [Print] [Top]
In my system (Window cygwin), objdump --help gives the following information.
Among the options, one can find
" -j, --section=NAME Only display information for section NAME"

Note that -j has one -, --section has two --.

Here is the listing:

Usage: objdump <option(s)> <file(s)>
Display information from object <file(s)>.
At least one of the following switches must be given:
-a, --archive-headers Display archive header information
-f, --file-headers Display the contents of the overall file header
-p, --private-headers Display object format specific file header contents
-h, --[section-]headers Display the contents of the section headers
-x, --all-headers Display the contents of all headers
-d, --disassemble Display assembler contents of executable sections
-D, --disassemble-all Display assembler contents of all sections
-S, --source Intermix source code with disassembly
-s, --full-contents Display the full contents of all sections requested
-g, --debugging Display debug information in object file
-e, --debugging-tags Display debug information using ctags style
-G, --stabs Display (in raw form) any STABS info in the file
-t, --syms Display the contents of the symbol table(s)
-T, --dynamic-syms Display the contents of the dynamic symbol table
-r, --reloc Display the relocation entries in the file
-R, --dynamic-reloc Display the dynamic relocation entries in the file
-v, --version Display this program's version number
-i, --info List object formats and architectures supported
-H, --help Display this information

The following switches are optional:
-b, --target=BFDNAME Specify the target object format as BFDNAME
-m, --architecture=MACHINE Specify the target architecture as MACHINE
-j, --section=NAME Only display information for section NAME
-M, --disassembler-options=OPT Pass text OPT on to the disassembler
-EB --endian=big Assume big endian format when disassembling
-EL --endian=little Assume little endian format when disassembling
--file-start-context Include context from start of file (with -S)
-I, --include=DIR Add DIR to search list for source files
-l, --line-numbers Include line numbers and filenames in output
-C, --demangle[=STYLE] Decode mangled/processed symbol names
The STYLE, if specified, can be `auto', `gnu',
`lucid', `arm', `hp', `edg', `gnu-v3', `java'
or `gnat'
-w, --wide Format output for more than 80 columns
-z, --disassemble-zeroes Do not skip blocks of zeroes when disassembling
--start-address=ADDR Only process data whose address is >= ADDR
--stop-address=ADDR Only process data whose address is <= ADDR
--prefix-addresses Print complete address alongside disassembly
--[no-]show-raw-insn Display hex alongside symbolic disassembly
--adjust-vma=OFFSET Add OFFSET to all displayed section addresses

objdump: supported targets: pe-i386 pei-i386 elf32-i386 elf32-little elf32-big srec symbolsrec tekhex binary ihex
objdump: supported architectures: i386 i386:x86-64 i8086 i386:x86-64:intel i386:intel
Report bugs to <URL:http://www.sourceware.org/bugzilla/>.
[Original] [Print] [Top]
Subject: Re: 用什么命令可以把一个elf文件中的一个段copy到一个新的文件中?
Author: qiyoa    Posted: 2005-01-24 15:36    Length: 147 byte(s)
[Original] [Print] [Top]
i am so sorry! the output of 'objdump' and 'objdump --help' are different!
so ,i made the mistake as before!
thank you very much.
[Original] [Print] [Top]
« Previous thread
想学习yacc和lex,哪里有比较简单的例子可以看看啊?
CPU 与 编译器
11
Next thread »
Cell Architecture Explained
     

Copyright © 2007 UNIX Resources Network, All Rights Reserved.      About URN | Privacy & Legal | Help | Contact us
备案序号: 京ICP备05006143    webmaster: webmaster@unixresources.net
This page created on 2008-07-17 03:47:33, cost 0.045860767364502 ms.