Bug 12808 - Segfault in _bfd_elf_merge_symbol
Summary: Segfault in _bfd_elf_merge_symbol
Status: RESOLVED INVALID
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.20
: P2 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-26 02:25 UTC by Kim Taylor
Modified: 2011-05-26 13:19 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
Fixes bug - Error message may not be correct (284 bytes, text/plain)
2011-05-26 02:25 UTC, Kim Taylor
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Kim Taylor 2011-05-26 02:25:01 UTC
Created attachment 5752 [details]
Fixes bug - Error message may not be correct

The wrong format string is used in calls to _bfd_default_error_handler. The attached patch fixes the one that caused a crash for me. The other calls are probably broken too. I do not know enough about what the error messages are trying to say to fix them properly.
Comment 1 Alan Modra 2011-05-26 06:21:13 UTC
elflink.c in 2.20.1 does not have an error in the line you show in your patch, so perhaps you or someone else applied an incorrect patch?
Comment 2 Kim Taylor 2011-05-26 12:08:59 UTC
(In reply to comment #1)
> elflink.c in 2.20.1 does not have an error in the line you show in your patch,
> so perhaps you or someone else applied an incorrect patch?

I'm not sure what you mean by this. I'll try to explain the problem clearer:

The following code has been extracted from the latest version of elflink.c
-------------------------------------------------------------------------
      if (tdef && ntdef)
	(*_bfd_error_handler)
	  (_("%s: TLS definition in %B section %A mismatches non-TLS definition in %B section %A"),
	   tbfd, tsec, ntbfd, ntsec, h->root.root.string);
      else if (!tdef && !ntdef)
	(*_bfd_error_handler)
	  (_("%s: TLS reference in %B mismatches non-TLS reference in %B"),
	   tbfd, ntbfd, h->root.root.string);
      else if (tdef)
	(*_bfd_error_handler)
	  (_("%s: TLS definition in %B section %A mismatches non-TLS reference in %B"),
	   tbfd, tsec, ntbfd, h->root.root.string);
      else
	(*_bfd_error_handler)
	  (_("%s: TLS reference in %B mismatches non-TLS definition in %B section %A"),
	   tbfd, ntbfd, ntsec, h->root.root.string);
--------------------------------------------------------------------------

There are several cases where the format descriptor does not match the supplied argument type.

eg: "%s: TLS definition in %B section %A mismatches non-TLS reference in %B"
    (string)             (bfd *)   (asection *)                       (bfd *)
      tbfd                tsec      btbfd                 h->root.root.string
     (bfd *)          (asection *)  (bfd *)                      (string)
Comment 3 Andreas Schwab 2011-05-26 12:29:38 UTC
%A and %B are always processed first.
Comment 4 Kim Taylor 2011-05-26 13:19:33 UTC
(In reply to comment #3)
> %A and %B are always processed first.

Ahhh, yes you are right. %As and %Bs get caught by _bfd_default_error_handler then anything remaining gets sent to vfprintf. I missed that.

The segfault occurs in the Debian binutils where the attached patch shows the first format descriptor as being incorrect.

This is thus not a binutils bug but a Debian bug as Alan was saying. I will check the Debian tree.

Thanks