This is the mail archive of the binutils@sources.redhat.com 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]

[BFD] bfd_perform_relocation usage


Hello all!

I checked the relevant archives and docs for this, but I cannot find 
anything:

How exactly am I to use bfd_perform_relocation? I am having problems in 
figuring out what the arguments mean and what has to be done before 
calling it.
I am trying to load an object file (.o) dynamically. 
(what DLD used to do for a.out, but for ELF) 
I have done this by hand for Intel, but need to port it to ARM and thought 
I should figure out BFD to make things easier.

At the moment I open a bfd for reading, read the section contents to some 
piece of memory, load the symbol table and load the relocation tables for 
each section, then loop through them calling bfd_perform_relocation:

bfd_perform_relocation (abfd, rels[i], sec_contents, sec, NULL, &error);

abfd is the bfd, rels[i] the relocation entry, sec_contents is a 
pointer to the contents of the section, read in by 
bfd_get_section_contents, I don't think I need an output bfd (so NULL) and 
error is just a char *.

It falls over with a segmentation fault somewhere in bfd_perform_relocation 
on the first call. 

Could someone please confirm, if I understand the way bfd is meant to be 
used, in particular the arguments I give it and the order I do things in?
Alternatively a pointer to some example code using bfd_perform_relocation 
would be helpful.

Thanks in advance.



Stefan Beyer
-- 
beyer at cs dot man dot ac dot uk
http://www.cs.man.ac.uk/~beyers8



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