public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: cygwin@cygwin.com
Subject: Binutils objcopy bug (was Re: rebase segfault)
Date: Wed, 16 Jan 2013 12:35:00 -0000	[thread overview]
Message-ID: <20130116123509.GA16991@calimero.vinschen.de> (raw)
In-Reply-To: <50F653AB.80102@gmail.com>

On Jan 16 08:15, marco atzeri wrote:
> On 1/15/2013 11:03 PM, marco atzeri wrote:
> >On 1/15/2013 12:24 PM, Corinna Vinschen wrote:
> >>On Jan 15 11:36, marco atzeri wrote:
> >>>On 1/15/2013 11:07 AM, Corinna Vinschen wrote:
> >>>>  The segfault occurs as soon as one
> >>>>entry translates into a memory address which is beyond the committed
> >>>>area of the file memory map.
> >>>>[...]
> [...]
> it seems only a symptom, also using that, I have still one
> rebase segfault more crazy than before.
> (ltree.dll is fine now)

This is not really the case, you just don't see it anymore.  As I wrote
in my first reply, what happens is that the relocation information
points outside of the file map.  The below effect on dict_snowball.dll
shows what's going wrong.

> $ rebase -O dict_snowball.dll
> Segmentation fault (core dumped)
> 
> It segfaults and a spurious character appears on the section:
> 
> $ objdump -h dict_snowball.dll
> 
> dict_snowball.dll:     file format pei-i386
> 
> Sections:
> Idx Name          Size      VMA       LMA       File off  Algn
>   0 .text         00016808  4e971000  4e971000  00000400  2**4
>                   CONTENTS, ALLOC, LOAD, READONLY, CODE, DATA
>   1 .data         00017180  4e988000  4e988000  00016e00  2**5
>                   CONTENTS, ALLOC, LOAD, DATA
>   2 .bss          000000f8  4e9a0000  4e9a0000  00000000  2**5
>                   ALLOC
>   3 .edata        00000fe0  4e9a1000  4e9a1000  0002e000  2**2
>                   CONTENTS, ALLOC, LOAD, READONLY, DATA
>   4 .idata        000003e0  4e9a2000  4e9a2000  0002f000  2**2
>                   CONTENTS, ALLOC, LOAD, DATA
>   5 .reloc        0000765c  4e9a3000  4e9a3000  0002f400  2**2
>                   CONTENTS, ALLOC, LOAD, READONLY, DATA
>   6 .gnu_debuglinkâ–’ 0000001c  4e9ab000  4e9ab000  00036c00  2**2
>                   CONTENTS, ALLOC, LOAD, READONLY, DATA
> 
> but the second time it works
> $ rebase -O dict_snowball.dll

It only works because the file isn't rebased at all since, apparently,
it already has been rebased, so the file is left alone.

> So it is now a rebase bug, a objcopy bug or both ?

As far as I can tell it's an objcopy bug.

The stripped version of the DLL has a normal relocation information
which at one point ends in a NULL IMAGE_BASE_RELOCATION record, as
expected.  After calling `objcopy --add-gnu-debuglink', the relocation
information is supposed to be the same as before, since the relocatable
file content didn't change.

Nevertheless, when stepping through the relocator code in rebase, it
turns out that the former NULL IMAGE_BASE_RELOCATION record does not
contain only 0 values anymore.  Rather, it has been overwritten with
some random(?) non-0 values, which rebase correctly interprets as the
start of the next IMAGE_BASE_RELOCATION array.  So rebase blunders
along, thus either just SEGVing, if everything goes well, or, worst
case, overwriting formerly correct information in the file with
arbitrary data.

This is a serious bug in objcopy in the current binutils.  Given that
cygport creates the debug info automatically, we might end up with
spuriously broken DLLs in the distro.

I checked with objcopy from the older binutils 2.51.53-2, and the
problem did not show up.  I also built the latest binutils release
2.23.1 and the problem also doesn't show, so we probably can get away
with just a black eye by updating binutils to 2.23.1.  Chris?


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

  reply	other threads:[~2013-01-16 12:35 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-15  8:44 rebase segfault marco atzeri
2013-01-15 10:08 ` Corinna Vinschen
2013-01-15 10:36   ` marco atzeri
2013-01-15 11:24     ` Corinna Vinschen
2013-01-15 22:04       ` marco atzeri
2013-01-16  7:16         ` marco atzeri
2013-01-16 12:35           ` Corinna Vinschen [this message]
2013-01-16 13:38             ` Binutils objcopy bug (was Re: rebase segfault) marco atzeri
2013-01-16 14:42               ` Corinna Vinschen
2013-01-16 15:12                 ` marco atzeri
2013-01-16 16:26                   ` Corinna Vinschen
2013-01-24  9:02               ` Yaakov
2013-01-24  9:28                 ` Corinna Vinschen
2013-01-24  9:49                   ` marco atzeri
2013-01-24 10:01                     ` Corinna Vinschen
2013-01-24 10:16                       ` marco atzeri
2013-01-24 12:09                         ` Corinna Vinschen
2013-01-24 12:35                           ` marco atzeri
2013-01-24 14:12                             ` Corinna Vinschen
2013-01-25 12:34                       ` marco atzeri
2013-01-25 13:20                         ` Kai Tietz
2013-01-25 15:01                           ` Corinna Vinschen
2013-01-25 15:12                             ` marco atzeri
2013-01-26  6:32                               ` Reini Urban
2013-01-26  7:53                                 ` marco atzeri
2013-01-29 22:30                                   ` Reini Urban
2013-01-30 16:46                                     ` Andrew Dunstan
2013-01-30 17:03                                       ` marco atzeri
2013-03-04 20:01                                       ` Andrew Dunstan
2013-03-04 21:30                                         ` marco atzeri
2013-03-04 21:41                                           ` Andrew Dunstan
2013-03-04 22:32                                           ` Andrew Dunstan
2013-03-05  5:42                                             ` marco atzeri
2013-03-05 15:39                                               ` Andrew Dunstan
2013-01-25 13:22                         ` Kai Tietz
2013-01-24 15:56                     ` Christopher Faylor
2013-01-24 16:17                       ` marco atzeri
2013-01-18 15:34             ` marco atzeri
2013-01-18 15:44               ` Christopher Faylor
2013-01-19  8:56             ` marco atzeri
2013-01-19 15:23               ` Corinna Vinschen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130116123509.GA16991@calimero.vinschen.de \
    --to=corinna-cygwin@cygwin.com \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).