diff options
author | Alan Modra <amodra@gmail.com> | 2004-06-29 13:46:34 +0000 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2004-06-29 13:46:34 +0000 |
commit | 075154045b3a1c940a448846723be16e3c7e0930 (patch) | |
tree | 6f652dcc932a68d189593be11ae2da1fe7d0a4eb /bfd | |
parent | 950ad202a518f7deb8e4ef1b2a3b63e2e3d7450d (diff) | |
download | gdb-075154045b3a1c940a448846723be16e3c7e0930.zip gdb-075154045b3a1c940a448846723be16e3c7e0930.tar.gz gdb-075154045b3a1c940a448846723be16e3c7e0930.tar.bz2 |
* 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.
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/ChangeLog | 39 | ||||
-rw-r--r-- | bfd/aout-tic30.c | 4 | ||||
-rw-r--r-- | bfd/bfd-in.h | 4 | ||||
-rw-r--r-- | bfd/bfd-in2.h | 4 | ||||
-rw-r--r-- | bfd/coff-arm.c | 7 | ||||
-rw-r--r-- | bfd/coff-mips.c | 8 | ||||
-rw-r--r-- | bfd/cpu-ns32k.c | 8 | ||||
-rw-r--r-- | bfd/elf32-d30v.c | 8 | ||||
-rw-r--r-- | bfd/elf32-dlx.c | 4 | ||||
-rw-r--r-- | bfd/elf32-i860.c | 16 | ||||
-rw-r--r-- | bfd/elf32-m32r.c | 19 | ||||
-rw-r--r-- | bfd/elf32-m68hc1x.c | 5 | ||||
-rw-r--r-- | bfd/elf32-mips.c | 8 | ||||
-rw-r--r-- | bfd/elf32-or32.c | 4 | ||||
-rw-r--r-- | bfd/elf32-ppc.c | 4 | ||||
-rw-r--r-- | bfd/elf32-s390.c | 4 | ||||
-rw-r--r-- | bfd/elf32-sh.c | 4 | ||||
-rw-r--r-- | bfd/elf32-sparc.c | 12 | ||||
-rw-r--r-- | bfd/elf32-v850.c | 4 | ||||
-rw-r--r-- | bfd/elf32-xstormy16.c | 4 | ||||
-rw-r--r-- | bfd/elf32-xtensa.c | 4 | ||||
-rw-r--r-- | bfd/elf64-alpha.c | 8 | ||||
-rw-r--r-- | bfd/elf64-mips.c | 8 | ||||
-rw-r--r-- | bfd/elf64-mmix.c | 4 | ||||
-rw-r--r-- | bfd/elf64-s390.c | 4 | ||||
-rw-r--r-- | bfd/elf64-sparc.c | 4 | ||||
-rw-r--r-- | bfd/elfn32-mips.c | 8 | ||||
-rw-r--r-- | bfd/elfxx-mips.c | 16 | ||||
-rw-r--r-- | bfd/reloc.c | 12 |
29 files changed, 97 insertions, 141 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 9fff848..3767818 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -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. diff --git a/bfd/aout-tic30.c b/bfd/aout-tic30.c index 81ee1b6..cf574ff 100644 --- a/bfd/aout-tic30.c +++ b/bfd/aout-tic30.c @@ -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; diff --git a/bfd/bfd-in.h b/bfd/bfd-in.h index b3eb293..97296c8 100644 --- a/bfd/bfd-in.h +++ b/bfd/bfd-in.h @@ -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; diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index 65a4a10..a3ace11 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -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; diff --git a/bfd/coff-arm.c b/bfd/coff-arm.c index eb7e038..3f3ab44 100644 --- a/bfd/coff-arm.c +++ b/bfd/coff-arm.c @@ -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 { diff --git a/bfd/coff-mips.c b/bfd/coff-mips.c index ca3376d..f351eb1 100644 --- a/bfd/coff-mips.c +++ b/bfd/coff-mips.c @@ -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); diff --git a/bfd/cpu-ns32k.c b/bfd/cpu-ns32k.c index 074eb70..0cd358d 100644 --- a/bfd/cpu-ns32k.c +++ b/bfd/cpu-ns32k.c @@ -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 diff --git a/bfd/elf32-d30v.c b/bfd/elf32-d30v.c index ffce498..6a84522 100644 --- a/bfd/elf32-d30v.c +++ b/bfd/elf32-d30v.c @@ -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 diff --git a/bfd/elf32-dlx.c b/bfd/elf32-dlx.c index 2301dae..f8a3946 100644 --- a/bfd/elf32-dlx.c +++ b/bfd/elf32-dlx.c @@ -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 diff --git a/bfd/elf32-i860.c b/bfd/elf32-i860.c index 863d7ae..010ac2e 100644 --- a/bfd/elf32-i860.c +++ b/bfd/elf32-i860.c @@ -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; diff --git a/bfd/elf32-m32r.c b/bfd/elf32-m32r.c index c6bc2be..6776a62 100644 --- a/bfd/elf32-m32r.c +++ b/bfd/elf32-m32r.c @@ -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; diff --git a/bfd/elf32-m68hc1x.c b/bfd/elf32-m68hc1x.c index ba501d1..3b453ec 100644 --- a/bfd/elf32-m68hc1x.c +++ b/bfd/elf32-m68hc1x.c @@ -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(); diff --git a/bfd/elf32-mips.c b/bfd/elf32-mips.c index 188fa1c..9774215 100644 --- a/bfd/elf32-mips.c +++ b/bfd/elf32-mips.c @@ -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)) diff --git a/bfd/elf32-or32.c b/bfd/elf32-or32.c index ee5b2c5..1419520 100644 --- a/bfd/elf32-or32.c +++ b/bfd/elf32-or32.c @@ -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. */ diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c index f971033..e53c47d 100644 --- a/bfd/elf32-ppc.c +++ b/bfd/elf32-ppc.c @@ -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)) diff --git a/bfd/elf32-s390.c b/bfd/elf32-s390.c index 597b4cd..3c54d56 100644 --- a/bfd/elf32-s390.c +++ b/bfd/elf32-s390.c @@ -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 diff --git a/bfd/elf32-sh.c b/bfd/elf32-sh.c index 2e220a5..fb45aeb 100644 --- a/bfd/elf32-sh.c +++ b/bfd/elf32-sh.c @@ -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 - diff --git a/bfd/elf32-sparc.c b/bfd/elf32-sparc.c index f895220..15868eb 100644 --- a/bfd/elf32-sparc.c +++ b/bfd/elf32-sparc.c @@ -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 diff --git a/bfd/elf32-v850.c b/bfd/elf32-v850.c index 05935e6..d52c303 100644 --- a/bfd/elf32-v850.c +++ b/bfd/elf32-v850.c @@ -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 diff --git a/bfd/elf32-xstormy16.c b/bfd/elf32-xstormy16.c index 6bf53e9..e03cc77 100644 --- a/bfd/elf32-xstormy16.c +++ b/bfd/elf32-xstormy16.c @@ -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)) diff --git a/bfd/elf32-xtensa.c b/bfd/elf32-xtensa.c index 495c275..438e17b 100644 --- a/bfd/elf32-xtensa.c +++ b/bfd/elf32-xtensa.c @@ -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 diff --git a/bfd/elf64-alpha.c b/bfd/elf64-alpha.c index a8f2cf0..7b17db5 100644 --- a/bfd/elf64-alpha.c +++ b/bfd/elf64-alpha.c @@ -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 diff --git a/bfd/elf64-mips.c b/bfd/elf64-mips.c index 7434442..ac9f96f 100644 --- a/bfd/elf64-mips.c +++ b/bfd/elf64-mips.c @@ -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)) diff --git a/bfd/elf64-mmix.c b/bfd/elf64-mmix.c index 992a321..0f9cd36 100644 --- a/bfd/elf64-mmix.c +++ b/bfd/elf64-mmix.c @@ -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 diff --git a/bfd/elf64-s390.c b/bfd/elf64-s390.c index 788406f..2c3246f 100644 --- a/bfd/elf64-s390.c +++ b/bfd/elf64-s390.c @@ -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 diff --git a/bfd/elf64-sparc.c b/bfd/elf64-sparc.c index 51f68bd..75704e2 100644 --- a/bfd/elf64-sparc.c +++ b/bfd/elf64-sparc.c @@ -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 diff --git a/bfd/elfn32-mips.c b/bfd/elfn32-mips.c index dc93e17..769c414 100644 --- a/bfd/elfn32-mips.c +++ b/bfd/elfn32-mips.c @@ -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)) diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c index 596c328..b819273 100644 --- a/bfd/elfxx-mips.c +++ b/bfd/elfxx-mips.c @@ -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. */ diff --git a/bfd/reloc.c b/bfd/reloc.c index df50af4..a6f158c 100644 --- a/bfd/reloc.c +++ b/bfd/reloc.c @@ -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 |