[binutils-gdb] When computing section link order for a relocateable link, ignore section sizes.

Nick Clifton nickc@sourceware.org
Fri May 7 09:58:24 GMT 2021


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

commit d820a652a6d3ae3793207016c0c8cc78451eabd0
Author: Nick Clifton <nickc@redhat.com>
Date:   Fri May 7 10:57:47 2021 +0100

    When computing section link order for a relocateable link, ignore section sizes.
    
            * ldelfgen.c (compare_link_order): Ignore section size when
            performing a relocateable link.

Diff:
---
 ld/ChangeLog  |  5 +++++
 ld/ldelfgen.c | 15 +++++++++------
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/ld/ChangeLog b/ld/ChangeLog
index fa367d3e69c..998c403382e 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,8 @@
+2021-05-07  Nick Clifton  <nickc@redhat.com>
+
+	* ldelfgen.c (compare_link_order): Ignore section size when
+	performing a relocateable link.
+
 2021-05-07  Alan Modra  <amodra@gmail.com>
 
 	* ldexp.c (update_definedness): Don't return false for absolute
diff --git a/ld/ldelfgen.c b/ld/ldelfgen.c
index 495fa8451fc..c456d4751e1 100644
--- a/ld/ldelfgen.c
+++ b/ld/ldelfgen.c
@@ -171,12 +171,15 @@ compare_link_order (const void *a, const void *b)
   else if (apos > bpos)
     return 1;
 
-  /* The only way we should get matching LMAs is when the first of two
-     sections has zero size.  */
-  if (asec->size < bsec->size)
-    return -1;
-  else if (asec->size > bsec->size)
-    return 1;
+  if (! bfd_link_relocatable (&link_info))
+    {
+      /* The only way we should get matching LMAs is when
+	 the first of the two sections has zero size.  */
+      if (asec->size < bsec->size)
+	return -1;
+      else if (asec->size > bsec->size)
+	return 1;
+    }
 
   /* If they are both zero size then they almost certainly have the same
      VMA and thus are not ordered with respect to each other.  Test VMA


More information about the Binutils-cvs mailing list