Automatic date update in version.in
[binutils-gdb.git] / bfd / coff-z8k.c
index 0adfd7118a7f85075c7f1d4e67ff5cbd45a44b4e..076b798f534a5a8c61dd37f85d6d993373fb5e46 100644 (file)
@@ -1,5 +1,5 @@
 /* BFD back-end for Zilog Z800n COFF binaries.
-   Copyright (C) 1992-2018 Free Software Foundation, Inc.
+   Copyright (C) 1992-2022 Free Software Foundation, Inc.
    Contributed by Cygnus Support.
    Written by Steve Chamberlain, <sac@cygnus.com>.
 
 #define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (1)
 
 static reloc_howto_type r_imm32 =
-HOWTO (R_IMM32, 0, 2, 32, FALSE, 0,
-       complain_overflow_bitfield, 0, "r_imm32", TRUE, 0xffffffff,
-       0xffffffff, FALSE);
+HOWTO (R_IMM32, 0, 2, 32, false, 0,
+       complain_overflow_bitfield, 0, "r_imm32", true, 0xffffffff,
+       0xffffffff, false);
 
 static reloc_howto_type r_imm4l =
-HOWTO (R_IMM4L, 0, 0, 4, FALSE, 0,
-       complain_overflow_bitfield, 0, "r_imm4l", TRUE, 0xf, 0xf, FALSE);
+HOWTO (R_IMM4L, 0, 0, 4, false, 0,
+       complain_overflow_bitfield, 0, "r_imm4l", true, 0xf, 0xf, false);
 
 static reloc_howto_type r_da =
-HOWTO (R_IMM16, 0, 1, 16, FALSE, 0,
-       complain_overflow_bitfield, 0, "r_da", TRUE, 0x0000ffff, 0x0000ffff,
-       FALSE);
+HOWTO (R_IMM16, 0, 1, 16, false, 0,
+       complain_overflow_bitfield, 0, "r_da", true, 0x0000ffff, 0x0000ffff,
+       false);
 
 static reloc_howto_type r_imm8 =
-HOWTO (R_IMM8, 0, 0, 8, FALSE, 0,
-       complain_overflow_bitfield, 0, "r_imm8", TRUE, 0x000000ff, 0x000000ff,
-       FALSE);
+HOWTO (R_IMM8, 0, 0, 8, false, 0,
+       complain_overflow_bitfield, 0, "r_imm8", true, 0x000000ff, 0x000000ff,
+       false);
 
 static reloc_howto_type r_rel16 =
-HOWTO (R_REL16, 0, 1, 16, FALSE, 0,
-       complain_overflow_bitfield, 0, "r_rel16", TRUE, 0x0000ffff, 0x0000ffff,
-       TRUE);
+HOWTO (R_REL16, 0, 1, 16, false, 0,
+       complain_overflow_bitfield, 0, "r_rel16", true, 0x0000ffff, 0x0000ffff,
+       true);
 
 static reloc_howto_type r_jr =
-HOWTO (R_JR, 1, 0, 8, TRUE, 0, complain_overflow_signed, 0,
-       "r_jr", TRUE, 0xff, 0xff, TRUE);
+HOWTO (R_JR, 1, 0, 8, true, 0, complain_overflow_signed, 0,
+       "r_jr", true, 0xff, 0xff, true);
 
 static reloc_howto_type r_disp7 =
-HOWTO (R_DISP7, 0, 0, 7, TRUE, 0, complain_overflow_bitfield, 0,
-       "r_disp7", TRUE, 0x7f, 0x7f, TRUE);
+HOWTO (R_DISP7, 0, 0, 7, true, 0, complain_overflow_bitfield, 0,
+       "r_disp7", true, 0x7f, 0x7f, true);
 
 static reloc_howto_type r_callr =
-HOWTO (R_CALLR, 1, 1, 12, TRUE, 0, complain_overflow_signed, 0,
-       "r_callr", TRUE, 0xfff, 0xfff, TRUE);
+HOWTO (R_CALLR, 1, 1, 12, true, 0, complain_overflow_signed, 0,
+       "r_callr", true, 0xfff, 0xfff, true);
 
 #define BADMAG(x) Z8KBADMAG(x)
 #define Z8K 1                  /* Customize coffcode.h.  */
@@ -177,11 +177,18 @@ reloc_processing (arelent *relent,
   relent->address = reloc->r_vaddr;
   rtype2howto (relent, reloc);
 
-  if (reloc->r_symndx > 0)
+  if (reloc->r_symndx == -1)
+    relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
+  else if (reloc->r_symndx >= 0 && reloc->r_symndx < obj_conv_table_size (abfd))
     relent->sym_ptr_ptr = symbols + obj_convert (abfd)[reloc->r_symndx];
   else
-    relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
-
+    {
+      _bfd_error_handler
+       /* xgettext:c-format */
+       (_("%pB: warning: illegal symbol index %ld in relocs"),
+        abfd, reloc->r_symndx);
+      relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
+    }
   relent->addend = reloc->r_offset;
   relent->address -= section->vma;
 }