This is the mail archive of the
mailing list for the binutils project.
Re: Deleting sections with libbfd
- From: Brendon Costa <bcosta at avdat dot com dot au>
- To: Dave Korn <dave dot korn at artimi dot com>
- Cc: 'Brendon Costa' <brendon at christian dot net>, binutils at sourceware dot org
- Date: Mon, 09 Oct 2006 10:58:26 +1000
- Subject: Re: Deleting sections with libbfd
- References: <032701c6eb2d$e2673c70$a501a8c0@CAM.ARTIMI.COM>
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).
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
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.