This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: "Create a symbol table"
> I don't think I had enough coffee this morning. The comment about
> the first entry of a symbol table has nothing to do with the
> problem. :-( I think your problem is calling bfd_set_section_contents
> too early. That function should only be called after you have finished
> making changes to the bfd, as it fixes section offsets in the file, and
> writes out the symbol table.
It's complicated by the use of bfd_make_writable(), which switches the
bfd from file-based to memory-based. The only thing you really should
do with such a bfd is later call bfd_make_readable and hand it back to
the program as if it were reading a file off disk.
PE uses this technique to create archives corresponding to DLLs you
attempt to "link" against.
/*
FUNCTION
bfd_make_writable
SYNOPSIS
boolean bfd_make_writable(bfd *abfd);
DESCRIPTION
Takes a BFD as created by <<bfd_create>> and converts it
into one like as returned by <<bfd_openw>>. It does this
by converting the BFD to BFD_IN_MEMORY. It's assumed that
you will call <<bfd_make_readable>> on this bfd later.
RETURNS
<<true>> is returned if all is ok, otherwise <<false>>.
*/
/*
FUNCTION
bfd_make_readable
SYNOPSIS
boolean bfd_make_readable(bfd *abfd);
DESCRIPTION
Takes a BFD as created by <<bfd_create>> and
<<bfd_make_writable>> and converts it into one like as
returned by <<bfd_openr>>. It does this by writing the
contents out to the memory buffer, then reversing the
direction.
RETURNS
<<true>> is returned if all is ok, otherwise <<false>>. */