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]

Adjusting relocation addends with objcopy


What I'm trying to do is this:  I'm attempting to make use of the code
in a Windows-built relocatable PE/COFF object file (.obj) for a build
on Linux, so I'm attempting to use objcopy to convert it over the ELF
format.  I have no idea if this is realistic, but hey.

Problems I've run into so far:

1. Undefined symbols need the leading _ character stripped.  No
problem, objcopy has a commandline option for doing this.

2. Much trickier:  References to external symbols in the converted
.obj file (mainly to library functions) do not resolve correctly. 
I've traced the problem back to the fact that the GNU toolchain emits
code with a 0xfffffffc (-4) in-situ addend where the relocation value
goes, whereas these are absent in the .obj file (The int32 is set to
0x00000000 instead of 0xfffffffc), so function calls to library
functions go to an address that's off by 4 bytes.  Crashes ensue.

First question:  I can hack objcopy to fix this for me in a
quick-and-dirty manner, but I'm wondering -- is this interesting to
anyone else?  ie, would it be worth it for me to do a clean
implementation and submit it as a patch?

While I'm at it, second question:  Anyone have any ideas as to what
problems I'm in for after I take care of this one?

Thanks in advance...   . SNF .



______________________________________________________________________ 
Post your free ad now! http://personals.yahoo.ca


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