From 230801466aa11b7c986db17c3f25f8df0390444e Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Wed, 11 Aug 1999 10:56:35 +0000 Subject: Check for overflow on R_ARM_PC24 relocs. --- bfd/elf32-arm.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'bfd/elf32-arm.h') diff --git a/bfd/elf32-arm.h b/bfd/elf32-arm.h index 78ecae1..6b2cabd 100644 --- a/bfd/elf32-arm.h +++ b/bfd/elf32-arm.h @@ -1223,10 +1223,16 @@ elf32_arm_final_link_relocate (howto, input_bfd, output_bfd, value -= 8; } } + + /* Perform a signed range check. */ + signed_addend = value; + signed_addend >>= howto->rightshift; + if (signed_addend > ((bfd_signed_vma)(howto->dst_mask >> 1)) + || signed_addend < - ((bfd_signed_vma) ((howto->dst_mask + 1) >> 1))) + return bfd_reloc_overflow; - value >>= howto->rightshift; - value &= howto->dst_mask; - value |= (bfd_get_32 (input_bfd, hit_data) & (~ howto->dst_mask)); + value = (signed_addend & howto->dst_mask) + | (bfd_get_32 (input_bfd, hit_data) & (~ howto->dst_mask)); break; case R_ARM_ABS32: -- cgit v1.1