This is the mail archive of the
binutils-cvs@sourceware.org
mailing list for the binutils project.
[binutils-gdb/binutils-2_26-branch] Fix PR ld/20254
- From: Senthil Kumar Selvaraj <saaadhu at sourceware dot org>
- To: bfd-cvs at sourceware dot org
- Date: 15 Jun 2016 07:29:08 -0000
- Subject: [binutils-gdb/binutils-2_26-branch] Fix PR ld/20254
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=30d923a46a5b6536a2a670be3b4c8209745b308d
commit 30d923a46a5b6536a2a670be3b4c8209745b308d
Author: Senthil Kumar Selvaraj <senthil_kumar.selvaraj@atmel.com>
Date: Wed Jun 15 12:25:30 2016 +0530
Fix PR ld/20254
This patch fixes another edge case related to alignment property
records - reloc offsets adjacent to property record offsets were not
getting adjusted during relaxation.
bfd/
PR ld/20254
* elf32-avr.c (elf32_avr_relax_delete_bytes): Adjust reloc
offsets until reloc_toaddr.
ld/
PR ld/20254
* testsuite/ld-avr/avr-prop-6.d: New test.
* testsuite/ld-avr/avr-prop-6.s: New test.
Diff:
---
bfd/ChangeLog | 9 +++++++++
bfd/elf32-avr.c | 15 +++++++++++++--
ld/ChangeLog | 9 +++++++++
ld/testsuite/ld-avr/avr-prop-6.d | 14 ++++++++++++++
ld/testsuite/ld-avr/avr-prop-6.s | 9 +++++++++
5 files changed, 54 insertions(+), 2 deletions(-)
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 0d9af6c..36b10e9 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,12 @@
+2016-06-14 Senthil Kumar Selvaraj <senthil_kumar.selvaraj@atmel.com>
+
+ Backport from master
+ 2016-06-14 Senthil Kumar Selvaraj <senthil_kumar.selvaraj@atmel.com>
+
+ PR ld/20254
+ * elf32-avr.c (elf32_avr_relax_delete_bytes): Adjust reloc
+ offsets until reloc_toaddr.
+
2016-06-14 H.J. Lu <hongjiu.lu@intel.com>
Backport from master
diff --git a/bfd/elf32-avr.c b/bfd/elf32-avr.c
index 422c4ac..d55e093 100644
--- a/bfd/elf32-avr.c
+++ b/bfd/elf32-avr.c
@@ -1826,7 +1826,7 @@ elf32_avr_relax_delete_bytes (bfd *abfd,
Elf_Internal_Rela *irel, *irelend;
Elf_Internal_Sym *isym;
Elf_Internal_Sym *isymbuf = NULL;
- bfd_vma toaddr;
+ bfd_vma toaddr, reloc_toaddr;
struct elf_link_hash_entry **sym_hashes;
struct elf_link_hash_entry **end_hashes;
unsigned int symcount;
@@ -1863,6 +1863,17 @@ elf32_avr_relax_delete_bytes (bfd *abfd,
}
}
+ /* We need to look at all relocs with offsets less than toaddr. prop
+ records handling adjusts toaddr downwards to avoid moving syms at the
+ address of the property record, but all relocs with offsets between addr
+ and the current value of toaddr need to have their offsets adjusted.
+ Assume addr = 0, toaddr = 4 and count = 2. After prop records handling,
+ toaddr becomes 2, but relocs with offsets 2 and 3 still need to be
+ adjusted (to 0 and 1 respectively), as the first 2 bytes are now gone.
+ So record the current value of toaddr here, and use it when adjusting
+ reloc offsets. */
+ reloc_toaddr = toaddr;
+
irel = elf_section_data (sec)->relocs;
irelend = irel + sec->reloc_count;
@@ -1921,7 +1932,7 @@ elf32_avr_relax_delete_bytes (bfd *abfd,
/* Get the new reloc address. */
if ((irel->r_offset > addr
- && irel->r_offset < toaddr))
+ && irel->r_offset < reloc_toaddr))
{
if (debug_relax)
printf ("Relocation at address 0x%x needs to be moved.\n"
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 57c735d..95fba97 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,12 @@
+2016-06-14 Senthil Kumar Selvaraj <senthil_kumar.selvaraj@atmel.com>
+
+ Backport from master
+ 2016-06-14 Senthil Kumar Selvaraj <senthil_kumar.selvaraj@atmel.com>
+
+ PR ld/20254
+ * testsuite/ld-avr/avr-prop-6.d: New test.
+ * testsuite/ld-avr/avr-prop-6.s: New test.
+
2016-06-14 H.J. Lu <hongjiu.lu@intel.com>
Backport from master
diff --git a/ld/testsuite/ld-avr/avr-prop-6.d b/ld/testsuite/ld-avr/avr-prop-6.d
new file mode 100644
index 0000000..1bf8aa1
--- /dev/null
+++ b/ld/testsuite/ld-avr/avr-prop-6.d
@@ -0,0 +1,14 @@
+#name: AVR .avr.prop, single .align sym at end of section test.
+#as: -mavrxmega2 -mlink-relax
+#ld: -mavrxmega2 --relax
+#source: avr-prop-6.s
+#objdump: -S
+#target: avr-*-*
+
+#...
+ 0: 00 c0 rjmp .+0 ; 0x2 <dest>
+
+00000002 <dest>:
+ 2: 00 00 nop
+ 4: fe cf rjmp .-4 ; 0x2 <dest>
+#...
diff --git a/ld/testsuite/ld-avr/avr-prop-6.s b/ld/testsuite/ld-avr/avr-prop-6.s
new file mode 100644
index 0000000..4aa3e67
--- /dev/null
+++ b/ld/testsuite/ld-avr/avr-prop-6.s
@@ -0,0 +1,9 @@
+ .text
+ .global _start, dest
+_start:
+ jmp dest
+ .align 1
+dest:
+ nop
+ rjmp dest
+