Bug 19175 - [Regression] ld assertion fail ../../bfd/elf32-i386.c:5245
Summary: [Regression] ld assertion fail ../../bfd/elf32-i386.c:5245
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.26
: P2 normal
Target Milestone: 2.26
Assignee: H.J. Lu
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-10-26 21:25 UTC by Matthias Klose
Modified: 2015-10-27 02:26 UTC (History)
1 user (show)

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


Attachments
test case (1.35 MB, application/x-xz)
2015-10-26 21:25 UTC, Matthias Klose
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Matthias Klose 2015-10-26 21:25:55 UTC
Created attachment 8749 [details]
test case

this is still seen with the fix (as checked in) for PR ld/19171.

ld --eh-frame-hdr -m elf_i386 --hash-style=gnu --as-needed -shared -z relro -o fwupdate.so --warn-common --no-undefined --fatal-warnings -Bsymbolic --build-id=sha1 crt0-efi-ia32.o fwupdate.o libefi.a libgnuefi.a libgcc.a -T elf_ia32_efi.lds
ld: BFD (GNU Binutils for Ubuntu) 2.25.51.20151022 assertion fail ../../bfd/elf32-i386.c:5245
ld: BFD (GNU Binutils for Ubuntu) 2.25.51.20151022 assertion fail ../../bfd/elf32-i386.c:5245
Comment 1 Matthias Klose 2015-10-26 21:33:54 UTC
code taken from https://github.com/rhinstaller/fwupdate
Comment 2 H.J. Lu 2015-10-26 22:53:18 UTC
[hjl@gnu-6 pr19175]$ cat 19175.s
	.globl	_start
	.type	_start, @function
_start:
	movl	_text@GOT(%ecx), %eax
	.size	_start, .-_start
[hjl@gnu-6 pr19175]$ cat 19175.t
EXTERN(_start)
ENTRY(_start)

SECTIONS
{
  .text :
  {
    _text = .;
    *(.text*)
  }
}
[hjl@gnu-6 pr19175]$ gcc -c 19175.s -m32
[hjl@gnu-6 pr19175]$ ./tst/ld -T 19175.t  -Bsymbolic -shared  19175.o -melf_i386 
./tst/ld: BFD (GNU Binutils) 2.25.51.20151026 assertion fail /export/gnu/import/git/sources/binutils-gdb/bfd/elf32-i386.c:5245
[hjl@gnu-6 pr19175]$
Comment 3 H.J. Lu 2015-10-26 23:33:38 UTC
Fixed.
Comment 4 Sourceware Commits 2015-10-26 23:33:48 UTC
The master branch has been updated by H.J. Lu <hjl@sourceware.org>:

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

commit 7b7e7f1da28585cfa49cbced50dbbd75a143cd20
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Mon Oct 26 16:32:34 2015 -0700

    Check symbol defined by assignment in linker script
    
    Symbol symbol defined by an assignment in a linker script has type
    bfd_link_hash_new.  elf_i386_convert_load and elf_x86_64_convert_load
    should check bfd_link_hash_new to see if a symbol is defined by a linker
    script.
    
    bfd/
    
    	PR ld/19175
    	* elf32-i386.c (elf_i386_convert_load): Check bfd_link_hash_new
    	instead of calling bfd_link_get_defined_symbol.
    	* elf64-x86-64.c (elf_x86_64_convert_load): Likewise.  Skip
    	relocation overflow for bfd_link_hash_new.
    	* linker.c (bfd_link_get_defined_symbol): Removed.
    	* bfd-in2.h: Regenerated.
    
    ld/testsuite/
    
    	PR ld/19175
    	* ld-i386/i386.exp: Run pr19175.
    	* ld-x86-64/x86-64.exp: Likewise.
    	* ld-i386/pr19175.d: New file.
    	* ld-i386/pr19175.s: Likewise.
    	* ld-i386/pr19175.t: Likewise.
    	* ld-x86-64/pr19175.d: Likewise.
    	* ld-x86-64/pr19175.s: Likewise.
    	* ld-x86-64/pr19175.t: Likewise.
Comment 5 Sourceware Commits 2015-10-27 02:26:09 UTC
The master branch has been updated by Alan Modra <amodra@sourceware.org>:

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

commit 321df0656c7557004a232b4ac3d8c354a59de364
Author: Alan Modra <amodra@gmail.com>
Date:   Tue Oct 27 12:01:55 2015 +1030

    Evaluate __start_* and __stop_* symbol PROVIDE expressions early
    
    Makes these symbols defined before bfd_elf_size_dynamic_sections, to
    avoid horrible hacks elsewhere.  The exp_fold_tree undefweak change
    is necessary to define undefweak symbols early too.  The comment was
    wrong.  PROVIDE in fact defines undefweak symbols, via
    bfd_elf_record_link_assignment.
    
    	PR ld/19175
    	* ldlang.c (lang_insert_orphan): Evaluate __start_* and __stop_*
    	symbol PROVIDE expressions.
    	* ldexp.c (exp_fold_tree_1 <etree_provide>): Define undefweak
    	references.