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]

objcopy problem with pe-i386 ?


Hi,
I'm trying to convert object files compiled by Microsoft VisualC++6.0
into elf32-i386 using objcopy on Linux host.
the conversion seemed successfully finished, but when I linked 
into executable, I found the calls from converted file to
other files are all gets wrong offset (+4bytes).

Is there any work around to get this work ?

I used binutils-2.14 that configured "--enable-targets=i386-pe".

---- The oparation is follows. ----

# on windows VC++6.0
cl -c ext_func.c

# on Redhat9.0
gcc -c main.c

objcopy --strip-debug \
	--remove-leading-char \
	--input-target pe-i386 \
	--output-target elf32-i386 \
	ext_func.obj ext_func.o

gcc -o test main.o ext_func.o

/* --- file: ext_func.c --- */
extern int int_func(int a);

int ext_func(int a)
{
	return int_func(a);
}
/* --- file: main.c --- */
#include <stdlib.h>

extern int ext_func(int);

int main(void)
{
	printf("ext_func() = %d.\n", ext_func(10));	
	return 0;
}

int int_func(int a)
{
	return (a>>1);	
}
------------------------
objdump -S test
---- snip ----
08048370 <ext_func>:
 8048370:	55                   	push   %ebp
 8048371:	8b ec                	mov    %esp,%ebp
 8048373:	8b 45 08             	mov    0x8(%ebp),%eax
 8048376:	50                   	push   %eax
 8048377:	e8 ed ff ff ff       	call   8048369 <int_func+0x4>
 804837c:	83 c4 04             	add    $0x4,%esp
 804837f:	5d                   	pop    %ebp
 8048380:	c3                   	ret    
 8048381:	90                   	nop    
 8048382:	90                   	nop    
 8048383:	90                   	nop    
---- snip ----

objdump -b pe-i386 -S -r ext_func.o

00000000 <ext_func>:
   0:	55                   	push   %ebp
   1:	8b ec                	mov    %esp,%ebp
   3:	8b 45 08             	mov    0x8(%ebp),%eax
   6:	50                   	push   %eax
   7:	e8 00 00 00 00       	call   c <ext_func+0xc>
			8: R_386_PC32	int_func
   c:	83 c4 04             	add    $0x4,%esp
   f:	5d                   	pop    %ebp
  10:	c3                   	ret    

------------------------------------------------
JIRO TERAKAWA


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