This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Newbie questions


Hi Bernhard,

I figured out if I call bfd_check_format() it will force the sections
to be loaded into memory, but now the file is marked as
output_has_begun so I can't modify it.

Is there a standard way to force the sections to be loaded so you can
iterate over them (and modify)?

Yes - use bfd_open and bfd_check_format as you have been doing, but open the input file for reading only and then create a new output file. Ie do not try to modify the input file, but instead copy it to a different output file, making changes on the way. Have a look at the code in binutils/objcopy.c for examples of this.


Calling bfd_set_section_contents fails because the sizes don't match.

This should be resolved by the change suggested above.

3. Would a tool that converts bfd (internal structures) to json and
back be useful?

Not sure. (Not being a json user myself). But it would certainly be interesting, and educational to create one.

Cheers
  Nick



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]