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: Deleting sections with libbfd


Dave Korn wrote:
> 
>   You delete a section by not copying it from an input bfd to output bfd.
>  
>...
> 
>   You have to open an input bfd and an output bfd and read from one, modify in
> memory, and write to the other; bfd doesn't support modify in-place.
> 
>   Take a look at objcopy.c; ISTM that you should be able to adapt it to your
> purposes.  (You may even be able to use it as-is with a bit of scripting or
> makefile trickery).
> 
>     cheers,
>       DaveK

Thanks for the info. I just had a look at the objcopy source and I
think it will be easier to use objcopy as an external program using
fork/exec for the moment than implementing my own specific object
copying with section manipulation.

Just a small question about objcopy. If I execute:

objcopy --remove-section=.edoc --add-section .edoc=/tmp/blah binfile

will that always do the remove before it does the add, or should I
make two invocations of objcopy to perform these operations one after
the other?

It seems to work fine on my machine invoking objcopy like that, I just
wanted to be sure that I should be able to do this as I could not find
info in the man page about the order of operations and if this is not
specified somewhere as correct usage it may change in different
versions of objcopy (though I doubt it would).


Thanks for the help.
Brendon.


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