This is the mail archive of the
binutils@sourceware.cygnus.com
mailing list for the binutils project.
Re: objcopy elf->coff relocs
- To: robertl@sco.com
- Subject: Re: objcopy elf->coff relocs
- From: Ian Lance Taylor <ian@zembu.com>
- Date: 6 Sep 1999 19:58:31 -0400
- CC: binutils@sourceware.cygnus.com
- References: <19990906163210.A11964@rjlhome.sco.com>
Date: Mon, 6 Sep 1999 16:32:10 -0500
From: Robert Lipe <robertl@sco.com>
I have a reason to convert (simple) ELF i386 relocatables to COFF
format for an open-sourced project. I had used objcopy for similar
tasks in the past so I though I'd give it a shot. Unfortunately, the
resulting object has bad reloc types which sends the linker into a
tizzy. Hopefully some can point out any pilot error along the way or
at least point me to a good starting place in BFD's guts if the problem
isn't self-evident to those of you comfortable inside it.
objcopy doesn't really convert relocations. In the general case it is
impossible. In specific cases it may be possible, but objcopy does
not do the necessary transformations. Moreover, the current BFD
relocation structures don't provide enough information to correctly
detect whether a specific transformation is possible or impossible.
I then went to a Linux/IA32 system and spun the binutils tree as of this
morning configured with --enable-targets=i386-coff.
First, I converted:
$ ./objcopy --output-format=coff-i386 telf.o tcvt.o
Then I examined:
$ ./objdump --reloc tcvt.o
tcvt.o: file format coff-i386
RELOCATION RECORDS FOR [.text]:
OFFSET TYPE VALUE
00000004 1 wretch
00000009 2 bletch
The way I read <reloc.h> reloc types 1 and 2 are R_DIR16 and R_REL16
and these are certainly not meant to be 16-bit objects.
objcopy didn't change the relocation type numbers. Types 1 and 2 are
R_386_32 and R_386_PC32 in ELF.
Ian