From d820a652a6d3ae3793207016c0c8cc78451eabd0 Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Fri, 7 May 2021 10:57:47 +0100 Subject: [PATCH] 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. --- 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 + + * ldelfgen.c (compare_link_order): Ignore section size when + performing a relocateable link. + 2021-05-07 Alan Modra * 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 -- 2.39.5