bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug binutils/12807] OBJCOPY from ELF to COFF changes relocation type fr


From: ee at la dot mine.nu
Subject: [Bug binutils/12807] OBJCOPY from ELF to COFF changes relocation type from 32 to 16 bits
Date: Fri, 27 May 2011 01:23:16 +0000

http://sourceware.org/bugzilla/show_bug.cgi?id=12807

--- Comment #2 from Emil <ee at la dot mine.nu> 2011-05-27 01:23:12 UTC ---
(In reply to comment #0)
> objcopy decides to change the R_386_32 type into type "1" - 16 bits 
> (instead of "6" - 32 bits). The PE format doesn't handle 16 bit relocations 
> so when you link the copied object into a program and run it you'll get a
> segfault because the "str" pointer is null.
> No error or warning is displayed by objcopy.

Actually there are more bugs:
R_386_32   converts to type "1"
R_386_PC32 converts to type "2"
"Microsoft Portable Executable and Common Object File Format Specification"
Revision 8.2 states that types "1" and "2" are not supported.
The correct transformation is
R_386_32   to IMAGE_REL_I386_DIR32  (type 6)
R_386_PC32 to IMAGE_REL_I386_REL32  (type 20)

Beside the above changes symbols of the last relocation type (which covers
branch and call instructions) should have symbol_type = 0x20 (now it is 0)
Another bug is that the actual relative displacement is 4 bytes off.

I have attached a little C program which patches COFF pe-i386 files produced
by OBJCOPY so they are now linking correctly and the linker generates working
EXE files.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]