Bug 12380 - Assertion in linker script failed twice
Summary: Assertion in linker script failed twice
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.22
: P2 minor
Target Milestone: ---
Assignee: Alan Modra
URL: http://sourceware.org/ml/binutils/201...
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-09 10:25 UTC by Dmitry Gorbachev
Modified: 2011-01-12 12:58 UTC (History)
2 users (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 Dmitry Gorbachev 2011-01-09 10:25:37 UTC
$ touch xxx.c
$ echo 'ASSERT(2 * 2 == 5, "violation of the fundamental laws of the universe!");' > xxx.lds
$ gcc -nostdlib xxx.c -Wl,-Txxx.lds
/usr/bin/ld: violation of the fundamental laws of the universe!
/usr/bin/ld: violation of the fundamental laws of the universe!
collect2: ld returned 1 exit status
Comment 1 H.J. Lu 2011-01-09 17:04:44 UTC
This works for me:

---
diff --git a/ld/ldexp.c b/ld/ldexp.c
index 3261884..812720c 100644
--- a/ld/ldexp.c
+++ b/ld/ldexp.c
@@ -723,8 +723,13 @@ exp_fold_tree_1 (etree_type *tree)
 
     case etree_assert:
       exp_fold_tree_1 (tree->assert_s.child);
-      if (expld.phase == lang_final_phase_enum && !expld.result.value)
-	einfo ("%X%P: %s\n", tree->assert_s.message);
+      if (expld.phase == lang_final_phase_enum
+	  && !expld.result.value
+	  && tree->assert_s.message)
+	{
+	  einfo ("%X%P: %s\n", tree->assert_s.message);
+	  tree->assert_s.message = NULL;
+	}
       break;
 
     case etree_unary:
---
Comment 2 H.J. Lu 2011-01-09 18:06:17 UTC
A patch is posted at

http://sourceware.org/ml/binutils/2011-01/msg00124.html
Comment 3 Sourceware Commits 2011-01-12 12:07:24 UTC
CVSROOT:	/cvs/src
Module name:	src
Changes by:	amodra@sourceware.org	2011-01-12 12:07:20

Modified files:
	ld             : ChangeLog ldexp.c ldexp.h ldlang.c 

Log message:
	PR ld/12380
	* ldexp.h (enum phase_enum): Comment.  Add exp_dataseg_done.
	* ldexp.c (fold_unary <DATA_SEGMENT_END>): Rearrange code.  Test
	for exp_dataseg_done rather than expld.phase == lang_final_phase_enum
	to detect when we've finished sizing sections.
	(fold_binary <DATA_SEGMENT_ALIGN>): Likewise.
	(fold_binary <DATA_SEGMENT_RELRO_END>): Likewise.  Also test
	that we are not inside an output section statement.
	* ldlang.c (lang_size_sections): Set exp_dataseg_done on exit if
	not exp_dataseg_relro_adjust or exp_dataseg_adjust.  Don't set
	lang_final_phase_enum here.
	(lang_process): Set lang_final_phase_enum here.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/ChangeLog.diff?cvsroot=src&r1=1.2267&r2=1.2268
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/ldexp.c.diff?cvsroot=src&r1=1.89&r2=1.90
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/ldexp.h.diff?cvsroot=src&r1=1.25&r2=1.26
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/ldlang.c.diff?cvsroot=src&r1=1.356&r2=1.357
Comment 4 Alan Modra 2011-01-12 12:58:00 UTC
Fixed mainline