Retain .debug_addr sections loaded in the main file.
[deliverable/binutils-gdb.git] / bfd / coff-alpha.c
index b86a8a259b584dd30481389b398fa4f6851ca932..8031ab9590274ff1ae68b7dea55adb35ba626610 100644 (file)
@@ -1,5 +1,5 @@
 /* BFD back-end for ALPHA Extended-Coff files.
-   Copyright (C) 1993-2020 Free Software Foundation, Inc.
+   Copyright (C) 1993-2021 Free Software Foundation, Inc.
    Modified from coff-mips.c by Steve Chamberlain <sac@cygnus.com> and
    Ian Lance Taylor <ian@cygnus.com>.
 
@@ -732,25 +732,31 @@ alpha_ecoff_get_relocated_section_contents (bfd *abfd,
 {
   bfd *input_bfd = link_order->u.indirect.section->owner;
   asection *input_section = link_order->u.indirect.section;
-  long reloc_size = bfd_get_reloc_upper_bound (input_bfd, input_section);
-  arelent **reloc_vector = NULL;
+  long reloc_size;
+  arelent **reloc_vector;
   long reloc_count;
   bfd *output_bfd = relocatable ? abfd : (bfd *) NULL;
   bfd_vma gp;
-  bfd_size_type sz;
   bfd_boolean gp_undefined;
   bfd_vma stack[RELOC_STACKSIZE];
   int tos = 0;
 
+  reloc_size = bfd_get_reloc_upper_bound (input_bfd, input_section);
   if (reloc_size < 0)
-    goto error_return;
-  reloc_vector = (arelent **) bfd_malloc ((bfd_size_type) reloc_size);
-  if (reloc_vector == NULL && reloc_size != 0)
-    goto error_return;
+    return NULL;
 
-  sz = input_section->rawsize ? input_section->rawsize : input_section->size;
-  if (! bfd_get_section_contents (input_bfd, input_section, data, 0, sz))
-    goto error_return;
+  if (!bfd_get_full_section_contents (input_bfd, input_section, &data))
+    return NULL;
+
+  if (data == NULL)
+    return NULL;
+
+  if (reloc_size == 0)
+    return data;
+
+  reloc_vector = (arelent **) bfd_malloc (reloc_size);
+  if (reloc_vector == NULL)
+    return NULL;
 
   reloc_count = bfd_canonicalize_reloc (input_bfd, input_section,
                                        reloc_vector, symbols);
@@ -1127,13 +1133,11 @@ alpha_ecoff_get_relocated_section_contents (bfd *abfd,
     abort ();
 
  successful_return:
-  if (reloc_vector != NULL)
-    free (reloc_vector);
+  free (reloc_vector);
   return data;
 
  error_return:
-  if (reloc_vector != NULL)
-    free (reloc_vector);
+  free (reloc_vector);
   return NULL;
 }
 
@@ -2130,7 +2134,7 @@ alpha_ecoff_get_elt_at_filepos (bfd *archive, file_ptr filepos)
                n = dict[h];
              else
                {
-                 if (! bfd_bread (&n, (bfd_size_type) 1, nbfd))
+                 if (bfd_bread (&n, 1, nbfd) != 1)
                    goto error_return;
                  dict[h] = n;
                }
@@ -2171,8 +2175,7 @@ alpha_ecoff_get_elt_at_filepos (bfd *archive, file_ptr filepos)
   return nbfd;
 
  error_return:
-  if (buf != NULL)
-    free (buf);
+  free (buf);
   if (nbfd != NULL)
     bfd_close (nbfd);
   return NULL;
@@ -2430,6 +2433,7 @@ const bfd_target alpha_ecoff_le_vec =
   ' ',                         /* ar_pad_char */
   15,                          /* ar_max_namelen */
   0,                           /* match priority.  */
+  TARGET_KEEP_UNUSED_SECTION_SYMBOLS, /* keep unused section symbols.  */
   bfd_getl64, bfd_getl_signed_64, bfd_putl64,
      bfd_getl32, bfd_getl_signed_32, bfd_putl32,
      bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
This page took 0.023964 seconds and 4 git commands to generate.