bug-binutils
[Top][All Lists]
Advanced

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

[Bug binutils/12807] New: OBJCOPY from ELF to COFF changes relocation ty


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

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

           Summary: OBJCOPY from ELF to COFF changes relocation type from
                    32 to 16 bits
           Product: binutils
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: binutils
        AssignedTo: address@hidden
        ReportedBy: address@hidden


Create a small C program and compile it with TCC compiler:

char *str = "STR";

void
empty( void )
{
}

$tcc -c -o t.o t.c
$objdump -x t.o
[...]
RELOCATION RECORDS FOR [.data]:
OFFSET   TYPE              VALUE
00000000 R_386_32          L.0

// disassembled:
.data:08000020             _data           segment para public 'DATA' use32
.data:08000020                             assume cs:_data
.data:08000020                             ;org 8000020h
.data:08000020                             public str
.data:08000020 24 00 00 08 str             dd offset L_0           ; "STR"
.data:08000024 53 54 52 00 L_0             db 'STR',0              ; 

$objcopy -O pe-i386 t.o tw.obj
$objdump -x tw.obj
[...]
RELOCATION RECORDS FOR [.data]:
OFFSET   TYPE              VALUE
00000000 1                 L.0+0xfffffffc

// disassembled:
.data:00000020             _data           segment para public 'DATA' use32
.data:00000020                             assume cs:_data
.data:00000020                             ;org 20h
.data:00000020                             public str
.data:00000020 24 00       str             dw offset L_0           ; "STR"
.data:00000022 00 00                       align 4
.data:00000024 53 54 52 00 L_0             db 'STR',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.

-- 
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]