Andes Workshop

It is currently Sun Sep 19, 2021 5:35 pm

All times are UTC + 8 hours [ DST ]




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: 將1個elf檔切成多個bin檔的方法
PostPosted: Tue Jan 22, 2013 11:44 am 
Offline
User avatar

Joined: Fri Mar 04, 2011 9:36 pm
Posts: 500
將1個elf檔切成多個bin檔的方法如下


我們看了一下 objcopy 的manual和code,
只有 -j 和 -R 這兩個參數可以用

[-j sectionname|--only-section=sectionname]
[-R sectionname|--remove-section=sectionname]


例如我有一個a.out, 有 .text, .foo, .bar 三個sections
[ 1] .text PROGBITS 00004000 001000 000008 00 AX 0 0 2
[ 2] .foo PROGBITS 00004008 001008 000008 00 WA 0 0 2
[ 3] .bar PROGBITS 00004010 001010 00000a 00 WA 0 0 2



1. nds32le-elf-objcopy -O binary a.out a.bin
這樣會生出一個 0x8 + 0x8 + 0xa 大的 bin 檔


2. nds32le-elf-objcopy -O binary -j .text a.out a.text.bin
這樣會生出一個 0x8 大的 bin 檔 (以 .text 的lma為base)
裡面只存在 .text section


3. nds32le-elf-objcopy -O binary -R .text a.out a.foobar.bin
這樣會生出一個 0x8 + 0xa 大的 bin 檔 (以 .foo 的lma 為base)
內容只存在 .foo 與 .bar


如果section比較複雜, 那麼可能需要多個 -j 或 -R 才能組合出想要的binary檔
意思是說,例如我要留2個sections,則
nds32le-elf-objcopy -O binary -j .text –j .foo a.out a.textfoo.bin


Top
 Profile Send private message E-mail  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC + 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group