From 4e67d4ca2a172339a5899ae47a065e61d1a13e69 Mon Sep 17 00:00:00 2001 From: Daniel Gutson Date: Mon, 28 Dec 2009 18:55:16 +0000 Subject: [PATCH] bfd/ * elf32-arm.c (elf32_arm_final_link_relocate): limits fixed. ld/testsuite/ * ld-arm/arm-elf.exp (armelftests): New test case added. * ld-arm/reloc-boundaries.s: New file. * ld-arm/reloc-boundaries.d: New file. --- bfd/ChangeLog | 5 +++++ bfd/elf32-arm.c | 9 +++++++-- ld/testsuite/ChangeLog | 6 ++++++ ld/testsuite/ld-arm/arm-elf.exp | 5 ++++- ld/testsuite/ld-arm/reloc-boundaries.d | 6 ++++++ ld/testsuite/ld-arm/reloc-boundaries.s | 5 +++++ 6 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 ld/testsuite/ld-arm/reloc-boundaries.d create mode 100644 ld/testsuite/ld-arm/reloc-boundaries.s diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 6ccebdcbc0d..bce7915f4c9 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,8 @@ +2009-12-28 Daniel Gutson + + * elf32-arm.c (elf32_arm_final_link_relocate): limits + fixed. + 2009-12-28 Daniel Gutson * elf-attrs.c (_bfd_elf_merge_object_attributes): Error diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c index 1921780edb2..3e9759b8249 100644 --- a/bfd/elf32-arm.c +++ b/bfd/elf32-arm.c @@ -7212,7 +7212,11 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, case R_ARM_ABS8: value += addend; - if ((long) value > 0x7f || (long) value < -0x80) + + /* There is no way to tell whether the user intended to use a signed or + unsigned addend. When checking for overflow we accept either, + as specified by the AAELF. */ + if ((long) value > 0xff || (long) value < -0x80) return bfd_reloc_overflow; bfd_put_8 (input_bfd, value, hit_data); @@ -7221,7 +7225,8 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, case R_ARM_ABS16: value += addend; - if ((long) value > 0x7fff || (long) value < -0x8000) + /* See comment for R_ARM_ABS8. */ + if ((long) value > 0xffff || (long) value < -0x8000) return bfd_reloc_overflow; bfd_put_16 (input_bfd, value, hit_data); diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index 0193e8238cc..fff9ac62a35 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2009-12-28 Daniel Gutson + + * ld-arm/arm-elf.exp (armelftests): New test case added. + * ld-arm/reloc-boundaries.s: New file. + * ld-arm/reloc-boundaries.d: New file. + 2009-12-28 Daniel Gutson * ld-arm/arm-elf.exp: Run missing test diff --git a/ld/testsuite/ld-arm/arm-elf.exp b/ld/testsuite/ld-arm/arm-elf.exp index 18b288faa3c..ce8e9ee87fe 100644 --- a/ld/testsuite/ld-arm/arm-elf.exp +++ b/ld/testsuite/ld-arm/arm-elf.exp @@ -58,7 +58,7 @@ if { ![is_elf_format] || ![istarget "arm*-*-*"] } { return } -# List contains test-items with 3 items followed by 2 lists: +# List contains test-items with 3 items followed by 2 lists and one more item: # 0:name 1:ld options 2:assembler options # 3:filenames of assembler files 4: action and options. 5: name of output file @@ -236,6 +236,9 @@ set armelftests { {"callweak-2" "-static -T arm.ld" "" {callweak-2.s} {{objdump -dr callweak-2.d}} "callweak-2"} + {"Relocation boundaries" "-defsym x=0 -defsym y=0 -defsym _start=0" "" {reloc-boundaries.s} + {{objdump -s reloc-boundaries.d}} + "reloc-boundaries"} } run_ld_link_tests $armelftests diff --git a/ld/testsuite/ld-arm/reloc-boundaries.d b/ld/testsuite/ld-arm/reloc-boundaries.d new file mode 100644 index 00000000000..dcdefd95de3 --- /dev/null +++ b/ld/testsuite/ld-arm/reloc-boundaries.d @@ -0,0 +1,6 @@ + +[^:]*: file format elf32-(little|big)arm + +Contents of section .text: + 8000 80ff0080 ffff ...... +#... diff --git a/ld/testsuite/ld-arm/reloc-boundaries.s b/ld/testsuite/ld-arm/reloc-boundaries.s new file mode 100644 index 00000000000..7e65bc08611 --- /dev/null +++ b/ld/testsuite/ld-arm/reloc-boundaries.s @@ -0,0 +1,5 @@ +.syntax unified + .byte x -128 + .byte x +255 + .short y -32768 + .short y +65535 -- 2.30.2