Check for overflow on R_ARM_PC24 relocs.
authorNick Clifton <nickc@redhat.com>
Wed, 11 Aug 1999 10:56:35 +0000 (10:56 +0000)
committerNick Clifton <nickc@redhat.com>
Wed, 11 Aug 1999 10:56:35 +0000 (10:56 +0000)
bfd/ChangeLog
bfd/elf32-arm.h

index 645b1187417c8ee6e7f25745e37702fe38b79cd4..13b8a665136f6b8d2c935eaa31bc738f298db3e1 100644 (file)
@@ -1,3 +1,8 @@
+1999-08-11  Robin Farine <advanc@dial.eunet.ch>
+
+       * elf32-arm.h (elf32_arm_final_link_relocate): Check for overflow
+       in R_ARM_PC24 relocs.
+
 Tue Aug 10 12:48:09 1999  Jeffrey A Law  (law@cygnus.com)
 
        * elf-hppa.h (elf_hppa_fake_sections): New function.
index 78ecae18b99c4bc21092e76b79057d3b893f2c79..6b2cabd3729f9fdbfb06eb747afc22ae31458d64 100644 (file)
@@ -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: