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] More cases of missing TO_ADDR in ldlang.c


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

commit fc90c28021804df1f5bf7f1381d893470c64c417
Author: Alan Modra <amodra@gmail.com>
Date:   Thu Mar 31 15:02:14 2016 +1030

    More cases of missing TO_ADDR in ldlang.c
    
    and one extraneous occurrence.
    
    	* ldlang.c (TO_ADDR, TO_SIZE, opb_shift): Move earlier in file.
    	(lang_insert_orphan): Use TO_ADDR in __stop sym calculation.
    	(print_input_section): Don't use TO_ADDR when printing section
    	size.
    	(lang_size_sections_1): Use TO_ADDR in overlay lma calculation.
    	(lang_size_sections): Use TO_ADDR in relro end calculation.

Diff:
---
 ld/ChangeLog |  9 +++++++++
 ld/ldlang.c  | 26 ++++++++++++--------------
 2 files changed, 21 insertions(+), 14 deletions(-)

diff --git a/ld/ChangeLog b/ld/ChangeLog
index 711817c..f1f7b74 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,12 @@
+2016-03-31  Alan Modra  <amodra@gmail.com>
+
+	* ldlang.c (TO_ADDR, TO_SIZE, opb_shift): Move earlier in file.
+	(lang_insert_orphan): Use TO_ADDR in __stop sym calculation.
+	(print_input_section): Don't use TO_ADDR when printing section
+	size.
+	(lang_size_sections_1): Use TO_ADDR in overlay lma calculation.
+	(lang_size_sections): Use TO_ADDR in relro end calculation.
+
 2016-03-30  Andrew Burgess  <andrew.burgess@embecosm.com>
 
 	* testsuite/lib/ld-lib.exp (run_dump_test): Fix check of return
diff --git a/ld/ldlang.c b/ld/ldlang.c
index cb6aab6..9fca810 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -49,7 +49,13 @@
 #define offsetof(TYPE, MEMBER) ((size_t) & (((TYPE*) 0)->MEMBER))
 #endif
 
-/* Locals variables.  */
+/* Convert between addresses in bytes and sizes in octets.
+   For currently supported targets, octets_per_byte is always a power
+   of two, so we can use shifts.  */
+#define TO_ADDR(X) ((X) >> opb_shift)
+#define TO_SIZE(X) ((X) << opb_shift)
+
+/* Local variables.  */
 static struct obstack stat_obstack;
 static struct obstack map_obstack;
 
@@ -68,6 +74,7 @@ static lang_statement_list_type *stat_save[10];
 static lang_statement_list_type **stat_save_ptr = &stat_save[0];
 static struct unique_sections *unique_section_list;
 static struct asneeded_minfo *asneeded_list_head;
+static unsigned int opb_shift = 0;
 static bfd_boolean maybe_overlays = FALSE;
 
 /* Forward declarations.  */
@@ -1887,7 +1894,7 @@ lang_insert_orphan (asection *s,
 	 before sizing dynamic sections.  */
       dot = os->bfd_section->vma;
       exp_fold_tree (start_assign->exp, os->bfd_section, &dot);
-      dot += s->size;
+      dot += TO_ADDR (s->size);
       exp_fold_tree (stop_assign->exp, os->bfd_section, &dot);
     }
 
@@ -3209,15 +3216,6 @@ ldlang_open_output (lang_statement_union_type *statement)
     }
 }
 
-/* Convert between addresses in bytes and sizes in octets.
-   For currently supported targets, octets_per_byte is always a power
-   of two, so we can use shifts.  */
-#define TO_ADDR(X) ((X) >> opb_shift)
-#define TO_SIZE(X) ((X) << opb_shift)
-
-/* Support the above.  */
-static unsigned int opb_shift = 0;
-
 static void
 init_opb (void)
 {
@@ -4225,7 +4223,7 @@ print_input_section (asection *i, bfd_boolean is_discarded)
 	size = 0;
     }
 
-  minfo ("0x%V %W %B\n", addr, TO_ADDR (size), i->owner);
+  minfo ("0x%V %W %B\n", addr, size, i->owner);
 
   if (size != i->rawsize && i->rawsize != 0)
     {
@@ -5132,7 +5130,7 @@ lang_size_sections_1
 		    /* If this is an overlay, set the current lma to that
 		       at the end of the previous section.  */
 		    if (os->sectype == overlay_section)
-		      lma = last->lma + last->size;
+		      lma = last->lma + TO_ADDR (last->size);
 
 		    /* Otherwise, keep the same lma to vma relationship
 		       as the previous section.  */
@@ -5524,7 +5522,7 @@ lang_size_sections (bfd_boolean *relax, bfd_boolean check_regions)
 
 	    end = start = sec->vma;
 	    if (!IS_TBSS (sec))
-	      end += sec->size;
+	      end += TO_ADDR (sec->size);
 	    bump = desired_end - end;
 	    /* We'd like to increase START by BUMP, but we must heed
 	       alignment so the increase might be less than optimum.  */


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