|
|
|
|
| 用什么命令可以把一个elf文件中的一个段copy到一个新的文件中? |
 用什么命令可以把一个elf文件中的一个段copy到一个新的文件中? - qiyoa [ 2005-01-22 22:09 | 1,845 byte(s)]
 Re: 用什么命令可以把一个elf文件中的一个段copy到一个新的文件中? - teawater [ 2005-01-23 09:48 | 7 byte(s)]
 Re: 用什么命令可以把一个elf文件中的一个段copy到一个新的文件中? - qiyoa [ 2005-01-23 12:51 | 439 byte(s)]
 Re: 用什么命令可以把一个elf文件中的一个段copy到一个新的文件中? - gangchen_sh [ 2005-01-24 06:22 | 4,116 byte(s)]
 Re: 用什么命令可以把一个elf文件中的一个段copy到一个新的文件中? - qiyoa [ 2005-01-24 15:36 | 147 byte(s)]
 Did you try objdump ? - gangchen_sh [ 2005-01-23 08:47 | 226 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]
|
|
[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]
|
|
[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]
|
|
[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]
|
|
[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]
|
|
|