]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
PR25081, Discrepancy between VMA and LMA after ALIGN
authorAlan Modra <amodra@gmail.com>
Wed, 9 Oct 2019 10:55:25 +0000 (21:25 +1030)
committerAlan Modra <amodra@gmail.com>
Thu, 10 Oct 2019 22:41:55 +0000 (09:11 +1030)
The testcase in the PR has two empty output sections, .sec1 with an
ALIGN and symbol assignment, and .sec2 just with an empty input
section.  The symbol assignment results in .sec1 being kept, but
because it is empty this section doesn't take space from the memory
region as you might expect from the ALIGN.  Instead the next section
.sec2, has vma/lma as if .sec1 wasn't present.  However, .sec2 is
discarded and os->ignored set, which unfortunately meant that dot
wasn't set from .sec2 vma.  That in turn results in .sec2 lma being
set incorrectly.  That vma/lma difference is then propagated to
.sec3 where it is seen as an overlap.

PR 25081
* ldlang.c (lang_size_sections_1): Set lma from section vma
rather than dot.

(cherry picked from commit 8610e0fd93ea253f9beb9ebb6e50e8807ed83327)

ld/ChangeLog
ld/ldlang.c

index 3a553de7cfd6a28c8e2a0cb99d43db0122a414ab..f9bc13e5c998c3b6a4a3b71d8dff84e3dab64640 100644 (file)
@@ -1,3 +1,11 @@
+2019-10-11  Alan Modra  <amodra@gmail.com>
+
+       Apply from master
+       2019-10-09  Alan Modra  <amodra@gmail.com>
+       PR 25081
+       * ldlang.c (lang_size_sections_1): Set lma from section vma
+       rather than dot.
+
 2019-10-10  Szabolcs Nagy  <szabolcs.nagy@arm.com>
 
        Apply from master
index cb98982d45fdbdbf1193339ed7862d54200d358a..390546afae215670469b8c3352a21d19f06c93b6 100644 (file)
@@ -5500,7 +5500,7 @@ lang_size_sections_1
                    /* Otherwise, keep the same lma to vma relationship
                       as the previous section.  */
                    else
-                     lma = dot + last->lma - last->vma;
+                     lma = os->bfd_section->vma + last->lma - last->vma;
 
                    if (section_alignment > 0)
                      lma = align_power (lma, section_alignment);