Bug 18152 - [2.26 Regression] internal error in do_relocate_sections, at gold/reloc.cc:953
Summary: [2.26 Regression] internal error in do_relocate_sections, at gold/reloc.cc:953
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: gold (show other bugs)
Version: 2.26
: P2 normal
Target Milestone: 2.26
Assignee: Cary Coutant
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-03-20 15:14 UTC by H.J. Lu
Modified: 2015-03-22 00:51 UTC (History)
2 users (show)

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


Attachments
self contained testcase (3.33 MB, application/x-xz)
2015-03-20 21:11 UTC, Rafael Ávila de Espíndola
Details

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2015-03-20 15:14:50 UTC
With llvm at r232785, on Linux/x86-64, "make check" in llvm
gave me:

FAIL: LLVM :: tools/gold/pr19901.ll (22024 of 24619)
******************** TEST 'LLVM :: tools/gold/pr19901.ll' FAILED ********************
Script:
--
/export/build/gnu/llvm-clang-x32/build-x86_64-linux/./bin/llc /export/ssd/git/llvm-x32/test/tools/gold/pr19901.ll -o /export/build/gnu/llvm-clang-x32/build-x86_64-linux/test/tools/gold/Output/pr19901.ll.tmp.o -filetype=obj -relocation-model=pic
/export/build/gnu/llvm-clang-x32/build-x86_64-linux/./bin/llvm-as /export/ssd/git/llvm-x32/test/tools/gold/Inputs/pr19901-1.ll -o /export/build/gnu/llvm-clang-x32/build-x86_64-linux/test/tools/gold/Output/pr19901.ll.tmp2.o
/usr/local/bin/ld.gold -plugin /export/build/gnu/llvm-clang-x32/build-x86_64-linux/./lib/LLVMgold.so      -plugin-opt=mtriple=x86_64-linux-gnu      -shared -m elf_x86_64 -o /export/build/gnu/llvm-clang-x32/build-x86_64-linux/test/tools/gold/Output/pr19901.ll.tmp.so /export/build/gnu/llvm-clang-x32/build-x86_64-linux/test/tools/gold/Output/pr19901.ll.tmp2.o /export/build/gnu/llvm-clang-x32/build-x86_64-linux/test/tools/gold/Output/pr19901.ll.tmp.o
/export/build/gnu/llvm-clang-x32/build-x86_64-linux/./bin/llvm-readobj -t /export/build/gnu/llvm-clang-x32/build-x86_64-linux/test/tools/gold/Output/pr19901.ll.tmp.so | /export/build/gnu/llvm-clang-x32/build-x86_64-linux/./bin/FileCheck /export/ssd/git/llvm-x32/test/tools/gold/pr19901.ll
--
Exit Code: 1

Command Output (stderr):
--
/usr/local/bin/ld.gold: internal error in do_relocate_sections, at /net/gnu-6/export/linux/src/binutils/binutils/gold/reloc.cc:953

--
Comment 1 H.J. Lu 2015-03-20 15:20:44 UTC
It is regression from 2.25.
Comment 2 H.J. Lu 2015-03-20 15:41:03 UTC
It was caused by

commit e16631979e847a6b39db3435bea7708b9f34b36d
Author: Cary Coutant <ccoutant@google.com>
Date:   Mon Mar 9 10:10:29 2015 -0700

    Fix failure in exception_static_test.
    
    Because the __EH_FRAME_BEGIN__ symbol is provided in an empty .eh_frame
    section in crtbeginT.o, if crt1.o has a non-empty .eh_frame section,
    we place all optimized .eh_frame sections into the output section ahead
    of the __EH_FRAME_BEGIN__ symbol, which breaks EH for statically-linked
    binaries.
    
    This patch fixes the problem by delaying the attachment of the optimized
    .eh_frame sections to the output section until we see the end marker
    section (or to the end of pass 1 if we never see an end marker).
Comment 3 Rafael Ávila de Espíndola 2015-03-20 21:11:06 UTC
Created attachment 8201 [details]
self contained testcase

This crashes:
$ ld-new -shared -o foo.so -plugin ./LLVMgold.so foo.bc foo.o
Comment 4 cvs-commit@gcc.gnu.org 2015-03-22 00:50:30 UTC
The master branch has been updated by Cary Coutant <ccoutant@sourceware.org>:

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

commit bd9e0d4628f1265c42516f90c4f162cefa787294
Author: Cary Coutant <ccoutant@gmail.com>
Date:   Sat Mar 21 17:47:49 2015 -0700

    Fix internal error in do_relocate_sections when using plugins.
    
    In a previous patch for PR 14675, to fix a problem with
    the .eh_frame section when static linking, I added a step to
    finalize the .eh_frame section at the end of the first link
    pass. This patch caused PR 18152, where a plugin-claimed
    object caused a non-claimed object's layout to be deferred
    until replacement files were read. The call to
    finalize_eh_frame_section() is happening before the layout of
    the deferred objects, leading to the internal error in
    do_relocate_sections.
    
    This patch moves the finalization of the .eh_frame section to
    after deferred objects have been processed.
    
    gold/
    	PR gold/14675
    	PR gold/18152
    	* gold.cc (queue_middle_tasks): Finalize .eh_frame after laying out
    	deferred objects.
Comment 5 Cary Coutant 2015-03-22 00:51:07 UTC
Fixed on trunk.