bug-binutils
[Top][All Lists]
Advanced

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

[Bug binutils/1391] New: objcopy trashes PE executable when using "add-g


From: focht at gmx dot net
Subject: [Bug binutils/1391] New: objcopy trashes PE executable when using "add-gnu-debuglink"
Date: 29 Sep 2005 14:56:45 -0000

Hello,

i am doing cross platform development and use the "separate debug symbols" 
feature.

On native "linux x86" and "linux arm" platform all works fine, the symbols are
separated (ELF, DWARF2 debug format) using

$OBJCOPY --only-keep-debug $1$EXE_EXT $1$DEBUG_EXT 
$OBJCOPY --strip-all $1$EXE_EXT
$OBJCOPY --add-gnu-debuglink=$1$DEBUG_EXT $1$EXE_EXT

sequence.
One can happily debug all the stuff using gcc 3.4.x and 4.0.x toolchains and
recent gdb 6.3.x

On cygwin platform i use same sequence.
The symbol information is separated fine and the debug link is added to .exe
Gdb can load the executable and the debug symbols from separate file:

$ gdb
GNU gdb 6.3.50.20050926
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i686-pc-cygwin"...
(gdb) file test_xxx
Load new symbol table from "/home/work/bin/cygwin-x86-gcc/debug/test_xxx.exe"?
(y or n) y
Reading symbols from /home/work/bin/cygwin-x86-gcc/debug/test_xxx.exe...Reading
symbols from /home/work/bin/cygwin-x86-gcc/debug/test_xxx.dbg...done.
(gdb) b main
Breakpoint 1 at 0x4010cd: file test_xxx.cpp, line 67.

when i try to run it:

(gdb) run
Starting program: /home/work/bin/cygwin-x86-gcc/debug/test_xxx.exe
Error creating process /home/work/bin/cygwin-x86-gcc/debug/test_xxx.exe, (error
193).

It fails.
"193" means something like "ERROR_BAD_EXE_FORMAT"

-------------------

$ objdump -h test_xxx.exe

test_xxx.exe:     file format pei-i386

Sections:
Idx Name          Size      VMA       LMA       File off  Algn
  0 .gnu_debuglink 00000018  00000000  00000000  00000268  2**2
                  CONTENTS, READONLY, DEBUGGING
  1 .text         001f2528  00401000  00401000  00000600  2**4
                  CONTENTS, ALLOC, LOAD, READONLY, CODE, DATA
  2 .data         0000544c  005f4000  005f4000  001f2c00  2**4
                  CONTENTS, ALLOC, LOAD, DATA
  3 .rdata        0002d18c  005fa000  005fa000  001f8200  2**4
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  4 .bss          00001f60  00628000  00628000  00000000  2**4
                  ALLOC
  5 .idata        0000119c  0062a000  0062a000  00225400  2**2
                  CONTENTS, ALLOC, LOAD, DATA
-------------------

When using a native win32 "PE" editor/format tool like "LordPE" it lists some
crap for the first section (containing debug link), all other sections seem ok:

->Section Header Table
   1. item:
    Name:                  /4
    VirtualSize:           0x00000018
    VirtualAddress:        0xFFC00000
    SizeOfRawData:         0x00000208
    PointerToRawData:      0x00000268
    PointerToRelocations:  0x00000000
    PointerToLinenumbers:  0x00000000
    NumberOfRelocations:   0x0000
    NumberOfLinenumbers:   0x0000
    Characteristics:       0x02000000
    (DISCARDABLE)

....
----------------------------------

Others tools like "dumpbin" (m$ vs.net 2003/vc 7.1) crash when i try to dump the
executable.

--------------

Seems objcopy is messing up the PE section table while adding gnu debug link.

Any thoughts?

Regards,

A. Focht

-- 
           Summary: objcopy trashes PE executable when using "add-gnu-
                    debuglink"
           Product: binutils
           Version: 2.16
            Status: NEW
          Severity: normal
          Priority: P2
         Component: binutils
        AssignedTo: unassigned at sources dot redhat dot com
        ReportedBy: focht at gmx dot net
                CC: bug-binutils at gnu dot org
 GCC build triplet: i686-pc-cygwin
  GCC host triplet: i686-pc-cygwin
GCC target triplet: i686-pc-cygwin


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

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.




reply via email to

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