* bfd-in.h (bfd_get_section_limit): Define.
authorAlan Modra <amodra@gmail.com>
Tue, 29 Jun 2004 13:46:34 +0000 (13:46 +0000)
committerAlan Modra <amodra@gmail.com>
Tue, 29 Jun 2004 13:46:34 +0000 (13:46 +0000)
* reloc.c (bfd_perform_relocation, bfd_install_relocation)
(_bfd_final_link_relocate): Use bfd_get_section_limit.
* aout-tic30.c (tic30_aout_final_link_relocate): Likewise.
* coff-arm.c (coff_arm_relocate_section): Likewise.
* coff-mips.c (mips_refhi_reloc, mips_gprel_reloc): Likewise.
* cpu-ns32k.c (do_ns32k_reloc): Likewise.
(bfd_ns32k_final_link_relocate): Likewise.
* elf32-d30v.c (bfd_elf_d30v_reloc, bfd_elf_d30v_reloc_21): Likwise.
* elf32-dlx.c (_bfd_dlx_elf_hi16_reloc): Likewise.
* elf32-i860.c (i860_howto_pc26_reloc, i860_howto_pc16_reloc)
(i860_howto_highadj_reloc, i860_howto_splitn_reloc): Likewise.
* elf32-m32r.c (m32r_elf_do_10_pcrel_reloc, m32r_elf_hi16_reloc)
(m32r_elf_generic_reloc, m32r_elf_relocate_section): Likewise.
* elf32-m68hc1x.c (m68hc11_elf_special_reloc): Likewise.
* elf32-mips.c (gprel32_with_gp, mips16_gprel_reloc): Likewise.
* elf32-or32.c (or32_elf_consth_reloc): Likewise.
* elf32-ppc.c (ppc_elf_addr16_ha_reloc): Likewise.
* elf32-s390.c (s390_elf_ldisp_reloc): Likewise.
* elf32-sh.c (sh_elf_reloc_loop): Likewise.
* elf32-sparc.c (sparc_elf_wdisp16_reloc): Likewise.
(sparc_elf_hix22_reloc, sparc_elf_lox10_reloc): Likwise.
* elf32-v850.c (v850_elf_reloc): Likewise.
* elf32-xstormy16.c (xstormy16_elf_24_reloc): Likewise.
* elf32-xtensa.c (bfd_elf_xtensa_reloc): Likewise.
* elf64-alpha.c (elf64_alpha_reloc_gpdisp): Likewise.
* elf64-mips.c (mips_elf64_gprel32_reloc)
(mips16_gprel_reloc): Likewise.
* elf64-mmix.c (mmix_elf_reloc): Likewise.
* elf64-s390.c (s390_elf_ldisp_reloc): Likewise.
* elf64-sparc.c (init_insn_reloc): Likewise.
* elfn32-mips.c (gprel32_with_gp, mips16_gprel_reloc): Likewise.
* elfxx-mips.c (_bfd_mips_elf_gprel16_with_gp)
(_bfd_mips_elf_hi16_reloc, _bfd_mips_elf_lo16_reloc)
(_bfd_mips_elf_generic_reloc): Likewise.
* bfd-in2.h: Regenerate.

29 files changed:
bfd/ChangeLog
bfd/aout-tic30.c
bfd/bfd-in.h
bfd/bfd-in2.h
bfd/coff-arm.c
bfd/coff-mips.c
bfd/cpu-ns32k.c
bfd/elf32-d30v.c
bfd/elf32-dlx.c
bfd/elf32-i860.c
bfd/elf32-m32r.c
bfd/elf32-m68hc1x.c
bfd/elf32-mips.c
bfd/elf32-or32.c
bfd/elf32-ppc.c
bfd/elf32-s390.c
bfd/elf32-sh.c
bfd/elf32-sparc.c
bfd/elf32-v850.c
bfd/elf32-xstormy16.c
bfd/elf32-xtensa.c
bfd/elf64-alpha.c
bfd/elf64-mips.c
bfd/elf64-mmix.c
bfd/elf64-s390.c
bfd/elf64-sparc.c
bfd/elfn32-mips.c
bfd/elfxx-mips.c
bfd/reloc.c

index 9fff848b7bed3e3e582cba43aa4522ab52904a19..3767818320e3d3ad991bf9239d776b4278acb398 100644 (file)
@@ -1,3 +1,42 @@
+2004-06-29  Alan Modra  <amodra@bigpond.net.au>
+
+       * bfd-in.h (bfd_get_section_limit): Define.
+       * reloc.c (bfd_perform_relocation, bfd_install_relocation) 
+       (_bfd_final_link_relocate): Use bfd_get_section_limit.
+       * aout-tic30.c (tic30_aout_final_link_relocate): Likewise.
+       * coff-arm.c (coff_arm_relocate_section): Likewise.
+       * coff-mips.c (mips_refhi_reloc, mips_gprel_reloc): Likewise.
+       * cpu-ns32k.c (do_ns32k_reloc): Likewise.
+       (bfd_ns32k_final_link_relocate): Likewise.
+       * elf32-d30v.c (bfd_elf_d30v_reloc, bfd_elf_d30v_reloc_21): Likwise.
+       * elf32-dlx.c (_bfd_dlx_elf_hi16_reloc): Likewise.
+       * elf32-i860.c (i860_howto_pc26_reloc, i860_howto_pc16_reloc) 
+       (i860_howto_highadj_reloc, i860_howto_splitn_reloc): Likewise.
+       * elf32-m32r.c (m32r_elf_do_10_pcrel_reloc, m32r_elf_hi16_reloc) 
+       (m32r_elf_generic_reloc, m32r_elf_relocate_section): Likewise.
+       * elf32-m68hc1x.c (m68hc11_elf_special_reloc): Likewise.
+       * elf32-mips.c (gprel32_with_gp, mips16_gprel_reloc): Likewise.
+       * elf32-or32.c (or32_elf_consth_reloc): Likewise.
+       * elf32-ppc.c (ppc_elf_addr16_ha_reloc): Likewise.
+       * elf32-s390.c (s390_elf_ldisp_reloc): Likewise.
+       * elf32-sh.c (sh_elf_reloc_loop): Likewise.
+       * elf32-sparc.c (sparc_elf_wdisp16_reloc): Likewise.
+       (sparc_elf_hix22_reloc, sparc_elf_lox10_reloc): Likwise.
+       * elf32-v850.c (v850_elf_reloc): Likewise.
+       * elf32-xstormy16.c (xstormy16_elf_24_reloc): Likewise.
+       * elf32-xtensa.c (bfd_elf_xtensa_reloc): Likewise.
+       * elf64-alpha.c (elf64_alpha_reloc_gpdisp): Likewise.
+       * elf64-mips.c (mips_elf64_gprel32_reloc)
+       (mips16_gprel_reloc): Likewise.
+       * elf64-mmix.c (mmix_elf_reloc): Likewise.
+       * elf64-s390.c (s390_elf_ldisp_reloc): Likewise.
+       * elf64-sparc.c (init_insn_reloc): Likewise.
+       * elfn32-mips.c (gprel32_with_gp, mips16_gprel_reloc): Likewise.
+       * elfxx-mips.c (_bfd_mips_elf_gprel16_with_gp) 
+       (_bfd_mips_elf_hi16_reloc, _bfd_mips_elf_lo16_reloc) 
+       (_bfd_mips_elf_generic_reloc): Likewise.
+       * bfd-in2.h: Regenerate.
+
 2004-06-28  Alan Modra  <amodra@bigpond.net.au>
 
        * bfd-in.h (struct stab_info): Move from stabs.c.
index 81ee1b6d5c35d6e3083e50c469f3cbbd1a124328..cf574ff04347da5c41205a6635088bd086bf5240 100644 (file)
@@ -402,10 +402,8 @@ tic30_aout_final_link_relocate (howto, input_bfd, input_section, contents,
      bfd_vma addend;
 {
   bfd_vma relocation;
-  bfd_size_type sz;
 
-  sz = input_section->rawsize ? input_section->rawsize : input_section->size;
-  if (address > sz)
+  if (address > bfd_get_section_limit (input_bfd, input_section))
     return bfd_reloc_outofrange;
 
   relocation = value + addend;
index b3eb2939b00360938fa39814ffd6b437e946cda4..97296c88898f6648eef3c9ab5a086ec25b80290f 100644 (file)
@@ -321,6 +321,10 @@ typedef struct bfd_section *sec_ptr;
 #define bfd_set_section_vma(bfd, ptr, val) (((ptr)->vma = (ptr)->lma = (val)), ((ptr)->user_set_vma = TRUE), TRUE)
 #define bfd_set_section_alignment(bfd, ptr, val) (((ptr)->alignment_power = (val)),TRUE)
 #define bfd_set_section_userdata(bfd, ptr, val) (((ptr)->userdata = (val)),TRUE)
+/* Find the address one past the end of SEC.  */
+#define bfd_get_section_limit(bfd, sec) \
+  (((sec)->rawsize ? (sec)->rawsize : (sec)->size) \
+   / bfd_octets_per_byte (bfd))
 
 typedef struct stat stat_type;
 \f
index 65a4a10213ec15f42c8258c3d3fdf67a86f44e04..a3ace1138ad618d0c77026d62d6c27311cd43c6d 100644 (file)
@@ -328,6 +328,10 @@ typedef struct bfd_section *sec_ptr;
 #define bfd_set_section_vma(bfd, ptr, val) (((ptr)->vma = (ptr)->lma = (val)), ((ptr)->user_set_vma = TRUE), TRUE)
 #define bfd_set_section_alignment(bfd, ptr, val) (((ptr)->alignment_power = (val)),TRUE)
 #define bfd_set_section_userdata(bfd, ptr, val) (((ptr)->userdata = (val)),TRUE)
+/* Find the address one past the end of SEC.  */
+#define bfd_get_section_limit(bfd, sec) \
+  (((sec)->rawsize ? (sec)->rawsize : (sec)->size) \
+   / bfd_octets_per_byte (bfd))
 
 typedef struct stat stat_type;
 \f
index eb7e038ae518231b79ac564bf7e4c2062a1f4a2a..3f3ab445673010186c432a47cfac11be0674b4e9 100644 (file)
@@ -1202,6 +1202,7 @@ coff_arm_relocate_section (output_bfd, info, input_bfd, input_section,
 {
   struct internal_reloc * rel;
   struct internal_reloc * relend;
+  bfd_vma high_address = bfd_get_section_limit (input_bfd, input_section);
 
   rel = relocs;
   relend = rel + input_section->reloc_count;
@@ -1635,12 +1636,8 @@ coff_arm_relocate_section (output_bfd, info, input_bfd, input_section,
              code.  */
 
           bfd_vma address = rel->r_vaddr - input_section->vma;
-         bfd_size_type sz;
 
-         sz = (input_section->rawsize
-               ? input_section->rawsize
-               : input_section->size);
-          if (address > sz)
+         if (address > high_address)
            rstat = bfd_reloc_outofrange;
           else
             {
index ca3376d9fa05c791ae6dfc50636dc72994b454f2..f351eb1409b6c85a12d5a3e656a6f3f75d613c6f 100644 (file)
@@ -473,7 +473,6 @@ mips_refhi_reloc (abfd,
 {
   bfd_reloc_status_type ret;
   bfd_vma relocation;
-  bfd_size_type sz;
   struct mips_hi *n;
 
   /* If we're relocating, and this an external symbol, we don't want
@@ -500,8 +499,7 @@ mips_refhi_reloc (abfd,
   relocation += symbol->section->output_offset;
   relocation += reloc_entry->addend;
 
-  sz = input_section->rawsize ? input_section->rawsize : input_section->size;
-  if (reloc_entry->address > sz)
+  if (reloc_entry->address > bfd_get_section_limit (abfd, input_section))
     return bfd_reloc_outofrange;
 
   /* Save the information, and let REFLO do the actual relocation.  */
@@ -610,7 +608,6 @@ mips_gprel_reloc (abfd,
   bfd_boolean relocatable;
   bfd_vma gp;
   bfd_vma relocation;
-  bfd_size_type sz;
   unsigned long val;
   unsigned long insn;
 
@@ -700,8 +697,7 @@ mips_gprel_reloc (abfd,
   relocation += symbol->section->output_section->vma;
   relocation += symbol->section->output_offset;
 
-  sz = input_section->rawsize ? input_section->rawsize : input_section->size;
-  if (reloc_entry->address > sz)
+  if (reloc_entry->address > bfd_get_section_limit (abfd, input_section))
     return bfd_reloc_outofrange;
 
   insn = bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address);
index 074eb70a62ccc09845c2524d844b3f67e66559c3..0cd358da967224b8cf65f07ca1959337d0be2bb2 100644 (file)
@@ -170,7 +170,6 @@ do_ns32k_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd,
   bfd_vma relocation;
   bfd_reloc_status_type flag = bfd_reloc_ok;
   bfd_size_type addr = reloc_entry->address;
-  bfd_size_type sz;
   bfd_vma output_base = 0;
   reloc_howto_type *howto = reloc_entry->howto;
   asection *reloc_target_output_section;
@@ -192,8 +191,7 @@ do_ns32k_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd,
     flag = bfd_reloc_undefined;
 
   /* Is the address of the relocation really within the section?  */
-  sz = input_section->rawsize ? input_section->rawsize : input_section->size;
-  if (reloc_entry->address > sz)
+  if (reloc_entry->address > bfd_get_section_limit (abfd, input_section))
     return bfd_reloc_outofrange;
 
   /* Work out which section the relocation is targeted at and the
@@ -804,11 +802,9 @@ _bfd_ns32k_final_link_relocate (howto, input_bfd, input_section, contents,
      bfd_vma addend;
 {
   bfd_vma relocation;
-  bfd_size_type sz;
 
   /* Sanity check the address.  */
-  sz = input_section->rawsize ? input_section->rawsize : input_section->size;
-  if (address > sz)
+  if (address > bfd_get_section_limit (input_bfd, input_section))
     return bfd_reloc_outofrange;
 
   /* This function assumes that we are dealing with a basic relocation
index ffce4988d84b965c3069e72b11ab7bb3bf75aebb..6a84522adfd9ce7746d3a589572f08cf6da12f89 100644 (file)
@@ -266,7 +266,6 @@ bfd_elf_d30v_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd,
   bfd_reloc_status_type r;
   asection *reloc_target_output_section;
   bfd_size_type addr = reloc_entry->address;
-  bfd_size_type sz;
   bfd_reloc_status_type flag = bfd_reloc_ok;
   bfd_vma output_base = 0;
   reloc_howto_type *howto = reloc_entry->howto;
@@ -291,8 +290,7 @@ bfd_elf_d30v_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd,
     flag = bfd_reloc_undefined;
 
   /* Is the address of the relocation really within the section?  */
-  sz = input_section->rawsize ? input_section->rawsize : input_section->size;
-  if (reloc_entry->address > sz)
+  if (reloc_entry->address > bfd_get_section_limit (abfd, input_section))
     return bfd_reloc_outofrange;
 
   /* Work out which section the relocation is targeted at and the
@@ -377,7 +375,6 @@ bfd_elf_d30v_reloc_21 (abfd, reloc_entry, symbol, data, input_section, output_bf
   bfd_reloc_status_type r;
   asection *reloc_target_output_section;
   bfd_size_type addr = reloc_entry->address;
-  bfd_size_type sz;
   bfd_reloc_status_type flag = bfd_reloc_ok;
   bfd_vma output_base = 0;
   reloc_howto_type *howto = reloc_entry->howto;
@@ -402,8 +399,7 @@ bfd_elf_d30v_reloc_21 (abfd, reloc_entry, symbol, data, input_section, output_bf
     flag = bfd_reloc_undefined;
 
   /* Is the address of the relocation really within the section?  */
-  sz = input_section->rawsize ? input_section->rawsize : input_section->size;
-  if (reloc_entry->address > sz)
+  if (reloc_entry->address > bfd_get_section_limit (abfd, input_section))
     return bfd_reloc_outofrange;
 
   /* Work out which section the relocation is targeted at and the
index 2301dae451be1064526e5e364e66e25ef5582af7..f8a394646b649d6193d8cca66f3bec202f5f31ad 100644 (file)
@@ -257,7 +257,6 @@ _bfd_dlx_elf_hi16_reloc (abfd, reloc_entry, symbol, data,
 {
   bfd_reloc_status_type ret;
   bfd_vma relocation;
-  bfd_size_type sz;
 
   /* If the skip flag is set then we simply do the generic relocating, this
      is more of a hack for dlx gas/gld, so we do not need to do the %hi/%lo
@@ -308,8 +307,7 @@ _bfd_dlx_elf_hi16_reloc (abfd, reloc_entry, symbol, data,
   relocation += reloc_entry->addend;
   relocation += bfd_get_16 (abfd, (bfd_byte *)data + reloc_entry->address);
 
-  sz = input_section->rawsize ? input_section->rawsize : input_section->size;
-  if (reloc_entry->address > sz)
+  if (reloc_entry->address > bfd_get_section_limit (abfd, input_section))
     return bfd_reloc_outofrange;
 
 #if 0
index 863d7aecbe1e8078df8e30a4f2a94ab18d983b37..010ac2e76196ff1fb678ff148aa3751262027990 100644 (file)
@@ -38,7 +38,6 @@ i860_howto_pc26_reloc (bfd *abfd ATTRIBUTE_UNUSED,
 {
   bfd_vma insn;
   bfd_vma relocation;
-  bfd_size_type sz;
   bfd_byte *addr;
 
   if (output_bfd != NULL
@@ -64,8 +63,7 @@ i860_howto_pc26_reloc (bfd *abfd ATTRIBUTE_UNUSED,
   relocation += symbol->section->output_offset;
   relocation += reloc_entry->addend;
 
-  sz = input_section->rawsize ? input_section->rawsize : input_section->size;
-  if (reloc_entry->address > sz)
+  if (reloc_entry->address > bfd_get_section_limit (abfd, input_section))
     return bfd_reloc_outofrange;
 
   /* Adjust for PC-relative relocation.  */
@@ -103,7 +101,6 @@ i860_howto_pc16_reloc (bfd *abfd,
 {
   bfd_vma insn;
   bfd_vma relocation;
-  bfd_size_type sz;
   bfd_byte *addr;
 
   if (output_bfd != NULL
@@ -129,8 +126,7 @@ i860_howto_pc16_reloc (bfd *abfd,
   relocation += symbol->section->output_offset;
   relocation += reloc_entry->addend;
 
-  sz = input_section->rawsize ? input_section->rawsize : input_section->size;
-  if (reloc_entry->address > sz)
+  if (reloc_entry->address > bfd_get_section_limit (abfd, input_section))
     return bfd_reloc_outofrange;
 
   /* Adjust for PC-relative relocation.  */
@@ -169,7 +165,6 @@ i860_howto_highadj_reloc (bfd *abfd,
 {
   bfd_vma insn;
   bfd_vma relocation;
-  bfd_size_type sz;
   bfd_byte *addr;
 
   if (output_bfd != NULL
@@ -196,8 +191,7 @@ i860_howto_highadj_reloc (bfd *abfd,
   relocation += reloc_entry->addend;
   relocation += 0x8000;
 
-  sz = input_section->rawsize ? input_section->rawsize : input_section->size;
-  if (reloc_entry->address > sz)
+  if (reloc_entry->address > bfd_get_section_limit (abfd, input_section))
     return bfd_reloc_outofrange;
 
   addr = (bfd_byte *) data + reloc_entry->address;
@@ -224,7 +218,6 @@ i860_howto_splitn_reloc (bfd *abfd,
 {
   bfd_vma insn;
   bfd_vma relocation;
-  bfd_size_type sz;
   bfd_byte *addr;
 
   if (output_bfd != NULL
@@ -250,8 +243,7 @@ i860_howto_splitn_reloc (bfd *abfd,
   relocation += symbol->section->output_offset;
   relocation += reloc_entry->addend;
 
-  sz = input_section->rawsize ? input_section->rawsize : input_section->size;
-  if (reloc_entry->address > sz)
+  if (reloc_entry->address > bfd_get_section_limit (abfd, input_section))
     return bfd_reloc_outofrange;
 
   addr = (bfd_byte *) data + reloc_entry->address;
index c6bc2bee843487af5c45fbceb96fd9a6c77caf67..6776a622c8be20500dda1e96f6ac4199aee05312 100644 (file)
@@ -901,13 +901,11 @@ m32r_elf_do_10_pcrel_reloc (abfd, howto, input_section, data, offset,
      bfd_vma addend;
 {
   bfd_signed_vma relocation;
-  bfd_size_type sz;
   unsigned long x;
   bfd_reloc_status_type status;
 
   /* Sanity check the address (offset in section).  */
-  sz = input_section->rawsize ? input_section->rawsize : input_section->size;
-  if (offset > sz)
+  if (offset > bfd_get_section_limit (abfd, input_section))
     return bfd_reloc_outofrange;
 
   relocation = symbol_value + addend;
@@ -972,7 +970,6 @@ m32r_elf_hi16_reloc (abfd, reloc_entry, symbol, data,
 {
   bfd_reloc_status_type ret;
   bfd_vma relocation;
-  bfd_size_type sz;
   struct m32r_hi16 *n;
 
   /* This part is from bfd_elf_generic_reloc.
@@ -987,8 +984,7 @@ m32r_elf_hi16_reloc (abfd, reloc_entry, symbol, data,
     }
 
   /* Sanity check the address (offset in section).  */
-  sz = input_section->rawsize ? input_section->rawsize : input_section->size;
-  if (reloc_entry->address > sz)
+  if (reloc_entry->address > bfd_get_section_limit (abfd, input_section))
     return bfd_reloc_outofrange;
 
   ret = bfd_reloc_ok;
@@ -1141,7 +1137,6 @@ m32r_elf_generic_reloc (input_bfd, reloc_entry, symbol, data,
 {
   bfd_reloc_status_type ret;
   bfd_vma relocation;
-  bfd_size_type sz;
   bfd_byte *inplace_address;
 
   /* This part is from bfd_elf_generic_reloc.
@@ -1162,8 +1157,7 @@ m32r_elf_generic_reloc (input_bfd, reloc_entry, symbol, data,
      a section relative addend which is wrong.  */
 
   /* Sanity check the address (offset in section).  */
-  sz = input_section->rawsize ? input_section->rawsize : input_section->size;
-  if (reloc_entry->address > sz)
+  if (reloc_entry->address > bfd_get_section_limit (input_bfd, input_section))
     return bfd_reloc_outofrange;
 
   ret = bfd_reloc_ok;
@@ -2578,6 +2572,7 @@ m32r_elf_relocate_section (output_bfd, info, input_bfd, input_section,
   bfd *dynobj;
   bfd_vma *local_got_offsets;
   asection *sgot, *splt, *sreloc;
+  bfd_vma high_address = bfd_get_section_limit (input_bfd, input_section);
 
   dynobj = htab->root.dynobj;
   local_got_offsets = elf_local_got_offsets (input_bfd);
@@ -2695,7 +2690,6 @@ m32r_elf_relocate_section (output_bfd, info, input_bfd, input_section,
       else
        {
          bfd_vma relocation;
-         bfd_size_type sz;
 
          /* This is a final link.  */
          sym = NULL;
@@ -2830,10 +2824,7 @@ m32r_elf_relocate_section (output_bfd, info, input_bfd, input_section,
            }
 
          /* Sanity check the address.  */
-         sz = (input_section->rawsize
-               ? input_section->rawsize
-               : input_section->size);
-         if (offset > input_section->size)
+         if (offset > high_address)
            {
              r = bfd_reloc_outofrange;
              goto check_reloc;
index ba501d1235c913e9baff4ea1e21f5d2ffca1d7a6..3b453ec0d5670eff61d2b42bfef569c1ebd7a2d7 100644 (file)
@@ -790,8 +790,6 @@ m68hc11_elf_special_reloc (bfd *abfd ATTRIBUTE_UNUSED,
                            bfd *output_bfd,
                            char **error_message ATTRIBUTE_UNUSED)
 {
-  bfd_size_type sz;
-
   if (output_bfd != (bfd *) NULL
       && (symbol->flags & BSF_SECTION_SYM) == 0
       && (! reloc_entry->howto->partial_inplace
@@ -804,8 +802,7 @@ m68hc11_elf_special_reloc (bfd *abfd ATTRIBUTE_UNUSED,
   if (output_bfd != NULL)
     return bfd_reloc_continue;
 
-  sz = input_section->rawsize ? input_section->rawsize : input_section->size;
-  if (reloc_entry->address > sz)
+  if (reloc_entry->address > bfd_get_section_limit (abfd, input_section))
     return bfd_reloc_outofrange;
 
   abort();
index 188fa1c0c3fa8ff4c141defd9e74565a39f5ac5a..9774215d018059ad795151dd5fc42360f7dbf2b2 100644 (file)
@@ -824,7 +824,6 @@ gprel32_with_gp (bfd *abfd, asymbol *symbol, arelent *reloc_entry,
 {
   bfd_vma relocation;
   bfd_vma val;
-  bfd_size_type sz;
 
   if (bfd_is_com_section (symbol->section))
     relocation = 0;
@@ -834,8 +833,7 @@ gprel32_with_gp (bfd *abfd, asymbol *symbol, arelent *reloc_entry,
   relocation += symbol->section->output_section->vma;
   relocation += symbol->section->output_offset;
 
-  sz = input_section->rawsize ? input_section->rawsize : input_section->size;
-  if (reloc_entry->address > sz)
+  if (reloc_entry->address > bfd_get_section_limit (abfd, input_section))
     return bfd_reloc_outofrange;
 
   /* Set val to the offset into the section or symbol.  */
@@ -943,7 +941,6 @@ mips16_gprel_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
   unsigned short insn = 0;
   bfd_signed_vma val;
   bfd_vma relocation;
-  bfd_size_type sz;
 
   /* If we're relocating, and this is an external symbol, we don't want
      to change anything.  */
@@ -968,8 +965,7 @@ mips16_gprel_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
   if (ret != bfd_reloc_ok)
     return ret;
 
-  sz = input_section->rawsize ? input_section->rawsize : input_section->size;
-  if (reloc_entry->address > sz)
+  if (reloc_entry->address > bfd_get_section_limit (abfd, input_section))
     return bfd_reloc_outofrange;
 
   if (bfd_is_com_section (symbol->section))
index ee5b2c5a382c18e8a0188793f1ec062859a1fe71..14195202d2055d2a52c9ed506f3d43fadc75084c 100644 (file)
@@ -400,7 +400,6 @@ or32_elf_consth_reloc (abfd, reloc_entry, symbol, data, input_section,
 {
   bfd_reloc_status_type ret;
   bfd_vma relocation;
-  bfd_size_type sz;
   struct or32_consth *n;
 
   ret = bfd_reloc_ok;
@@ -418,8 +417,7 @@ or32_elf_consth_reloc (abfd, reloc_entry, symbol, data, input_section,
   relocation += symbol->section->output_offset;
   relocation += reloc_entry->addend;
 
-  sz = input_section->rawsize ? input_section->rawsize : input_section->size;
-  if (reloc_entry->address > sz)
+  if (reloc_entry->address > bfd_get_section_limit (abfd, input_section))
     return bfd_reloc_outofrange;
 
   /* Save the information, and let LO16 do the actual relocation.  */
index f9710337e34553330960c0170fb1bbf0e70d6645..e53c47d4a241f99b2a93d0892b899ccd8d0b6f58 100644 (file)
@@ -2157,7 +2157,6 @@ ppc_elf_addr16_ha_reloc (bfd *abfd ATTRIBUTE_UNUSED,
                         char **error_message ATTRIBUTE_UNUSED)
 {
   bfd_vma relocation;
-  bfd_size_type sz;
 
   if (output_bfd != NULL)
     {
@@ -2165,8 +2164,7 @@ ppc_elf_addr16_ha_reloc (bfd *abfd ATTRIBUTE_UNUSED,
       return bfd_reloc_ok;
     }
 
-  sz = input_section->rawsize ? input_section->rawsize : input_section->size;
-  if (reloc_entry->address > sz)
+  if (reloc_entry->address > bfd_get_section_limit (abfd, input_section))
     return bfd_reloc_outofrange;
 
   if (bfd_is_com_section (symbol->section))
index 597b4cda6307c7dc864135e348e19d3566012d66..3c54d562ec63e0fd9691c51fcd282d847ff47dcf 100644 (file)
@@ -398,7 +398,6 @@ s390_elf_ldisp_reloc (abfd, reloc_entry, symbol, data, input_section,
   reloc_howto_type *howto = reloc_entry->howto;
   bfd_vma relocation;
   bfd_vma insn;
-  bfd_size_type sz;
   
   if (output_bfd != (bfd *) NULL
       && (symbol->flags & BSF_SECTION_SYM) == 0
@@ -412,8 +411,7 @@ s390_elf_ldisp_reloc (abfd, reloc_entry, symbol, data, input_section,
   if (output_bfd != NULL)
     return bfd_reloc_continue;
   
-  sz = input_section->rawsize ? input_section->rawsize : input_section->size;
-  if (reloc_entry->address > sz)
+  if (reloc_entry->address > bfd_get_section_limit (abfd, input_section))
     return bfd_reloc_outofrange;
   
   relocation = (symbol->value
index 2e220a5f03d01f2bc8aba27c58d1b2e64694ae4c..fb45aebc55e7074b090af4aac9288bd08253e3d5 100644 (file)
@@ -1843,12 +1843,10 @@ sh_elf_reloc_loop (int r_type ATTRIBUTE_UNUSED, bfd *input_bfd,
   bfd_byte *start_ptr, *ptr, *last_ptr;
   int diff, cum_diff;
   bfd_signed_vma x;
-  bfd_size_type sz;
   int insn;
 
   /* Sanity check the address.  */
-  sz = input_section->rawsize ? input_section->rawsize : input_section->size;
-  if (addr > sz)
+  if (addr > bfd_get_section_limit (input_bfd, input_section))
     return bfd_reloc_outofrange;
 
   /* We require the start and end relocations to be processed consecutively -
index f895220cf813a4643a04373af83b62271b71fb8a..15868eb54d4f9898f641628cd50a8d59262a11db 100644 (file)
@@ -374,7 +374,6 @@ sparc_elf_wdisp16_reloc (abfd,
 {
   bfd_vma relocation;
   bfd_vma x;
-  bfd_size_type sz;
 
   if (output_bfd != (bfd *) NULL
       && (symbol->flags & BSF_SECTION_SYM) == 0
@@ -388,8 +387,7 @@ sparc_elf_wdisp16_reloc (abfd,
   if (output_bfd != NULL)
     return bfd_reloc_continue;
 
-  sz = input_section->rawsize ? input_section->rawsize : input_section->size;
-  if (reloc_entry->address > sz)
+  if (reloc_entry->address > bfd_get_section_limit (abfd, input_section))
     return bfd_reloc_outofrange;
 
   relocation = (symbol->value
@@ -432,7 +430,6 @@ sparc_elf_hix22_reloc (abfd,
 {
   bfd_vma relocation;
   bfd_vma insn;
-  bfd_size_type sz;
 
   if (output_bfd != (bfd *) NULL
       && (symbol->flags & BSF_SECTION_SYM) == 0)
@@ -444,8 +441,7 @@ sparc_elf_hix22_reloc (abfd,
   if (output_bfd != NULL)
     return bfd_reloc_continue;
 
-  sz = input_section->rawsize ? input_section->rawsize : input_section->size;
-  if (reloc_entry->address > sz)
+  if (reloc_entry->address > bfd_get_section_limit (abfd, input_section))
     return bfd_reloc_outofrange;
 
   relocation = (symbol->value
@@ -480,7 +476,6 @@ sparc_elf_lox10_reloc (abfd,
 {
   bfd_vma relocation;
   bfd_vma insn;
-  bfd_size_type sz;
 
   if (output_bfd != (bfd *) NULL
       && (symbol->flags & BSF_SECTION_SYM) == 0)
@@ -492,8 +487,7 @@ sparc_elf_lox10_reloc (abfd,
   if (output_bfd != NULL)
     return bfd_reloc_continue;
 
-  sz = input_section->rawsize ? input_section->rawsize : input_section->size;
-  if (reloc_entry->address > sz)
+  if (reloc_entry->address > bfd_get_section_limit (abfd, input_section))
     return bfd_reloc_outofrange;
 
   relocation = (symbol->value
index 05935e640afa6e49006720d27c821780a1af5274..d52c303b0e4332ae2e0c3b2a1945464c233ad1f4 100644 (file)
@@ -1334,7 +1334,6 @@ v850_elf_reloc (abfd, reloc, symbol, data, isection, obfd, err)
      bfd *obfd;
      char **err ATTRIBUTE_UNUSED;
 {
-  bfd_size_type sz;
   long relocation;
 
   /* If there is an output BFD,
@@ -1360,8 +1359,7 @@ v850_elf_reloc (abfd, reloc, symbol, data, isection, obfd, err)
   /* We handle final linking of some relocs ourselves.  */
 
   /* Is the address of the relocation really within the section?  */
-  sz = isection->rawsize ? isection->rawsize : isection->size;
-  if (reloc->address > sz)
+  if (reloc->address > bfd_get_section_limit (abfd, isection))
     return bfd_reloc_outofrange;
 
   /* Work out which section the relocation is targeted at and the
index 6bf53e9510609b711a68f39052fa4a39ec1224b8..e03cc77190db89644726e0d8e2e3613faa4836f7 100644 (file)
@@ -372,7 +372,6 @@ xstormy16_elf_24_reloc (abfd, reloc_entry, symbol, data, input_section,
      char **error_message ATTRIBUTE_UNUSED;
 {
   bfd_vma relocation, x;
-  bfd_size_type sz;
 
   if (output_bfd != NULL)
     {
@@ -380,8 +379,7 @@ xstormy16_elf_24_reloc (abfd, reloc_entry, symbol, data, input_section,
       return bfd_reloc_ok;
     }
 
-  sz = input_section->rawsize ? input_section->rawsize : input_section->size;
-  if (reloc_entry->address > sz)
+  if (reloc_entry->address > bfd_get_section_limit (abfd, input_section))
     return bfd_reloc_outofrange;
 
   if (bfd_is_com_section (symbol->section))
index 495c275027d5d5e91de4548353bd965182b893d4..438e17b05edf732d3e9297889e605589578afb11 100644 (file)
@@ -1650,7 +1650,6 @@ bfd_elf_xtensa_reloc (abfd, reloc_entry, symbol, data, input_section,
   bfd_vma relocation;
   bfd_reloc_status_type flag;
   bfd_size_type octets = reloc_entry->address * bfd_octets_per_byte (abfd);
-  bfd_size_type sz;
   bfd_vma output_base = 0;
   reloc_howto_type *howto = reloc_entry->howto;
   asection *reloc_target_output_section;
@@ -1675,8 +1674,7 @@ bfd_elf_xtensa_reloc (abfd, reloc_entry, symbol, data, input_section,
     }
 
   /* Is the address of the relocation really within the section?  */
-  sz = input_section->rawsize ? input_section->rawsize : input_section->size;
-  if (reloc_entry->address > sz / bfd_octets_per_byte (abfd))
+  if (reloc_entry->address > bfd_get_section_limit (abfd, input_section))
     return bfd_reloc_outofrange;
 
   /* Work out which section the relocation is targeted at and the
index a8f2cf0ff34d9b16f605d9dd2d187ad9d5eae469..7b17db54333cb3a9278e31372048121f2159be4f 100644 (file)
@@ -1036,7 +1036,7 @@ elf64_alpha_reloc_gpdisp (abfd, reloc_entry, sym, data, input_section,
 {
   bfd_reloc_status_type ret;
   bfd_vma gp, relocation;
-  bfd_size_type sz;
+  bfd_vma high_address;
   bfd_byte *p_ldah, *p_lda;
 
   /* Don't do anything if we're not doing a final link.  */
@@ -1046,9 +1046,9 @@ elf64_alpha_reloc_gpdisp (abfd, reloc_entry, sym, data, input_section,
       return bfd_reloc_ok;
     }
 
-  sz = input_section->rawsize ? input_section->rawsize : input_section->size;
-  if (reloc_entry->address > sz
-      || reloc_entry->address + reloc_entry->addend > sz)
+  high_address = bfd_get_section_limit (abfd, input_section);
+  if (reloc_entry->address > high_address
+      || reloc_entry->address + reloc_entry->addend > high_address)
     return bfd_reloc_outofrange;
 
   /* The gp used in the portion of the output object to which this
index 743444240aa7e3b23a9c09d0ad4fbaa6f84f6918..ac9f96f97b345108d0e929b91ee030acb33aa4aa 100644 (file)
@@ -1588,7 +1588,6 @@ mips_elf64_gprel32_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
   bfd_vma gp;
   bfd_vma relocation;
   bfd_vma val;
-  bfd_size_type sz;
 
   /* If we're relocating, and this is an external symbol, we don't want
      to change anything.  */
@@ -1622,8 +1621,7 @@ mips_elf64_gprel32_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
   relocation += symbol->section->output_section->vma;
   relocation += symbol->section->output_offset;
 
-  sz = input_section->rawsize ? input_section->rawsize : input_section->size;
-  if (reloc_entry->address > sz)
+  if (reloc_entry->address > bfd_get_section_limit (abfd, input_section))
     return bfd_reloc_outofrange;
 
   /* Set val to the offset into the section or symbol.  */
@@ -1714,7 +1712,6 @@ mips16_gprel_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
   unsigned short insn = 0;
   bfd_signed_vma val;
   bfd_vma relocation;
-  bfd_size_type sz;
 
   /* If we're relocating, and this is an external symbol with no
      addend, we don't want to change anything.  */
@@ -1739,8 +1736,7 @@ mips16_gprel_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
   if (ret != bfd_reloc_ok)
     return ret;
 
-  sz = input_section->rawsize ? input_section->rawsize : input_section->size;
-  if (reloc_entry->address > sz)
+  if (reloc_entry->address > bfd_get_section_limit (abfd, input_section))
     return bfd_reloc_outofrange;
 
   if (bfd_is_com_section (symbol->section))
index 992a32115611a0e2f4620b84221de0dff36226f1..0f9cd36a790ec19f317909eeb9f4670b0a0b19ba 100644 (file)
@@ -1261,7 +1261,6 @@ mmix_elf_reloc (abfd, reloc_entry, symbol, data, input_section,
   bfd_reloc_status_type flag = bfd_reloc_ok;
   bfd_vma output_base = 0;
   bfd_vma addr;
-  bfd_size_type sz;
 
   r = bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data,
                             input_section, output_bfd, error_message);
@@ -1277,8 +1276,7 @@ mmix_elf_reloc (abfd, reloc_entry, symbol, data, input_section,
     return bfd_reloc_undefined;
 
   /* Is the address of the relocation really within the section?  */
-  sz = input_section->rawsize ? input_section->rawsize : input_section->size;
-  if (reloc_entry->address > sz)
+  if (reloc_entry->address > bfd_get_section_limit (abfd, input_section))
     return bfd_reloc_outofrange;
 
   /* Work out which section the relocation is targeted at and the
index 788406f2686ce6a6ba5b98c09b78bd2c757defb8..2c3246fb361b0a945c19d4455940e4e1cf5df311 100644 (file)
@@ -420,7 +420,6 @@ s390_elf_ldisp_reloc (abfd, reloc_entry, symbol, data, input_section,
   reloc_howto_type *howto = reloc_entry->howto;
   bfd_vma relocation;
   bfd_vma insn;
-  bfd_size_type sz;
 
   if (output_bfd != (bfd *) NULL
       && (symbol->flags & BSF_SECTION_SYM) == 0
@@ -433,8 +432,7 @@ s390_elf_ldisp_reloc (abfd, reloc_entry, symbol, data, input_section,
   if (output_bfd != NULL)
     return bfd_reloc_continue;
 
-  sz = input_section->rawsize ? input_section->rawsize : input_section->size;
-  if (reloc_entry->address > sz)
+  if (reloc_entry->address > bfd_get_section_limit (abfd, input_section))
     return bfd_reloc_outofrange;
 
   relocation = (symbol->value
index 51f68bd0ba0b16894d4ebdd2ebcec79ac685006d..75704e2e56a56b45f37e4c0e6c98e5561ee64e4a 100644 (file)
@@ -794,7 +794,6 @@ init_insn_reloc (abfd,
      bfd_vma *pinsn;
 {
   bfd_vma relocation;
-  bfd_size_type sz;
   reloc_howto_type *howto = reloc_entry->howto;
 
   if (output_bfd != (bfd *) NULL
@@ -810,8 +809,7 @@ init_insn_reloc (abfd,
   if (output_bfd != NULL)
     return bfd_reloc_continue;
 
-  sz = input_section->rawsize ? input_section->rawsize : input_section->size;
-  if (reloc_entry->address > sz)
+  if (reloc_entry->address > bfd_get_section_limit (abfd, input_section))
     return bfd_reloc_outofrange;
 
   relocation = (symbol->value
index dc93e17b8444e015d24bf29e80fd897bc5e4798d..769c4149812f58de14073ee8bc88b537e1c12511 100644 (file)
@@ -1415,7 +1415,6 @@ gprel32_with_gp (bfd *abfd, asymbol *symbol, arelent *reloc_entry,
                 void *data, bfd_vma gp)
 {
   bfd_vma relocation;
-  bfd_size_type sz;
   unsigned long val;
 
   if (bfd_is_com_section (symbol->section))
@@ -1426,8 +1425,7 @@ gprel32_with_gp (bfd *abfd, asymbol *symbol, arelent *reloc_entry,
   relocation += symbol->section->output_section->vma;
   relocation += symbol->section->output_offset;
 
-  sz = input_section->rawsize ? input_section->rawsize : input_section->size;
-  if (reloc_entry->address > sz)
+  if (reloc_entry->address > bfd_get_section_limit (abfd, input_section))
     return bfd_reloc_outofrange;
 
   if (reloc_entry->howto->src_mask == 0)
@@ -1508,7 +1506,6 @@ mips16_gprel_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
   unsigned short insn = 0;
   bfd_signed_vma val;
   bfd_vma relocation;
-  bfd_size_type sz;
 
   if (output_bfd != NULL)
     relocatable = TRUE;
@@ -1523,8 +1520,7 @@ mips16_gprel_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
   if (ret != bfd_reloc_ok)
     return ret;
 
-  sz = input_section->rawsize ? input_section->rawsize : input_section->size;
-  if (reloc_entry->address > sz)
+  if (reloc_entry->address > bfd_get_section_limit (abfd, input_section))
     return bfd_reloc_outofrange;
 
   if (bfd_is_com_section (symbol->section))
index 596c328baf6c64f080bdbc327cefcc868c5f9187..b81927373d4cd41e884768cab06cc9adb2a06c7d 100644 (file)
@@ -1068,7 +1068,6 @@ _bfd_mips_elf_gprel16_with_gp (bfd *abfd, asymbol *symbol,
 {
   bfd_vma relocation;
   bfd_signed_vma val;
-  bfd_size_type sz;
   bfd_reloc_status_type status;
 
   if (bfd_is_com_section (symbol->section))
@@ -1079,8 +1078,7 @@ _bfd_mips_elf_gprel16_with_gp (bfd *abfd, asymbol *symbol,
   relocation += symbol->section->output_section->vma;
   relocation += symbol->section->output_offset;
 
-  sz = input_section->rawsize ? input_section->rawsize : input_section->size;
-  if (reloc_entry->address > sz)
+  if (reloc_entry->address > bfd_get_section_limit (abfd, input_section))
     return bfd_reloc_outofrange;
 
   /* Set val to the offset into the section or symbol.  */
@@ -1145,10 +1143,8 @@ _bfd_mips_elf_hi16_reloc (bfd *abfd ATTRIBUTE_UNUSED, arelent *reloc_entry,
                          char **error_message ATTRIBUTE_UNUSED)
 {
   struct mips_hi16 *n;
-  bfd_size_type sz;
 
-  sz = input_section->rawsize ? input_section->rawsize : input_section->size;
-  if (reloc_entry->address > sz)
+  if (reloc_entry->address > bfd_get_section_limit (abfd, input_section))
     return bfd_reloc_outofrange;
 
   n = bfd_malloc (sizeof *n);
@@ -1198,10 +1194,8 @@ _bfd_mips_elf_lo16_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
                          bfd *output_bfd, char **error_message)
 {
   bfd_vma vallo;
-  bfd_size_type sz;
 
-  sz = input_section->rawsize ? input_section->rawsize : input_section->size;
-  if (reloc_entry->address > sz)
+  if (reloc_entry->address > bfd_get_section_limit (abfd, input_section))
     return bfd_reloc_outofrange;
 
   vallo = bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address);
@@ -1250,14 +1244,12 @@ _bfd_mips_elf_generic_reloc (bfd *abfd ATTRIBUTE_UNUSED, arelent *reloc_entry,
                             char **error_message ATTRIBUTE_UNUSED)
 {
   bfd_signed_vma val;
-  bfd_size_type sz;
   bfd_reloc_status_type status;
   bfd_boolean relocatable;
 
   relocatable = (output_bfd != NULL);
 
-  sz = input_section->rawsize ? input_section->rawsize : input_section->size;
-  if (reloc_entry->address > sz)
+  if (reloc_entry->address > bfd_get_section_limit (abfd, input_section))
     return bfd_reloc_outofrange;
 
   /* Build up the field adjustment in VAL.  */
index df50af47a7af9e012f16b8bdfa86b99a5c763bda..a6f158c51ddb45a6dc8f2d78796ef92e4cd789d7 100644 (file)
@@ -587,7 +587,6 @@ bfd_perform_relocation (bfd *abfd,
 {
   bfd_vma relocation;
   bfd_reloc_status_type flag = bfd_reloc_ok;
-  bfd_size_type sz;
   bfd_size_type octets = reloc_entry->address * bfd_octets_per_byte (abfd);
   bfd_vma output_base = 0;
   reloc_howto_type *howto = reloc_entry->howto;
@@ -624,8 +623,7 @@ bfd_perform_relocation (bfd *abfd,
     }
 
   /* Is the address of the relocation really within the section?  */
-  sz = input_section->rawsize ? input_section->rawsize : input_section->size;
-  if (reloc_entry->address > sz / bfd_octets_per_byte (abfd))
+  if (reloc_entry->address > bfd_get_section_limit (abfd, input_section))
     return bfd_reloc_outofrange;
 
   /* Work out which section the relocation is targeted at and the
@@ -981,7 +979,6 @@ bfd_install_relocation (bfd *abfd,
 {
   bfd_vma relocation;
   bfd_reloc_status_type flag = bfd_reloc_ok;
-  bfd_size_type sz;
   bfd_size_type octets = reloc_entry->address * bfd_octets_per_byte (abfd);
   bfd_vma output_base = 0;
   reloc_howto_type *howto = reloc_entry->howto;
@@ -1015,8 +1012,7 @@ bfd_install_relocation (bfd *abfd,
     }
 
   /* Is the address of the relocation really within the section?  */
-  sz = input_section->rawsize ? input_section->rawsize : input_section->size;
-  if (reloc_entry->address > sz / bfd_octets_per_byte (abfd))
+  if (reloc_entry->address > bfd_get_section_limit (abfd, input_section))
     return bfd_reloc_outofrange;
 
   /* Work out which section the relocation is targeted at and the
@@ -1350,11 +1346,9 @@ _bfd_final_link_relocate (reloc_howto_type *howto,
                          bfd_vma addend)
 {
   bfd_vma relocation;
-  bfd_size_type sz;
 
   /* Sanity check the address.  */
-  sz = input_section->rawsize ? input_section->rawsize : input_section->size;
-  if (address > sz)
+  if (address > bfd_get_section_limit (input_bfd, input_section))
     return bfd_reloc_outofrange;
 
   /* This function assumes that we are dealing with a basic relocation
This page took 0.080589 seconds and 4 git commands to generate.