Automatic date update in version.in
[binutils-gdb.git] / bfd / pdp11.c
index 75ddf2038c294e51335ca79e495345ad85e2bb4e..a28af2b0c730df9c0a497595b81da56b42d7eeb7 100644 (file)
@@ -1,5 +1,5 @@
 /* BFD back-end for PDP-11 a.out binaries.
-   Copyright (C) 2001-2021 Free Software Foundation, Inc.
+   Copyright (C) 2001-2022 Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -1333,8 +1333,6 @@ aout_get_external_symbols (bfd *abfd)
 
          if (stringsize >= BYTES_IN_LONG)
            {
-             /* Keep the string count in the buffer for convenience
-                when indexing with e_strx.  */
              amt = stringsize - BYTES_IN_LONG;
              if (bfd_bread (strings + BYTES_IN_LONG, amt, abfd) != amt)
                {
@@ -1344,7 +1342,8 @@ aout_get_external_symbols (bfd *abfd)
            }
        }
       /* Ensure that a zero index yields an empty string.  */
-      strings[0] = '\0';
+      if (stringsize >= BYTES_IN_WORD)
+       memset (strings, 0, BYTES_IN_LONG);
 
       /* Ensure that the string buffer is NUL terminated.  */
       strings[stringsize] = 0;
@@ -1862,7 +1861,8 @@ pdp11_aout_swap_reloc_out (bfd *abfd, arelent *g, bfd_byte *natptr)
   if (r_extern)                                                                \
     {                                                                  \
       /* Undefined symbol.  */                                         \
-      cache_ptr->sym_ptr_ptr = symbols + r_index;                      \
+      if (r_index < bfd_get_symcount (abfd))                           \
+       cache_ptr->sym_ptr_ptr = symbols + r_index;                     \
       cache_ptr->addend = ad;                                          \
     }                                                                  \
   else                                                                 \