aboutsummaryrefslogtreecommitdiff
path: root/binutils
diff options
context:
space:
mode:
Diffstat (limited to 'binutils')
-rw-r--r--binutils/ChangeLog7
-rw-r--r--binutils/objcopy.c11
2 files changed, 18 insertions, 0 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index cf0df39..058ebf3 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,10 @@
+2017-12-06 Jim Wilson <jimw@sifive.com>
+
+ PR 22465
+ * objcopy.c (copy_section): New local extra. If isection->lma not
+ exactly divisible by interleave, then bias from. Also adjust
+ osection->lma if necessary.
+
2017-12-06 Alan Modra <amodra@gmail.com>
PR 22552
diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index c45133b..f40b355 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -3898,6 +3898,15 @@ copy_section (bfd *ibfd, sec_ptr isection, void *obfdarg)
char *end = (char *) memhunk + size;
int i;
+ /* If the section address is not exactly divisible by the interleave,
+ then we must bias the from address. If the copy_byte is less than
+ the bias, then we must skip forward one interleave, and increment
+ the final lma. */
+ int extra = isection->lma % interleave;
+ from -= extra;
+ if (copy_byte < extra)
+ from += interleave;
+
for (; from < end; from += interleave)
for (i = 0; i < copy_width; i++)
{
@@ -3908,6 +3917,8 @@ copy_section (bfd *ibfd, sec_ptr isection, void *obfdarg)
size = (size + interleave - 1 - copy_byte) / interleave * copy_width;
osection->lma /= interleave;
+ if (copy_byte < extra)
+ osection->lma++;
}
if (!bfd_set_section_contents (obfd, osection, memhunk, 0, size))