This is the mail archive of the
binutils@sourceware.cygnus.com
mailing list for the binutils project.
objcopy elf->coff relocs
- To: binutils@sourceware.cygnus.com
- Subject: objcopy elf->coff relocs
- From: Robert Lipe <robertl@sco.com>
- Date: Mon, 6 Sep 1999 16:32:10 -0500
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.
I started with this C source and generated ELF and COFF versions of it:
extern bletch();
extern int wretch;
main()
{
bletch(wretch);
}
objdump --reloc tells me this:
tcoff.o: file format coff-i386
RELOCATION RECORDS FOR [.text]:
OFFSET TYPE VALUE
00000004 dir32 wretch
00000009 DISP32 bletch
telf.o: file format elf32-i386
RELOCATION RECORDS FOR [.text]:
OFFSET TYPE VALUE
00000004 R_386_32 wretch
00000009 R_386_PC32 bletch
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.
Any tips?
Thanx,
RJL