]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - bfd/elf32-pru.c
Update year range in copyright notice of binutils files
[thirdparty/binutils-gdb.git] / bfd / elf32-pru.c
index 98b2018621acd5b8f821bb728fb022466c24417e..b4726befa16b5923e9e8afdfcdbcff1646c0cf98 100644 (file)
@@ -1,5 +1,5 @@
 /* 32-bit ELF support for TI PRU.
-   Copyright (C) 2014-2019 Free Software Foundation, Inc.
+   Copyright (C) 2014-2021 Free Software Foundation, Inc.
    Contributed by Dimitar Dimitrov <dimitar@dinux.eu>
    Based on elf32-nios2.c
 
@@ -32,6 +32,9 @@
 #include "opcode/pru.h"
 #include "libiberty.h"
 
+/* All users of this file have bfd_octets_per_byte (abfd, sec) == 1.  */
+#define OCTETS_PER_BYTE(ABFD, SEC) 1
+
 #define SWAP_VALS(A,B)               \
   do {                               \
       (A) ^= (B);                    \
@@ -536,8 +539,8 @@ pru_elf32_do_ldi32_relocate (bfd *abfd, reloc_howto_type *howto,
                             bfd_byte *data, bfd_vma offset,
                             bfd_vma symbol_value, bfd_vma addend)
 {
-  bfd_signed_vma relocation;
-  bfd_size_type octets = offset * bfd_octets_per_byte (abfd, NULL);
+  bfd_vma relocation;
+  bfd_size_type octets = offset * OCTETS_PER_BYTE (abfd, input_section);
   bfd_byte *location;
   unsigned long in1, in2;
 
@@ -557,7 +560,7 @@ pru_elf32_do_ldi32_relocate (bfd *abfd, reloc_howto_type *howto,
   BFD_ASSERT (!howto->pc_relative);
 
   /* A hacked-up version of _bfd_relocate_contents() follows.  */
-  location = data + offset * bfd_octets_per_byte (abfd, NULL);
+  location = data + octets;
 
   BFD_ASSERT (!howto->pc_relative);
 
@@ -1520,20 +1523,17 @@ pru_elf32_relax_section (bfd * abfd, asection * sec,
        }
     }
 
-  if (internal_relocs != NULL
-      && elf_section_data (sec)->relocs != internal_relocs)
+  if (elf_section_data (sec)->relocs != internal_relocs)
     free (internal_relocs);
 
   return TRUE;
 
-error_return:
-  if (isymbuf != NULL && symtab_hdr->contents != (unsigned char *) isymbuf)
+ error_return:
+  if (symtab_hdr->contents != (unsigned char *) isymbuf)
     free (isymbuf);
-  if (contents != NULL
-      && elf_section_data (sec)->this_hdr.contents != contents)
+  if (elf_section_data (sec)->this_hdr.contents != contents)
     free (contents);
-  if (internal_relocs != NULL
-      && elf_section_data (sec)->relocs != internal_relocs)
+  if (elf_section_data (sec)->relocs != internal_relocs)
     free (internal_relocs);
 
   return FALSE;
@@ -1551,7 +1551,7 @@ static struct bfd_link_hash_table *
 pru_elf32_link_hash_table_create (bfd *abfd)
 {
   struct elf_link_hash_table *ret;
-  bfd_size_type amt = sizeof (struct elf_link_hash_table);
+  size_t amt = sizeof (struct elf_link_hash_table);
 
   ret = bfd_zmalloc (amt);
   if (ret == NULL)