diff options
Diffstat (limited to 'bfd/elf32-nds32.c')
-rw-r--r-- | bfd/elf32-nds32.c | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/bfd/elf32-nds32.c b/bfd/elf32-nds32.c index e240c31..bcd7c42 100644 --- a/bfd/elf32-nds32.c +++ b/bfd/elf32-nds32.c @@ -2692,12 +2692,13 @@ nds32_elf_do_9_pcrel_reloc (bfd * abfd, bfd_vma symbol_value, bfd_vma addend) { - bfd_signed_vma relocation; + bfd_vma relocation; unsigned short x; bfd_reloc_status_type status; /* Sanity check the address (offset in section). */ - if (offset > bfd_get_section_limit (abfd, input_section)) + bfd_vma octet = offset * bfd_octets_per_byte (abfd, input_section); + if (!bfd_reloc_offset_in_range (howto, abfd, input_section, octet)) return bfd_reloc_outofrange; relocation = symbol_value + addend; @@ -2708,7 +2709,7 @@ nds32_elf_do_9_pcrel_reloc (bfd * abfd, before doing pcrel calculations. */ relocation -= (offset & -(bfd_vma) 2); - if (relocation < -ACCURATE_8BIT_S1 || relocation >= ACCURATE_8BIT_S1) + if (relocation + ACCURATE_8BIT_S1 >= 2 * ACCURATE_8BIT_S1) status = bfd_reloc_overflow; else status = bfd_reloc_ok; @@ -2751,7 +2752,7 @@ struct nds32_hi20 static struct nds32_hi20 *nds32_hi20_list; static bfd_reloc_status_type -nds32_elf_hi20_reloc (bfd *abfd ATTRIBUTE_UNUSED, +nds32_elf_hi20_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol, void *data, @@ -2774,7 +2775,10 @@ nds32_elf_hi20_reloc (bfd *abfd ATTRIBUTE_UNUSED, } /* Sanity check the address (offset in section). */ - if (reloc_entry->address > bfd_get_section_limit (abfd, input_section)) + bfd_vma octet = (reloc_entry->address + * bfd_octets_per_byte (abfd, input_section)); + if (!bfd_reloc_offset_in_range (reloc_entry->howto, + abfd, input_section, octet)) return bfd_reloc_outofrange; ret = bfd_reloc_ok; @@ -2938,7 +2942,10 @@ nds32_elf_generic_reloc (bfd *input_bfd, arelent *reloc_entry, a section relative addend which is wrong. */ /* Sanity check the address (offset in section). */ - if (reloc_entry->address > bfd_get_section_limit (input_bfd, input_section)) + bfd_vma octet = (reloc_entry->address + * bfd_octets_per_byte (input_bfd, input_section)); + if (!bfd_reloc_offset_in_range (reloc_entry->howto, input_bfd, input_section, + octet)) return bfd_reloc_outofrange; ret = bfd_reloc_ok; @@ -4337,7 +4344,6 @@ nds32_elf_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, Elf_Internal_Shdr *symtab_hdr; asection *sgot; char *local_tls_type; - unsigned long symndx; bfd_vma *local_tlsdesc_gotent; if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour) @@ -4379,8 +4385,8 @@ nds32_elf_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, sgot = elf_hash_table (info)->sgot; local_tls_type = elf32_nds32_local_got_tls_type (ibfd); local_tlsdesc_gotent = elf32_nds32_local_tlsdesc_gotent (ibfd); - for (symndx = 0; local_got < end_local_got; - ++local_got, ++local_tls_type, ++local_tlsdesc_gotent, ++symndx) + for (; local_got < end_local_got; + ++local_got, ++local_tls_type, ++local_tlsdesc_gotent) { if (*local_got > 0) { @@ -4698,7 +4704,8 @@ nds32_elf_final_link_relocate (reloc_howto_type *howto, bfd *input_bfd, bfd_vma relocation; /* Sanity check the address. */ - if (address > bfd_get_section_limit (input_bfd, input_section)) + bfd_vma octet = address * bfd_octets_per_byte (input_bfd, input_section); + if (!bfd_reloc_offset_in_range (howto, input_bfd, input_section, octet)) return bfd_reloc_outofrange; /* This function assumes that we are dealing with a basic relocation |