Bug 17432 - internal error in relocate_tls, at gold/x86_64.cc:3829
Summary: internal error in relocate_tls, at gold/x86_64.cc:3829
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: gold (show other bugs)
Version: 2.25
: P2 normal
Target Milestone: ---
Assignee: Cary Coutant
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-09-24 19:06 UTC by Markus Trippelsdorf
Modified: 2014-09-30 23:07 UTC (History)
1 user (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Trippelsdorf 2014-09-24 19:06:23 UTC
Since r215417 of gcc trunk gold hits the following assert:

markus@x4 ~ % echo "int main () {}" | g++ -flto -fprofile-generate -x c++ -
ld: internal error in relocate_tls, at gold/x86_64.cc:3829
collect2: error: ld returned 1 exit status

3825     case elfcpp::R_X86_64_TPOFF32:          // Local-exec
3826       if (tls_segment == NULL)
3827         {
3828           gold_assert(parameters->errors()->error_count() > 0
3829                       || issue_undefined_symbol_error(gsym));
3830           return;
3831         }
3832       value -= tls_segment->memsz();
3833       Relocate_functions<size, false>::rela32(view, value, addend);
3834       break;
3835     }

https://gcc.gnu.org/viewcvs/gcc/trunk/gcc/ipa-visibility.c?r1=215417&r2=215416&pathrev=215417
Comment 1 Ian Lance Taylor 2014-09-25 00:51:04 UTC
Can you show how gold is invoked?  Can you show the input files?
Comment 2 Markus Trippelsdorf 2014-09-25 06:50:18 UTC
Honza posted a disassembly:

https://gcc.gnu.org/ml/gcc-patches/2014-09/msg02208.html
Comment 3 Cary Coutant 2014-09-26 02:13:51 UTC
When we add the placeholder symbol from the claimed file handler, it's not marked as a TLS symbol (the API doesn't provide a way). We're supposed to override the placeholder symbol with the real symbol when we see the real ELF file, but we don't do that for COMMON symbols.

Shouldn't be too hard to fix.
Comment 4 cvs-commit@gcc.gnu.org 2014-09-26 04:50:55 UTC
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gdb and binutils".

The branch, master has been updated
       via  1707f183446fae9aca8523c1ebf721bcf2472008 (commit)
      from  d7ac9d81bb1a177264187efc51c9cc0479cdd09c (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=1707f183446fae9aca8523c1ebf721bcf2472008

commit 1707f183446fae9aca8523c1ebf721bcf2472008
Author: Cary Coutant <ccoutant@google.com>
Date:   Thu Sep 25 21:47:10 2014 -0700

    Fix problem where TLS common symbols are not allocated properly during LTO.
    
    The plugin API doesn't provide a way for the claimed file handler to
    identify a TLS symbol, so when adding a common TLS symbol, gold
    mistakenly places the symbol in the non-TLS commons list, and does
    not override it when we see the replacement symbol that is marked
    as TLS. Consequently, we allocate the TLS common symbol as a regular
    common, and, if it's the only TLS in the program, we'll give an
    internal error because we haven't allocated a TLS segment.
    
    This patch fixes the problem by removing an exclusion where common
    symbols would not override the placeholder symbols, but checking to
    see if the size needs adjusting (the original reason for the exclusion).
    Furthermore, we need to avoid putting placeholder symbols in the common
    list, and wait until we see a real common symbol with a type we can
    trust.
    
    gold/
    	PR gold/17432
    	* resolve.cc (Symbol_table::resolve): Override common placeholder
    	symbols, but adjust sizes.
    	* symtab.cc (Symbol_table::add_from_object): Don't add placeholder
    	symbols to common lists.

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

Summary of changes:
 gold/ChangeLog  |    8 ++++++++
 gold/resolve.cc |   23 +++++++++++++++++++----
 gold/symtab.cc  |   12 ++++++++----
 3 files changed, 35 insertions(+), 8 deletions(-)
Comment 5 Cary Coutant 2014-09-26 04:56:12 UTC
Fixed on trunk.
Comment 6 cvs-commit@gcc.gnu.org 2014-09-30 23:07:37 UTC
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gdb and binutils".

The branch, master has been updated
       via  db4c959472b3a8f82cfb67d2532ba22f44ab98da (commit)
      from  cd6da0366dc6684d32f349b729b5558258fc3af4 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=db4c959472b3a8f82cfb67d2532ba22f44ab98da

commit db4c959472b3a8f82cfb67d2532ba22f44ab98da
Author: Cary Coutant <ccoutant@google.com>
Date:   Tue Sep 30 16:06:50 2014 -0700

    Fix error from previous patch where tosize and tovalue were redefined
    in a block, shadowing the declarations outside the block.
    
    gold/
    	PR gold/17432
    	* resolve.cc (Symbol_table::resolve): Fix local shadowing error.

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

Summary of changes:
 gold/ChangeLog  |    5 +++++
 gold/resolve.cc |    4 ++--
 2 files changed, 7 insertions(+), 2 deletions(-)