PowerPC: Don't generate unused section symbols
[binutils-gdb.git] / bfd / coffcode.h
index 4b934b9b2b96fb29f1e42e1d214f95720a12e07b..2fd699ff1b82818950d858a3dce2697b42f6d4a0 100644 (file)
@@ -1,5 +1,5 @@
 /* Support for the generic parts of most COFF variants, for BFD.
-   Copyright (C) 1990-2020 Free Software Foundation, Inc.
+   Copyright (C) 1990-2021 Free Software Foundation, Inc.
    Written by Cygnus Support.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -445,14 +445,6 @@ static void * coff_mkobject_hook
 static flagword handle_COMDAT
   (bfd *, flagword, void *, const char *, asection *);
 #endif
-#ifdef COFF_IMAGE_WITH_PE
-static bfd_boolean coff_read_word
-  (bfd *, unsigned int *);
-static unsigned int coff_compute_checksum
-  (bfd *);
-static bfd_boolean coff_apply_checksum
-  (bfd *);
-#endif
 #ifdef TICOFF
 static bfd_boolean ticoff0_bad_format_hook
   (bfd *, void * );
@@ -3274,11 +3266,8 @@ coff_compute_section_file_positions (bfd * abfd)
 
 #ifdef COFF_IMAGE_WITH_PE
 
-static unsigned int pelength;
-static unsigned int peheader;
-
 static bfd_boolean
-coff_read_word (bfd *abfd, unsigned int *value)
+coff_read_word (bfd *abfd, unsigned int *value, unsigned int *pelength)
 {
   unsigned char b[2];
   int status;
@@ -3295,13 +3284,13 @@ coff_read_word (bfd *abfd, unsigned int *value)
   else
     *value = (unsigned int) (b[0] + (b[1] << 8));
 
-  pelength += (unsigned int) status;
+  *pelength += status;
 
   return TRUE;
 }
 
 static unsigned int
-coff_compute_checksum (bfd *abfd)
+coff_compute_checksum (bfd *abfd, unsigned int *pelength)
 {
   bfd_boolean more_data;
   file_ptr filepos;
@@ -3309,7 +3298,7 @@ coff_compute_checksum (bfd *abfd)
   unsigned int total;
 
   total = 0;
-  pelength = 0;
+  *pelength = 0;
   filepos = (file_ptr) 0;
 
   do
@@ -3317,7 +3306,7 @@ coff_compute_checksum (bfd *abfd)
       if (bfd_seek (abfd, filepos, SEEK_SET) != 0)
        return 0;
 
-      more_data = coff_read_word (abfd, &value);
+      more_data = coff_read_word (abfd, &value, pelength);
       total += value;
       total = 0xffff & (total + (total >> 0x10));
       filepos += 2;
@@ -3332,11 +3321,13 @@ coff_apply_checksum (bfd *abfd)
 {
   unsigned int computed;
   unsigned int checksum = 0;
+  unsigned int peheader;
+  unsigned int pelength;
 
   if (bfd_seek (abfd, 0x3c, SEEK_SET) != 0)
     return FALSE;
 
-  if (!coff_read_word (abfd, &peheader))
+  if (!coff_read_word (abfd, &peheader, &pelength))
     return FALSE;
 
   if (bfd_seek (abfd, peheader + 0x58, SEEK_SET) != 0)
@@ -3348,7 +3339,7 @@ coff_apply_checksum (bfd *abfd)
   if (bfd_seek (abfd, peheader, SEEK_SET) != 0)
     return FALSE;
 
-  computed = coff_compute_checksum (abfd);
+  computed = coff_compute_checksum (abfd, &pelength);
 
   checksum = computed + pelength;
 
@@ -5829,6 +5820,7 @@ const bfd_target VAR =                                                    \
   '/',                         /* AR_pad_char.  */                     \
   15,                          /* AR_max_namelen.  */                  \
   0,                           /* match priority.  */                  \
+  TARGET_KEEP_UNUSED_SECTION_SYMBOLS, /* keep unused section symbols.  */ \
                                                                        \
   /* Data conversion functions.  */                                    \
   bfd_getb64, bfd_getb_signed_64, bfd_putb64,                          \
@@ -5890,6 +5882,7 @@ const bfd_target VAR =                                                    \
   '/',                         /* AR_pad_char.  */                     \
   15,                          /* AR_max_namelen.  */                  \
   0,                           /* match priority.  */                  \
+  TARGET_KEEP_UNUSED_SECTION_SYMBOLS, /* keep unused section symbols.  */ \
                                                                        \
   /* Data conversion functions.  */                                    \
   bfd_getb64, bfd_getb_signed_64, bfd_putb64,                          \
@@ -5951,6 +5944,7 @@ const bfd_target VAR =                                                    \
   '/',                         /* AR_pad_char.  */                     \
   15,                          /* AR_max_namelen.  */                  \
   0,                           /* match priority.  */                  \
+  TARGET_KEEP_UNUSED_SECTION_SYMBOLS, /* keep unused section symbols.  */ \
                                                                        \
   /* Data conversion functions.  */                                    \
   bfd_getl64, bfd_getl_signed_64, bfd_putl64,                          \