This is the mail archive of the binutils-cvs@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]

[binutils-gdb] PR23648, Symbols based on MEMORY regions confuse --gc-sections


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

commit 7f0cfc6eb8bbead5c9a1ff3a8dec11d93304f5ad
Author: Alan Modra <amodra@gmail.com>
Date:   Wed Sep 19 13:22:43 2018 +0930

    PR23648, Symbols based on MEMORY regions confuse --gc-sections
    
    Running lang_do_memory_regions earlier seems a reasonable solution to
    gaining better values for symbols prior to lang_gc_sections.
    
    	PR ld/23648
    	* ldlang.c (lang_process): Move lang_do_memory_regions earlier.
    	Comment on lang_do_assignments call.
    	* ldgram.y (origin_exp): Don't assign region->current.

Diff:
---
 ld/ChangeLog |  7 +++++++
 ld/ldgram.y  |  1 -
 ld/ldlang.c  | 12 ++++++++----
 3 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/ld/ChangeLog b/ld/ChangeLog
index bf5441f..a31c3f3 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,5 +1,12 @@
 2018-09-19  Alan Modra  <amodra@gmail.com>
 
+	PR ld/23648
+	* ldlang.c (lang_process): Move lang_do_memory_regions earlier.
+	Comment on lang_do_assignments call.
+	* ldgram.y (origin_exp): Don't assign region->current.
+
+2018-09-19  Alan Modra  <amodra@gmail.com>
+
 	* ldmain.c (add_archive_element): Handle auto-inport symbols
 	when printing map.
 
diff --git a/ld/ldgram.y b/ld/ldgram.y
index cba0486..81ed85e 100644
--- a/ld/ldgram.y
+++ b/ld/ldgram.y
@@ -819,7 +819,6 @@ origin_spec:
 	ORIGIN '=' mustbe_exp
 		{
 		  region->origin_exp = $3;
-		  region->current = region->origin;
 		}
 	;
 
diff --git a/ld/ldlang.c b/ld/ldlang.c
index d644b56..1ac5eb1 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -7180,6 +7180,9 @@ lang_process (void)
   current_target = default_target;
   lang_statement_iteration++;
   open_input_bfds (statement_list.head, OPEN_BFD_NORMAL);
+  /* open_input_bfds also handles assignments, so we can give values
+     to symbolic origin/length now.  */
+  lang_do_memory_regions ();
 
 #ifdef ENABLE_PLUGINS
   if (link_info.lto_plugin_active)
@@ -7322,8 +7325,6 @@ lang_process (void)
   /* PR 13683: We must rerun the assignments prior to running garbage
      collection in order to make sure that all symbol aliases are resolved.  */
   lang_do_assignments (lang_mark_phase_enum);
-
-  lang_do_memory_regions();
   expld.phase = lang_first_phase_enum;
 
   /* Size up the common data.  */
@@ -7408,8 +7409,11 @@ lang_process (void)
   /* Fix any __start, __stop, .startof. or .sizeof. symbols.  */
   lang_finalize_start_stop ();
 
-  /* Do all the assignments, now that we know the final resting places
-     of all the symbols.  */
+  /* Do all the assignments again, to report errors.  Assignment
+     statements are processed multiple times, updating symbols; In
+     open_input_bfds, lang_do_assignments, and lang_size_sections.
+     Since lang_relax_sections calls lang_do_assignments, symbols are
+     also updated in ldemul_after_allocation.  */
   lang_do_assignments (lang_final_phase_enum);
 
   ldemul_finish ();


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