This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH: Fix empty sections with alignment


This patch

http://sourceware.org/ml/binutils/2005-09/msg00215.html

breaks empty sections with alignment. The patch here works for me.


H.J.
----
2005-09-26  H.J. Lu  <hongjiu.lu@intel.com>

	* ldlang.c (lang_size_sections_1): Process alignment addr_tree
	later.

--- ld/ldlang.c.empty	2005-09-26 13:12:55.000000000 -0700
+++ ld/ldlang.c	2005-09-26 15:21:08.000000000 -0700
@@ -4044,7 +4044,9 @@ lang_size_sections_1
 	    lang_output_section_statement_type *os;
 
 	    os = &s->output_section_statement;
-	    if (os->addr_tree != NULL)
+	    if (os->addr_tree != NULL
+		&& !(os->addr_tree->type.node_class == etree_unary
+		     && os->addr_tree->type.node_code == ALIGN_K))
 	      {
 		os->processed = FALSE;
 		exp_fold_tree (os->addr_tree, bfd_abs_section_ptr, &dot);
@@ -4159,6 +4161,22 @@ lang_size_sections_1
 				 os->name, (unsigned long) (newdot - savedot));
 		      }
 		  }
+		else if (os->addr_tree->type.node_class == etree_unary
+			 && os->addr_tree->type.node_code == ALIGN_K)
+		  {
+		    newdot = dot;
+		    os->processed = FALSE;
+		    exp_fold_tree (os->addr_tree, bfd_abs_section_ptr,
+				   &newdot);
+
+		    if (!expld.result.valid_p
+			&& expld.phase != lang_mark_phase_enum)
+		      einfo (_("%F%S: non constant or forward reference"
+			       " address expression for section %s\n"),
+			     os->name);
+
+		    newdot = expld.result.value + expld.result.section->vma;
+		  }
 
 		/* The section starts here.
 		   First, align to what the section needs.  */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]