Bug 15365 - MIPS linker hits assertion with -mabi=64 accessing __ehdr_start
Summary: MIPS linker hits assertion with -mabi=64 accessing __ehdr_start
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.24
: P2 normal
Target Milestone: ---
Assignee: Maciej W. Rozycki
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-04-12 19:14 UTC by sje@gcc.gnu.org
Modified: 2013-05-03 19:35 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 sje@gcc.gnu.org 2013-04-12 19:14:59 UTC
A recent change to glibc caused my ToT MIPS builds to fail.  The test case included below demonstrates the linker assertion I am hitting when building glibc.

% cat ehdr.c
#include <stdio.h>
#include <elf.h> /* has definition of Elf32_Ehdr & Elf64_Ehdr */

extern const Elf32_Ehdr __ehdr_start __attribute__ ((weak));

main()
{
	void *x;
	x = (void *) &__ehdr_start;
	printf("0x%x\n", x);
}

% mips-mti-linux-gnu-gcc -mips64r2 -mabi=64 ehdr.c -o x
/local/home/sellcey/nightly2/install-mips-mti-linux-gnu/lib/gcc/mips-mti-linux-gnu/4.9.0/../../../../mips-mti-linux-gnu/bin/ld: BFD (GNU Binutils) 2.23.52.20130411 assertion fail /local/home/sellcey/nightly2/src/binutils/bfd/elfxx-mips.c:3457
collect2: error: ld returned 1 exit status

The assertion in elfxx-mips.c is:


   /* This function shouldn't be called for symbols that live in the global       area of the GOT.  */
   BFD_ASSERT (h == NULL || h->global_got_area == GGA_NONE);
Comment 1 Maciej W. Rozycki 2013-04-22 20:27:52 UTC
I'm working on this problem.
Comment 2 Sourceware Commits 2013-05-03 15:19:29 UTC
CVSROOT:	/cvs/src
Module name:	src
Changes by:	macro@sourceware.org	2013-05-03 15:19:27

Modified files:
	gold           : ChangeLog layout.cc 
	ld             : ChangeLog 
	ld/emultempl   : elf32.em 
	ld/testsuite   : ChangeLog 
	ld/testsuite/ld-elf: ehdr_start.d 
	ld/testsuite/ld-mips-elf: mips-elf.exp 
Added files:
	ld/testsuite/ld-mips-elf: ehdr_start-1.ld ehdr_start-1.nd 
	                          ehdr_start-2.ld ehdr_start-2.nd 
	                          ehdr_start-new.s ehdr_start-o32.s 

Log message:
	gold/
	PR ld/15365
	* layout.cc (Layout::finalize): Make __ehdr_start STV_HIDDEN.
	
	ld/
	PR ld/15365
	* emultempl/elf32.em (gld${EMULATION_NAME}_before_allocation):
	Restrict __ehdr_start's export class to no less than STV_HIDDEN.
	
	ld/testsuite/
	PR ld/15365
	* ld-elf/ehdr_start.d: Expect __ehdr_start to be STB_LOCAL.
	* ld-mips-elf/ehdr_start-1.nd: New test.
	* ld-mips-elf/ehdr_start-2.nd: New test.
	* ld-mips-elf/ehdr_start-1.ld: New test linker script.
	* ld-mips-elf/ehdr_start-2.ld: New test linker script.
	* ld-mips-elf/ehdr_start-new.s: New test source.
	* ld-mips-elf/ehdr_start-o32.s: New test source.
	* ld-mips-elf/mips-elf.exp: Run the new tests.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/ChangeLog.diff?cvsroot=src&r1=1.1076&r2=1.1077
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/layout.cc.diff?cvsroot=src&r1=1.251&r2=1.252
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/ChangeLog.diff?cvsroot=src&r1=1.2593&r2=1.2594
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/emultempl/elf32.em.diff?cvsroot=src&r1=1.245&r2=1.246
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ChangeLog.diff?cvsroot=src&r1=1.1717&r2=1.1718
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-elf/ehdr_start.d.diff?cvsroot=src&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-mips-elf/ehdr_start-1.ld.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-mips-elf/ehdr_start-1.nd.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-mips-elf/ehdr_start-2.ld.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-mips-elf/ehdr_start-2.nd.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-mips-elf/ehdr_start-new.s.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-mips-elf/ehdr_start-o32.s.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-mips-elf/mips-elf.exp.diff?cvsroot=src&r1=1.78&r2=1.79
Comment 3 Maciej W. Rozycki 2013-05-03 19:35:52 UTC
Discussed here: http://sourceware.org/ml/binutils/2013-04/msg00260.html
continued here: http://sourceware.org/ml/binutils/2013-05/msg00045.html
and now fixed with the commit referred.