aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bfd/ChangeLog7
-rw-r--r--bfd/elf32-avr.c5
-rw-r--r--ld/ChangeLog6
-rw-r--r--ld/testsuite/ld-avr/pr13402.d16
-rw-r--r--ld/testsuite/ld-avr/pr13402.s9
5 files changed, 42 insertions, 1 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 5f840a1..272da0c 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,10 @@
+2017-06-27 Senthil Kumar Selvaraj <senthil_kumar.selvaraj@atmel.com>
+
+ PR ld/13402
+ * elf32-avr.c (elf32_avr_adjust_diff_reloc_value): Adjust
+ reloc addend if necessary. Adjust diff only if
+ shrinked_insn_address < end_address.
+
2017-06-27 Alan Modra <amodra@gmail.com>
PR binutils/21665
diff --git a/bfd/elf32-avr.c b/bfd/elf32-avr.c
index f140aa7..830da28 100644
--- a/bfd/elf32-avr.c
+++ b/bfd/elf32-avr.c
@@ -1785,12 +1785,15 @@ elf32_avr_adjust_diff_reloc_value (bfd *abfd,
if (shrinked_insn_address >= start_address
- && shrinked_insn_address <= end_address)
+ && shrinked_insn_address < end_address)
{
/* Reduce the diff value by count bytes and write it back into section
contents. */
bfd_signed_vma new_diff = x < 0 ? x + count : x - count;
+ if (sym2_address > shrinked_insn_address)
+ irel->r_addend -= count;
+
switch (ELF32_R_TYPE (irel->r_info))
{
case R_AVR_DIFF8:
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 92d0003..fec44c9 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,9 @@
+2017-06-27 Senthil Kumar Selvaraj <senthil_kumar.selvaraj@atmel.com>
+
+ PR ld/13402
+ * testsuite/ld-avr/pr13402.d: New test.
+ * testsuite/ld-avr/pr13402.s: New test.
+
2017-06-27 Maciej W. Rozycki <macro@imgtec.com>
* testsuite/ld-mips-elf/mips-elf-flags.exp (good_combination):
diff --git a/ld/testsuite/ld-avr/pr13402.d b/ld/testsuite/ld-avr/pr13402.d
new file mode 100644
index 0000000..6663950
--- /dev/null
+++ b/ld/testsuite/ld-avr/pr13402.d
@@ -0,0 +1,16 @@
+#name: AVR fix broken sync between debug_line and code addresses
+#as: -mmcu=avrxmega2 -mlink-relax -gdwarf-2
+#ld: -mavrxmega2 --relax
+#source: pr13402.s
+#objdump: -S
+#target: avr-*-*
+
+#...
+main:
+call a
+ 0: 02 d0 rcall .+4 ; 0x6 <_etext>
+call b
+ 2: 01 d0 rcall .+2 ; 0x6 <_etext>
+call c
+ 4: 00 d0 rcall .+0 ; 0x6 <_etext>
+#...
diff --git a/ld/testsuite/ld-avr/pr13402.s b/ld/testsuite/ld-avr/pr13402.s
new file mode 100644
index 0000000..9539829
--- /dev/null
+++ b/ld/testsuite/ld-avr/pr13402.s
@@ -0,0 +1,9 @@
+.global main
+main:
+call a
+call b
+call c
+
+a:
+b:
+c: