delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2016/07/22/08:01:12

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
X-Recipient: djgpp AT delorie DOT com
X-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20120113;
h=mime-version:in-reply-to:references:from:date:message-id:subject:to;
bh=BduK5u/xsEKi1RkenvEthxh7xx4j/hF+kgEKXXXzwVg=;
b=EyeSVVy1sBwfPqf4KrwqJ94urbs7C93QvOPPENowppcLEvY2/9B1XAP1KTRpA3EIr7
UQTY+m3qSCIjltTOlxhBheMUwZg5/fyeL58w0vxreRHs7o86SwHSeqXAf5jVrxFBF0wT
oqMa5VzOOYQ4sv36ZyepjUwMpvmZU5qKcvz/qpZo5Tqau5z/sUAcwnzaQ9FMKbzPlo+b
6bCbm4tQ8KKZRlQacW83JBqFdsPIftR9n5Nv9C7WusP74wmYRtxDB4xJrz9TcwmBQmz4
BkV4315pQL4g/OFriWDY7yOxozklcht1RU27KXPckhGTDzKAEY9OSAvGY34NKwvn9+Ds
YElQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20130820;
h=x-gm-message-state:mime-version:in-reply-to:references:from:date
:message-id:subject:to;
bh=BduK5u/xsEKi1RkenvEthxh7xx4j/hF+kgEKXXXzwVg=;
b=iJ6V5JCWgZg+7A4cpZCRATPmx3Zmrw6VcZyglObzHi+HSLx26VUOSKE9CRvhy2cmXm
aVPQkpPQtnpyTxy1TpPtSuieILfy3EoDh9W88iEOInaFFr6oZqPteZ27ORnuqQHHtkdo
lk895l3lgTzcB909VQ0hB9xUNP2ZGcfnfJLuvOvMzIS0qi3hTN/R/2rxDjQ5LHEsien/
zr/xt6HqpeMs+re5atEzfsAWQ4Cf9xVVtkSOCoLz7lgZ4WT/RYRV/7iit3IxbKaP5L3C
rfYPQQojN/sPfllpzEl4jJKzIMR1WS/ke6vgJaqd7po58CQgvdmEiCfcdmhiNaKSbwXG
4Glw==
X-Gm-Message-State: AEkooutEr1JC1v+lIV2VY18qSj9kCD/xvPU10jA8C3WByHnVibhaw+PCI342WyPbhl/QJO0z4vdPeivFBVA0dQ==
X-Received: by 10.107.14.74 with SMTP id 71mr4147060ioo.93.1469188841818; Fri,
22 Jul 2016 05:00:41 -0700 (PDT)
MIME-Version: 1.0
In-Reply-To: <d4e8427b-b265-41c5-8322-58ff3043fcac@googlegroups.com>
References: <e5d46af2-36fb-46af-af04-805ce2f8b6c3 AT googlegroups DOT com>
<b558cc5e-cc8f-4794-a8ca-f90f65312a90 AT googlegroups DOT com> <d4e8427b-b265-41c5-8322-58ff3043fcac AT googlegroups DOT com>
From: "Ozkan Sezer (sezeroz AT gmail DOT com) [via djgpp AT delorie DOT com]" <djgpp AT delorie DOT com>
Date: Fri, 22 Jul 2016 15:00:41 +0300
Message-ID: <CAA2C=vDd7mD3iO13M2FQLVoJ=tCjWGhAfkuj1NsyxN9a9PQY6Q@mail.gmail.com>
Subject: Re: LD from binutils 2.26 crashes when -ffunction-sections +
-Wl,--gc-sections is used but only under DOS
To: djgpp AT delorie DOT com
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On 7/22/16, RayeR (glaux AT centrum DOT cz) [via djgpp AT delorie DOT com]
<djgpp AT delorie DOT com> wrote:
>> And if crash it should be consistent and crash under Windows too.
>
> OK, maybe the bug is happening under Windows too but their memory management
> of NTVDM is more benevolent to memory protection and doesn't trigger fault
> in some cases. Even if so the produced binary seems to be OK (and smaller).
>

It segs in fini_reloc_cookie_rels() because (sec)->used_by_bfd is NULL

Program received signal SIGSEGV, Segmentation fault.
0x08088dbd in _bfd_coff_gc_mark (info=0x80f3b80, sec=0x906b248,
gc_mark_hook=0x80859b0 <_bfd_coff_gc_mark_hook>) at
../../binutils-2.26/bfd/coffgen.c:2691
2691	  if (cookie->rels && coff_section_data (NULL, sec)->relocs !=
cookie->rels)
(gdb) bt
#0  0x08088dbd in _bfd_coff_gc_mark (info=0x80f3b80, sec=0x906b248,
gc_mark_hook=0x80859b0 <_bfd_coff_gc_mark_hook>) at
../../binutils-2.26/bfd/coffgen.c:2691
#1  0x08088e22 in _bfd_coff_gc_mark (info=0x80f3b80, sec=0x906b89c,
gc_mark_hook=0x80859b0 <_bfd_coff_gc_mark_hook>) at
../../binutils-2.26/bfd/coffgen.c:2799
#2  0x08088e22 in _bfd_coff_gc_mark (info=0x80f3b80, sec=0x905ac84,
gc_mark_hook=0x80859b0 <_bfd_coff_gc_mark_hook>) at
../../binutils-2.26/bfd/coffgen.c:2799
#3  0x08088e22 in _bfd_coff_gc_mark (info=0x80f3b80, sec=0x905abd0,
gc_mark_hook=0x80859b0 <_bfd_coff_gc_mark_hook>) at
../../binutils-2.26/bfd/coffgen.c:2799
#4  0x08088f31 in bfd_coff_gc_sections (abfd=0x9051918,
info=0x80f3b80) at ../../binutils-2.26/bfd/coffgen.c:3045
#5  0x0805af43 in lang_process () at ../../binutils-2.26/ld/ldlang.c:6502
#6  0x0805e952 in main (argc=15, argv=0xbfb8e504) at
../../binutils-2.26/ld/ldmain.c:414

Doing the following makes the program to run without crashing:

--- binutils-2.26/bfd/coffgen.c.orig
+++ binutils-2.26/bfd/coffgen.c
@@ -2688,8 +2688,11 @@
 fini_reloc_cookie_rels (struct coff_reloc_cookie *cookie,
 			asection *sec)
 {
-  if (cookie->rels && coff_section_data (NULL, sec)->relocs != cookie->rels)
+  if (cookie->rels) {
+   if (!coff_section_data(NULL, sec)) return;
+   if (coff_section_data (NULL, sec)->relocs != cookie->rels)
     free (cookie->rels);
+  }
 }

 /* Initialize the whole of COOKIE for input section SEC.  */

It is very possible that this isn't a proper fix though.

--
O.S.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019