From e23f1610289a9ba59e77cc214680d38aa7db9e13 Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Wed, 28 Nov 2007 13:04:18 +0000 Subject: [PATCH] * elf-m10300.c (mn10300_elf_relax_section): Extend previous fix to cover forward jumps. * ld-mn10300/i135409-5.s: New test case. Check for relaxation to a 16-bit backward jump instruction. * ld-mn10300/i135409-5.t: Linker script for the new test. * ld-mn10300/i135409-5.d: Expected disassembly of new test. * ld-mn10300/mn10300.exp: Run the new test. --- bfd/ChangeLog | 5 +++++ bfd/elf-m10300.c | 4 ++-- ld/testsuite/ChangeLog | 8 ++++++++ ld/testsuite/ld-mn10300/i135409-5.d | 7 +++++++ ld/testsuite/ld-mn10300/i135409-5.s | 8 ++++++++ ld/testsuite/ld-mn10300/i135409-5.t | 23 +++++++++++++++++++++++ ld/testsuite/ld-mn10300/mn10300.exp | 10 +++++++++- 7 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 ld/testsuite/ld-mn10300/i135409-5.d create mode 100644 ld/testsuite/ld-mn10300/i135409-5.s create mode 100644 ld/testsuite/ld-mn10300/i135409-5.t diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 8dc7003f3fe..e78868e500e 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,8 @@ +2007-11-28 Nick Clifton + + * elf-m10300.c (mn10300_elf_relax_section): Extend previous fix to + cover forward jumps. + 2007-11-21 Nick Clifton * elf-m10300.c (mn10300_elf_relax_section): Allow for alignment diff --git a/bfd/elf-m10300.c b/bfd/elf-m10300.c index 2695217f4eb..af2fff3c140 100644 --- a/bfd/elf-m10300.c +++ b/bfd/elf-m10300.c @@ -2736,7 +2736,7 @@ mn10300_elf_relax_section (bfd *abfd, bfd_vma aend = irel->r_offset; aend = BFD_ALIGN (aend, 1 << irel->r_addend); - adj = 2*adj - adj - 1; + adj = 2 * adj - adj - 1; /* Record the biggest adjustmnet. Skip any alignment at the end of our section. */ @@ -2963,7 +2963,7 @@ mn10300_elf_relax_section (bfd *abfd, able to relax. */ /* Account for jumps across alignment boundaries using align_gap_adjustment. */ - if (value < 0x8001 - align_gap_adjustment + if ((bfd_signed_vma) value < 0x8001 - (bfd_signed_vma) align_gap_adjustment && ((bfd_signed_vma) value > -0x8000 + (bfd_signed_vma) align_gap_adjustment)) { unsigned char code; diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index 7e8719ad93a..fc7671ab82e 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2007-11-28 Nick Clifton + + * ld-mn10300/i135409-5.s: New test case. Check for relaxation to + a 16-bit backward jump instruction. + * ld-mn10300/i135409-5.t: Linker script for the new test. + * ld-mn10300/i135409-5.d: Expected disassembly of new test. + * ld-mn10300/mn10300.exp: Run the new test. + 2007-11-21 Nick Clifton * ld-mn10300/i135409-4.s: New test case. Check for relaxation to diff --git a/ld/testsuite/ld-mn10300/i135409-5.d b/ld/testsuite/ld-mn10300/i135409-5.d new file mode 100644 index 00000000000..dbff7013725 --- /dev/null +++ b/ld/testsuite/ld-mn10300/i135409-5.d @@ -0,0 +1,7 @@ + +tmpdir/i135409-5.x: file format elf32-.* + +Disassembly of section .text: + +0+0700 <_start>: + 700:[ ]+cc 00 f9[ ]+jmp[ ]+0 \ diff --git a/ld/testsuite/ld-mn10300/i135409-5.s b/ld/testsuite/ld-mn10300/i135409-5.s new file mode 100644 index 00000000000..23897e8bdd6 --- /dev/null +++ b/ld/testsuite/ld-mn10300/i135409-5.s @@ -0,0 +1,8 @@ + .text + .global _start +_start: + jmp L001 + + .section .text1 +L001: + nop diff --git a/ld/testsuite/ld-mn10300/i135409-5.t b/ld/testsuite/ld-mn10300/i135409-5.t new file mode 100644 index 00000000000..8b42814603d --- /dev/null +++ b/ld/testsuite/ld-mn10300/i135409-5.t @@ -0,0 +1,23 @@ +SECTIONS +{ + . = 0x0; + .text1 : + { + *(.text1) + } + + . = 0x700; + .text : + { + *(.text) + } + . = 0x8100; + .bss : + { + *(.bss) + } + .data : + { + *(.data) + } +} diff --git a/ld/testsuite/ld-mn10300/mn10300.exp b/ld/testsuite/ld-mn10300/mn10300.exp index f67881f75af..edb1470db57 100644 --- a/ld/testsuite/ld-mn10300/mn10300.exp +++ b/ld/testsuite/ld-mn10300/mn10300.exp @@ -80,13 +80,21 @@ set mn10300_tests { "i135409-3.x" } { - "adjusting a 16 bit branch" + "adjusting a 16-bit forward branch" "-Ti135409-4.t -relax" "" { "i135409-4.s" } { {objdump -d i135409-4.d} } "i135409-4.x" } + { + "adjusting a 16-bit backward branch" + "-Ti135409-5.t -relax" + "" + { "i135409-5.s" } + { {objdump -d i135409-5.d} } + "i135409-5.x" + } } run_ld_link_tests $mn10300_tests -- 2.30.2