This is the mail archive of the 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]

Re: objcopy of coff-i386 to elf32-i386?

On Wed, Sep 13, 2000 at 10:57:32AM -0700, H . J . Lu wrote:
> On Wed, Sep 13, 2000 at 02:56:46PM +1100, Lachlan O'Dea wrote:
> > 
> > objcopy --remove-leading-char \
> > 	--input-target=coff-i386 --output-target=elf32-i386 \
> > 	$(COFFDIR)/$*.obj $*.o
> > 
> That never worked. If it did, it did by accident. Please read the
> updated documentation from sourceware or my Linux binutils. Basically,
> you can only use objcopy on fully linked files. You can mix .o files
> in the final link.

Sorry, my mistake. It almost works :-)

So are you suggesting I do something like this (on an elf system):

gcc -g -o test main.o c_code.o -Wl,-b,coff-i386 masm_code.obj

where masm_code.obj is coff produced by MASM, main.o and c_code.o are
elf32 compiled by gcc.

This gives me an executable, but again the calls from the coff files
have the wrong offsets. When I run objdump -d on the executable produced
by the above command, I get:

08048448 <asm_function>:
 8048448:       51                      push   %ecx
 8048449:       b9 2a 00 00 00          mov    $0x2a,%ecx
 804844e:       51                      push   %ecx
 804844f:       e8 d8 ff ff ff          call   804842c <print_int+0xc>
 8048454:       59                      pop    %ecx
 8048455:       59                      pop    %ecx
 8048456:       c3                      ret

asm_function is from masm_code.obj, and the call should be to
print_int(int) from c_code.o. main.o also has a call to print_int, and
it comes out fine:

080483e4 <main>:
[ cut ]
 804840b:       6a 2b                   push   $0x2b
 804840d:       e8 0e 00 00 00          call   8048420 <print_int>
 8048412:       83 c4 10                add    $0x10,%esp
 8048415:       89 ec                   mov    %ebp,%esp
 8048417:       5d                      pop    %ebp
 8048418:       c3                      ret

Am I doing this right? I can send you this example code if it's
useful. Thanks for the help.

Lachlan O'Dea <>   Computer Associates Pty Ltd
Webmaster                                   Vet - Anti-Virus Software

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