public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: peter matula <xmatul01@stud.fit.vutbr.cz>
To: binutils@sourceware.org
Subject: create relocation entry from scratch
Date: Thu, 15 Jul 2010 12:19:00 -0000	[thread overview]
Message-ID: <4C3EFCBF.8050503@stud.fit.vutbr.cz> (raw)

Hello,

I'm using BFD to transform our internal binary format to ELF. I have 
already successfully made transformation of executable files which can 
be described like this:

CreateBfd();    // create BFD file
GetArch();    // convert arch and mach info from our format to BFD
CreateSections();    // create sections in BFD
GetSymtab();    // create and fill symbol table
GetSectionData();    // copy data from out format to BFD
CloeBfd();    // write and close BFD

Now i would like to add relocation conversion. Until now everything went 
well but i stuck on this. When should I add relocations ? During section 
creation in CreateSections(), after GetSymTab() or somewhen else ?
And how should i create relocation entry from scratch ? I found few 
examples like this:

relpp = (arelent **) xmalloc(get_reloc_upper_bound(ibfd, isec));
relcount = bfd_canonicalize_reloc(ibfd, isec, relpp, sympp);
bfd_set_reloc(obfd, osec, relpp, relcount);

But I can not use bfd_canonicalize_reloc() to get info from out format 
and I have to fill each reloc entry manually. Is this the right way or 
should I use something like this:

arelent_chain *reloc = (arelent_chain *)bfd_alloc(abfd, 
sizeof(arelent_chain));
...
rel_section->constructor_chain = reloc;

Problem is, there is not function bfd_alloc() in my bfd.h and I did not 
find it in latest binutils either. What happend to it ?

Thanks for advices.
Peter Matula

             reply	other threads:[~2010-07-15 12:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-15 12:19 peter matula [this message]
2010-07-15 13:29 ` Ian Lance Taylor
2010-07-15 14:16   ` peter matula

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4C3EFCBF.8050503@stud.fit.vutbr.cz \
    --to=xmatul01@stud.fit.vutbr.cz \
    --cc=binutils@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).