public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* strip crashes on MSVC generated object files
@ 2005-02-18 21:32 Christian Groessler
  2005-02-21 16:48 ` Alan Modra
  0 siblings, 1 reply; 2+ messages in thread
From: Christian Groessler @ 2005-02-18 21:32 UTC (permalink / raw)
  To: binutils; +Cc: chris

Hi,

current CVS strip targetted for i686-mingw32 crashes when stripping
MSVC generated object files.
It happens for example when using the --strip-debug option.

I've put a demo object file on
ftp://ftp.groessler.org/pub/chris/tmp/strip-crash.zip (blavc.obj).

These MSVC object files have an additional .drectve section which
might trigger the problem.

What happens is that coffgen.c(bfd_coff_get_comdat_section) gets
called with an *ABS* section and then crashes when dereferencing
used_by_bfd (in coff_section_data).

I've attached a patch to workaround the issue, but it's probably more
curing the symptoms instead of the disease?

regards,
chris



2005-02-18  Christian Groessler  <chris@groessler.org>

        * coffgen.c (bfd_coff_get_comdat_section): Do not call
        coff_section_data for *ABS* sections.



Index: bfd/coffgen.c
===================================================================
RCS file: /cvs/src/src/bfd/coffgen.c,v
retrieving revision 1.46
diff -p -u -r1.46 coffgen.c
--- bfd/coffgen.c       31 Jan 2005 23:13:17 -0000      1.46
+++ bfd/coffgen.c       18 Feb 2005 13:23:15 -0000
@@ -2427,6 +2427,8 @@ bfd_coff_set_symbol_class (abfd, symbol,
 struct coff_comdat_info *
 bfd_coff_get_comdat_section (bfd *abfd, struct bfd_section *sec)
 {
+  if (strcmp (sec->name, BFD_ABS_SECTION_NAME) == 0)
+    return NULL;
   if (bfd_get_flavour (abfd) == bfd_target_coff_flavour)
     return coff_section_data (abfd, sec)->comdat;
   else


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: strip crashes on MSVC generated object files
  2005-02-18 21:32 strip crashes on MSVC generated object files Christian Groessler
@ 2005-02-21 16:48 ` Alan Modra
  0 siblings, 0 replies; 2+ messages in thread
From: Alan Modra @ 2005-02-21 16:48 UTC (permalink / raw)
  To: Christian Groessler; +Cc: binutils

On Fri, Feb 18, 2005 at 02:47:52PM +0100, Christian Groessler wrote:
> I've attached a patch to workaround the issue, but it's probably more
> curing the symptoms instead of the disease?

It's a reasonable thing to do.  The disease in this case is that the
absolute input section isn't attached to each bfd that defines absolute
symbols.  However, fixing that properly requires quite a large patch.

I'm committing a more direct approach than your patch.  There are other
sections besides the absolute section that won't have coff_section_data.

	* coffgen.c (bfd_coff_get_comdat_section): Check that
	coff_section_data isn't NULL.

Index: bfd/coffgen.c
===================================================================
RCS file: /cvs/src/src/bfd/coffgen.c,v
retrieving revision 1.47
diff -u -p -r1.47 coffgen.c
--- bfd/coffgen.c	20 Feb 2005 14:59:06 -0000	1.47
+++ bfd/coffgen.c	21 Feb 2005 11:18:11 -0000
@@ -2427,7 +2427,8 @@ bfd_coff_set_symbol_class (abfd, symbol,
 struct coff_comdat_info *
 bfd_coff_get_comdat_section (bfd *abfd, struct bfd_section *sec)
 {
-  if (bfd_get_flavour (abfd) == bfd_target_coff_flavour)
+  if (bfd_get_flavour (abfd) == bfd_target_coff_flavour
+      && coff_section_data (abfd, sec) != NULL)
     return coff_section_data (abfd, sec)->comdat;
   else
     return NULL;

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-02-21 11:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-02-18 21:32 strip crashes on MSVC generated object files Christian Groessler
2005-02-21 16:48 ` Alan Modra

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).