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]

RE: extracting relocation info from COFF from"section contents" base d on partial_inplace


The output of objdump -s and bfd_get_section_contents is just a array of
bytes.  What I'd like to know is where the Addend and other offset related
info is stored.

For example, if my code says:
	extern struct someStruct externData;

	void function() {
	  printf("%d\n",externData.accessCounter);
	}


There should normally be some info stored in the object, I think the Addend
field, that tells the offset to accessCounter.  That way, when the linker
and/or loader inserts the real pointer to externData, it will know to add
that offset to the instruction when pusing externData.accessCounter for the
printf call.  

My problem is that I don't know how to access this information(at least for
COFF)  Where is this offset info(or "Howto" info) stored?  How can I extract
this info from the COFF object file?

James

> -----Original Message-----
> From: Ian Lance Taylor [mailto:ian@wasabisystems.com]
> Sent: Thursday, April 08, 2004 11:24 AM
> To: Liang, James
> Cc: 'binutils@sources.redhat.com'
> Subject: Re: extracting relocation info from COFF from "section
> contents" base d on partial_inplace
> 
> 
> "Liang, James" <jliang@sandia.gov> writes:
> 
> > I'm writing a port of objcopy that takes COFF as input.  
> The problem is that
> > I can't seem to get all of the relocation
> > information I need.  Specifically, I'm missing some info 
> from some imported
> > symbols.  The Howto section does not give me
> > enough information to relocate, but does give me 'true" 
> flags for pcrel and
> > partial_inplace.
> > 
> > From the info section of BFD, I get that these flags mean 
> they're stored in
> > the "section contents", but I have no idea how to extract them.
> > How do I get these values?
> 
> I'm not sure what the real problem is here.
> 
> Relocations generally apply to some part of the object file.  That's
> what they do--they relocate information in the object file to some
> specific address.  A relocation applies some computation, typically
> including the value of some symbol.  When a relocation is marked
> partial_inplace, it means that part of the computation includes the
> existing data in the object file.  Those are the "section contents"
> which you refer to.  It's the data in the section, the data which can
> be dumped using objdump -s.
> 
> You can read the section contents by calling bfd_get_section_contents.
> 
> Hope that helps.  If it doesn't, try to clarify what your real problem
> is.
> 
> Ian
> 


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