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: How can I get info on the UNDEF section or the imports section of an object file from BFD?


"Liang, James" <jliang@sandia.gov> writes:

> Does anyone know how I can get info on the UNDEF section or the imports
> section of an object file from BFD?
> 
> Consider that I have a snippet:
> extern struct someStruct externData;
> 
> 	void function() {
> 	  printf("%d\n",externData.accessCounter);
> 	}
> 
> This basically compiles to:
>   push [externData+8]
>   push "%d\n"
>   call printf
> 
> Where the push instruction is just a   "ff 35 6c 00 00 00"
> 
> By looking at it through IDA Pro, I can easily see that the 6c byte is there
> because it put externData in a section called UNDEF, that holds all of the
> imported symbols, at offset 64.  Thus it simply added the offset of +8 to
> the 64 where the externData resides and got 6c.  
> 
> I would like to be able to read info about the UNDEF section using BFD so
> that I can see that externData is at offset 64, see the ff 35 6c, and use it
> to calculate the "externData +8".  The problem is that I can't seem to
> figure out how to get info about the imports section using the BFD
> libraries.  Without this info, I can't figure out how to fixup the extern.
> I tried getting this info from objdump, but can't quite seem to get it to
> give that either. 
> 
> Where is this info stored?  How can I access it?

I don't know what IDA Pro is, and I'm confused by your terminology.
What does objdump show about your file?

If the symbol externData is in a section named UNDEF, that suggests
that it is actually an undefined symbol.  Is there an actual section
named UNDEF?  That is, do you see such a section using objdump -h?
How does objdump show the symbol using objdump -t?

I don't know what you mean by the imports section.  I don't know of
any such thing in ordinary COFF.

Since your question seems to be related to relocations, what do you
see using objdump -r?

Ian


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