This is the mail archive of the
mailing list for the binutils project.
Deleting sections with libbfd
- From: Brendon Costa <brendon at christian dot net>
- To: binutils at sourceware dot org
- Cc: Brendon Costa <bcosta at avdat dot com dot au>
- Date: Mon, 09 Oct 2006 08:35:44 +1000
- Subject: Deleting sections with libbfd
I have been working on an extension for GCC that allows me to perform
static analysis of C++ exceptions. This extension generates data while
objects are being compiled and embeds that data into the .o files in a
section named ".edoc".
In post processing the resulting exes I wish to ensure that the number
of .edoc sections contained in an exe is exactly 1. This seems to always
be the case on my machine however I read in the libbfd manual that it is
possible for an exe to contain more than 1 section with the same name.
My plan was to search the output exe for any sections named ".edoc" and
delete them, and then create a new single section ".edoc" and set its
contents as i require.
I could not find any mention of "Deleting Sections" in the libbfd manual
or in the archives. Is this at all possible?
If not would it suffice for me to set the size of all ".edoc" sections
in the binary except the one i wish to use to 0?
Also is it possible to open a bfd for reading and writing? I need to
write, but if i use bfd_openw then it does not read in the existing
contents of the binary file. I really need to modify the bfd so read it
in, modify the appropriate sections and save the changed file.