embedded - How can the --add-section switch of OBJCOPY be used? -


there 2 questions revolve around use of --add-section. simple 1 in title. based on reading, haven't been able figure out how 1 execute --add-section.

to use add-section, have pass section name. if use existing section name program responds "can't add section '.data': file in wrong format." perhaps need pass parameter. if use new section name, prefer do, i'm warned "allocated section '.blob' not in segment."

now, have gotten feature work need aside "not in segment" warning. i'd figure out if there legitimate way put blob executable. link in, isn't easy because data i'm adding generated contents of executable itself.

the second question care about. there way following given blob cannot computed until after link complete.

  1. link elf file
  2. generate blob elf file , other data
  3. add blob elf file loaded @ run-time correct location in memory

    objcopy --add-section .blob=blob.o \ --set-section-flags .blob=alloc,contents,load,readonly \ --change-section-address .blob=address \ program.elf program.blobbed.elf

i'd happy add section and/or segment elf file part of link , insert blob there. i'm not sure how that.

it has occurred me accomplish feat second link, objcopy cleaner.

  1. link elf file
  2. generate blob elf file , other data
  3. re-link elf file including new blob.o

update: last strategy may workable long relink doesn't change in portion of program produced first link. doesn't on first attempts, may possible work around it. hence, desire use --add-section add in blob instead of going through second link.

you may add section, fill with, say, nuls, , compute blob. patch blob section. later, when check integrity of elf, if section full of nuls , compute blob again. finally, compare both computed blob , blob stored in section.


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -