Make bfd_byte an int8_t, flagword a uint32_t
[binutils-gdb.git] / bfd / xcofflink.c
index 6dbcd299b883fcd278e2954d73376f5443784f8d..b57ed21afb9071611b4cbbc98ad5df8adfb17db8 100644 (file)
@@ -1,5 +1,5 @@
 /* POWER/PowerPC XCOFF linker support.
-   Copyright (C) 1995-2022 Free Software Foundation, Inc.
+   Copyright (C) 1995-2023 Free Software Foundation, Inc.
    Written by Ian Lance Taylor <ian@cygnus.com>, Cygnus Support.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -216,7 +216,7 @@ static bool xcoff_mark (struct bfd_link_info *, asection *);
 
 /* Read the contents of a section.  */
 
-static bool
+static bfd_byte *
 xcoff_get_section_contents (bfd *abfd, asection *sec)
 {
   if (coff_section_data (abfd, sec) == NULL)
@@ -225,22 +225,22 @@ xcoff_get_section_contents (bfd *abfd, asection *sec)
 
       sec->used_by_bfd = bfd_zalloc (abfd, amt);
       if (sec->used_by_bfd == NULL)
-       return false;
+       return NULL;
     }
 
-  if (coff_section_data (abfd, sec)->contents == NULL)
+  bfd_byte *contents = coff_section_data (abfd, sec)->contents;
+  if (contents == NULL)
     {
-      bfd_byte *contents;
-
-      if (! bfd_malloc_and_get_section (abfd, sec, &contents))
+      if (bfd_malloc_and_get_section (abfd, sec, &contents))
+       coff_section_data (abfd, sec)->contents = contents;
+      else
        {
          free (contents);
-         return false;
+         contents = NULL;
        }
-      coff_section_data (abfd, sec)->contents = contents;
     }
 
-  return true;
+  return contents;
 }
 
 /* Get the size required to hold the dynamic symbols.  */
@@ -259,15 +259,15 @@ _bfd_xcoff_get_dynamic_symtab_upper_bound (bfd *abfd)
     }
 
   lsec = bfd_get_section_by_name (abfd, ".loader");
-  if (lsec == NULL)
+  if (lsec == NULL || (lsec->flags & SEC_HAS_CONTENTS) == 0)
     {
       bfd_set_error (bfd_error_no_symbols);
       return -1;
     }
 
-  if (! xcoff_get_section_contents (abfd, lsec))
+  contents = xcoff_get_section_contents (abfd, lsec);
+  if (!contents)
     return -1;
-  contents = coff_section_data (abfd, lsec)->contents;
 
   bfd_xcoff_swap_ldhdr_in (abfd, (void *) contents, &ldhdr);
 
@@ -293,17 +293,15 @@ _bfd_xcoff_canonicalize_dynamic_symtab (bfd *abfd, asymbol **psyms)
     }
 
   lsec = bfd_get_section_by_name (abfd, ".loader");
-  if (lsec == NULL)
+  if (lsec == NULL || (lsec->flags & SEC_HAS_CONTENTS) == 0)
     {
       bfd_set_error (bfd_error_no_symbols);
       return -1;
     }
 
-  if (! xcoff_get_section_contents (abfd, lsec))
+  contents = xcoff_get_section_contents (abfd, lsec);
+  if (!contents)
     return -1;
-  contents = coff_section_data (abfd, lsec)->contents;
-
-  coff_section_data (abfd, lsec)->keep_contents = true;
 
   bfd_xcoff_swap_ldhdr_in (abfd, contents, &ldhdr);
 
@@ -380,15 +378,15 @@ _bfd_xcoff_get_dynamic_reloc_upper_bound (bfd *abfd)
     }
 
   lsec = bfd_get_section_by_name (abfd, ".loader");
-  if (lsec == NULL)
+  if (lsec == NULL || (lsec->flags & SEC_HAS_CONTENTS) == 0)
     {
       bfd_set_error (bfd_error_no_symbols);
       return -1;
     }
 
-  if (! xcoff_get_section_contents (abfd, lsec))
+  contents = xcoff_get_section_contents (abfd, lsec);
+  if (!contents)
     return -1;
-  contents = coff_section_data (abfd, lsec)->contents;
 
   bfd_xcoff_swap_ldhdr_in (abfd, (struct external_ldhdr *) contents, &ldhdr);
 
@@ -415,15 +413,15 @@ _bfd_xcoff_canonicalize_dynamic_reloc (bfd *abfd,
     }
 
   lsec = bfd_get_section_by_name (abfd, ".loader");
-  if (lsec == NULL)
+  if (lsec == NULL || (lsec->flags & SEC_HAS_CONTENTS) == 0)
     {
       bfd_set_error (bfd_error_no_symbols);
       return -1;
     }
 
-  if (! xcoff_get_section_contents (abfd, lsec))
+  contents = xcoff_get_section_contents (abfd, lsec);
+  if (!contents)
     return -1;
-  contents = coff_section_data (abfd, lsec)->contents;
 
   bfd_xcoff_swap_ldhdr_in (abfd, contents, &ldhdr);
 
@@ -906,7 +904,7 @@ xcoff_link_add_dynamic_symbols (bfd *abfd, struct bfd_link_info *info)
      o_snloader field in the a.out header, rather than grabbing the
      section by name.  */
   lsec = bfd_get_section_by_name (abfd, ".loader");
-  if (lsec == NULL)
+  if (lsec == NULL || (lsec->flags & SEC_HAS_CONTENTS) == 0)
     {
       _bfd_error_handler
        (_("%pB: dynamic object with no .loader section"),
@@ -915,9 +913,9 @@ xcoff_link_add_dynamic_symbols (bfd *abfd, struct bfd_link_info *info)
       return false;
     }
 
-  if (! xcoff_get_section_contents (abfd, lsec))
+  contents = xcoff_get_section_contents (abfd, lsec);
+  if (!contents)
     return false;
-  contents = coff_section_data (abfd, lsec)->contents;
 
   /* Remove the sections from this object, so that they do not get
      included in the link.  */
@@ -1044,11 +1042,8 @@ xcoff_link_add_dynamic_symbols (bfd *abfd, struct bfd_link_info *info)
        }
     }
 
-  if (contents != NULL && ! coff_section_data (abfd, lsec)->keep_contents)
-    {
-      free (coff_section_data (abfd, lsec)->contents);
-      coff_section_data (abfd, lsec)->contents = NULL;
-    }
+  free (contents);
+  coff_section_data (abfd, lsec)->contents = NULL;
 
   /* Record this file in the import files.  */
   n = bfd_alloc (abfd, (bfd_size_type) sizeof (struct xcoff_import_file));
@@ -1582,14 +1577,14 @@ xcoff_link_add_symbols (bfd *abfd, struct bfd_link_info *info)
          /* This is an external reference.  */
          if (sym.n_sclass == C_HIDEXT
              || sym.n_scnum != N_UNDEF
-             || aux.x_csect.x_scnlen.l != 0)
+             || aux.x_csect.x_scnlen.u64 != 0)
            {
              _bfd_error_handler
                /* xgettext:c-format */
                (_("%pB: bad XTY_ER symbol `%s': class %d scnum %d "
                   "scnlen %" PRId64),
                 abfd, name, sym.n_sclass, sym.n_scnum,
-                (int64_t) aux.x_csect.x_scnlen.l);
+                aux.x_csect.x_scnlen.u64);
              bfd_set_error (bfd_error_bad_value);
              goto error_return;
            }
@@ -1613,12 +1608,12 @@ xcoff_link_add_symbols (bfd *abfd, struct bfd_link_info *info)
          if (aux.x_csect.x_smclas == XMC_TC0)
            {
              if (sym.n_sclass != C_HIDEXT
-                 || aux.x_csect.x_scnlen.l != 0)
+                 || aux.x_csect.x_scnlen.u64 != 0)
                {
                  _bfd_error_handler
                    /* xgettext:c-format */
-                   (_("%pB: XMC_TC0 symbol `%s' is class %d scnlen %" PRId64),
-                    abfd, name, sym.n_sclass, (int64_t) aux.x_csect.x_scnlen.l);
+                   (_("%pB: XMC_TC0 symbol `%s' is class %d scnlen %" PRIu64),
+                    abfd, name, sym.n_sclass, aux.x_csect.x_scnlen.u64);
                  bfd_set_error (bfd_error_bad_value);
                  goto error_return;
                }
@@ -1648,9 +1643,9 @@ xcoff_link_add_symbols (bfd *abfd, struct bfd_link_info *info)
              && sym.n_sclass == C_HIDEXT
              && info->output_bfd->xvec == abfd->xvec
              && ((bfd_xcoff_is_xcoff32 (abfd)
-                  && aux.x_csect.x_scnlen.l == 4)
+                  && aux.x_csect.x_scnlen.u64 == 4)
                  || (bfd_xcoff_is_xcoff64 (abfd)
-                     && aux.x_csect.x_scnlen.l == 8)))
+                     && aux.x_csect.x_scnlen.u64 == 8)))
            {
              asection *enclosing;
              struct internal_reloc *relocs;
@@ -1781,7 +1776,7 @@ xcoff_link_add_symbols (bfd *abfd, struct bfd_link_info *info)
 
            if (! bfd_is_abs_section (enclosing)
                && ((bfd_vma) sym.n_value < enclosing->vma
-                   || ((bfd_vma) sym.n_value + aux.x_csect.x_scnlen.l
+                   || (sym.n_value + aux.x_csect.x_scnlen.u64
                        > enclosing->vma + enclosing->size)))
              {
                _bfd_error_handler
@@ -1795,8 +1790,8 @@ xcoff_link_add_symbols (bfd *abfd, struct bfd_link_info *info)
            csect->filepos = (enclosing->filepos
                              + sym.n_value
                              - enclosing->vma);
-           csect->size = aux.x_csect.x_scnlen.l;
-           csect->rawsize = aux.x_csect.x_scnlen.l;
+           csect->size = aux.x_csect.x_scnlen.u64;
+           csect->rawsize = aux.x_csect.x_scnlen.u64;
            csect->flags |= SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS;
            csect->alignment_power = SMTYP_ALIGN (aux.x_csect.x_smtyp);
 
@@ -1881,13 +1876,12 @@ xcoff_link_add_symbols (bfd *abfd, struct bfd_link_info *info)
            bool bad;
 
            bad = false;
-           if (aux.x_csect.x_scnlen.l < 0
-               || (aux.x_csect.x_scnlen.l
-                   >= esym - (bfd_byte *) obj_coff_external_syms (abfd)))
+           if (aux.x_csect.x_scnlen.u64
+               >= (size_t) (esym - (bfd_byte *) obj_coff_external_syms (abfd)))
              bad = true;
            if (! bad)
              {
-               section = xcoff_data (abfd)->csects[aux.x_csect.x_scnlen.l];
+               section = xcoff_data (abfd)->csects[aux.x_csect.x_scnlen.u64];
                if (section == NULL
                    || (section->flags & SEC_HAS_CONTENTS) == 0)
                  bad = true;
@@ -1934,7 +1928,7 @@ xcoff_link_add_symbols (bfd *abfd, struct bfd_link_info *info)
          if (csect == NULL)
            goto error_return;
          csect->vma = sym.n_value;
-         csect->size = aux.x_csect.x_scnlen.l;
+         csect->size = aux.x_csect.x_scnlen.u64;
          csect->alignment_power = SMTYP_ALIGN (aux.x_csect.x_smtyp);
          /* There are a number of other fields and section flags
             which we do not bother to set.  */
@@ -1961,7 +1955,7 @@ xcoff_link_add_symbols (bfd *abfd, struct bfd_link_info *info)
              csect->flags |= SEC_IS_COMMON;
              csect->size = 0;
              section = csect;
-             value = aux.x_csect.x_scnlen.l;
+             value = aux.x_csect.x_scnlen.u64;
            }
 
          break;
@@ -2306,8 +2300,7 @@ xcoff_link_add_symbols (bfd *abfd, struct bfd_link_info *info)
 
          /* If we are not keeping memory, free the reloc information.  */
          if (! info->keep_memory
-             && coff_section_data (abfd, o) != NULL
-             && ! coff_section_data (abfd, o)->keep_relocs)
+             && coff_section_data (abfd, o) != NULL)
            {
              free (coff_section_data (abfd, o)->relocs);
              coff_section_data (abfd, o)->relocs = NULL;
@@ -2379,13 +2372,13 @@ xcoff_link_check_dynamic_ar_symbols (bfd *abfd,
   *pneeded = false;
 
   lsec = bfd_get_section_by_name (abfd, ".loader");
-  if (lsec == NULL)
+  if (lsec == NULL || (lsec->flags & SEC_HAS_CONTENTS) == 0)
     /* There are no symbols, so don't try to include it.  */
     return true;
 
-  if (! xcoff_get_section_contents (abfd, lsec))
+  contents = xcoff_get_section_contents (abfd, lsec);
+  if (!contents)
     return false;
-  contents = coff_section_data (abfd, lsec)->contents;
 
   bfd_xcoff_swap_ldhdr_in (abfd, contents, &ldhdr);
 
@@ -2434,12 +2427,9 @@ xcoff_link_check_dynamic_ar_symbols (bfd *abfd,
        }
     }
 
-  /* We do not need this shared object.  */
-  if (contents != NULL && ! coff_section_data (abfd, lsec)->keep_contents)
-    {
-      free (coff_section_data (abfd, lsec)->contents);
-      coff_section_data (abfd, lsec)->contents = NULL;
-    }
+  /* We do not need this shared object's .loader section.  */
+  free (contents);
+  coff_section_data (abfd, lsec)->contents = NULL;
 
   return true;
 }
@@ -3142,8 +3132,7 @@ xcoff_mark (struct bfd_link_info *info, asection *sec)
        }
 
       if (! info->keep_memory
-         && coff_section_data (sec->owner, sec) != NULL
-         && ! coff_section_data (sec->owner, sec)->keep_relocs)
+         && coff_section_data (sec->owner, sec) != NULL)
        {
          free (coff_section_data (sec->owner, sec)->relocs);
          coff_section_data (sec->owner, sec)->relocs = NULL;
@@ -4138,7 +4127,9 @@ bfd_xcoff_build_dynamic_sections (bfd *output_bfd,
        {
          /* Grab the contents of SUB's .debug section, if any.  */
          subdeb = bfd_get_section_by_name (sub, ".debug");
-         if (subdeb != NULL && subdeb->size > 0)
+         if (subdeb != NULL
+             && subdeb->size != 0
+             && (subdeb->flags & SEC_HAS_CONTENTS) != 0)
            {
              /* We use malloc and copy the names into the debug
                 stringtab, rather than bfd_alloc, because I expect
@@ -4316,9 +4307,10 @@ bfd_xcoff_link_generate_rtinit (bfd *abfd,
 
 /* Get the name of a csect which will contain stubs.
    It has the same pattern as AIX linker: @FIX"number".  */
-static char * xcoff_stub_csect_name (unsigned int n)
+static char *
+xcoff_stub_csect_name (unsigned int n)
 {
-  char buf[6];
+  char buf[8];
   size_t len;
   char *csect_name;
 
@@ -4360,30 +4352,30 @@ xcoff_stub_get_csect_in_range (asection *section,
        csect = csect->next, it++)
     {
       /* A csect is in range if everything instructions in SECTION
-         can branch to every stubs in the stub csect.  This can
+        can branch to every stubs in the stub csect.  This can
         be simplify by saying that the first entry of each sections
         (ie the vma of this section) can reach the last entry of the
         stub csect (ie the vma of the csect + its size).
-         However, as the stub csect might be growing its size isn't
-         fixed.  Thus, the last entry of SECTION might not be able
-         to reach the first entry of the stub csect anymore.
-         If this case happens, the following condition will be
-         false during the next pass of bfd_xcoff_size_stubs and
-         another csect will be used.
-         This means we might create more stubs than needed.  */
+        However, as the stub csect might be growing its size isn't
+        fixed.  Thus, the last entry of SECTION might not be able
+        to reach the first entry of the stub csect anymore.
+        If this case happens, the following condition will be
+        false during the next pass of bfd_xcoff_size_stubs and
+        another csect will be used.
+        This means we might create more stubs than needed.  */
       bfd_vma csect_vma, section_vma;
       bfd_vma csect_last_vma, section_last_vma;
 
       csect_vma = (csect->output_section->vma
-                       + csect->output_offset);
+                  + csect->output_offset);
       csect_last_vma = (csect->output_section->vma
                        + csect->output_offset
                        + csect->size);
       section_vma = (section->output_section->vma
                     + section->output_offset);
       section_last_vma = (section->output_section->vma
-                    + section->output_offset
-                    + section->size);
+                         + section->output_offset
+                         + section->size);
 
       if (csect_last_vma - section_vma + (1 << 25) < 2 * (1 << 25)
          && section_last_vma - csect_vma + (1 << 25) < 2 * (1 << 25))
@@ -4689,7 +4681,7 @@ xcoff_build_one_stub (struct bfd_hash_entry *gen_entry, void *in_arg)
   if (hstub->target_section != NULL
       && hstub->target_section->output_section == NULL
       && info->non_contiguous_regions)
-    info->callbacks->einfo (_("%F%P: Could not assign '%pA' to an output section. "
+    info->callbacks->einfo (_("%F%P: Could not assign `%pA' to an output section. "
                              "Retry without --enable-non-contiguous-regions.\n"),
                            hstub->target_section);
 
@@ -4703,7 +4695,7 @@ xcoff_build_one_stub (struct bfd_hash_entry *gen_entry, void *in_arg)
       BFD_ASSERT (hstub->htarget->toc_section != NULL);
       /* The first instruction in the stub code needs to be
         cooked to hold the correct offset in the toc.  It will
-         be filled by xcoff_stub_create_relocations.  */
+        be filled by xcoff_stub_create_relocations.  */
       for (i = 0; i < bfd_xcoff_stub_indirect_call_size(output_bfd) / 4; i++)
        bfd_put_32 (stub_bfd,
                    (bfd_vma) bfd_xcoff_stub_indirect_call_code(output_bfd, i),
@@ -4714,7 +4706,7 @@ xcoff_build_one_stub (struct bfd_hash_entry *gen_entry, void *in_arg)
       BFD_ASSERT (hstub->htarget->toc_section != NULL);
       /* The first instruction in the glink code needs to be
         cooked to hold the correct offset in the toc.  It will
-         be filled by xcoff_stub_create_relocations.  */
+        be filled by xcoff_stub_create_relocations.  */
       for (i = 0; i < bfd_xcoff_stub_shared_call_size(output_bfd) / 4; i++)
        bfd_put_32 (stub_bfd,
                    (bfd_vma) bfd_xcoff_stub_shared_call_code(output_bfd, i),
@@ -4871,7 +4863,7 @@ bfd_xcoff_size_stubs (struct bfd_link_info *info)
                      _bfd_error_handler (_("%pB: Unable to find a stub csect in range"
                                            "of relocation at %#" PRIx64 " targeting"
                                            "'%s'"),
-                                         section->owner, irel->r_vaddr,
+                                         section->owner, (uint64_t) irel->r_vaddr,
                                          hsym->root.root.string);
                      goto error_ret;
                    }
@@ -4896,10 +4888,10 @@ bfd_xcoff_size_stubs (struct bfd_link_info *info)
                  hstub = xcoff_add_stub (stub_name, hstub_csect, hsym, info, stub_type);
                  if (hstub == NULL)
                    {
-                     free (stub_name);
                      /* xgettext:c-format */
                      _bfd_error_handler (_("%pB: Cannot create stub entry '%s'"),
                                          section->owner, stub_name);
+                     free (stub_name);
                      goto error_ret;
                    }
 
@@ -4999,7 +4991,7 @@ xcoff_stub_create_relocations (struct bfd_hash_entry *bh, void * inf)
       return false;
 
       /* The first instruction of this stub code need
-         a R_TOC relocation.  */
+        a R_TOC relocation.  */
     case xcoff_stub_indirect_call:
     case xcoff_stub_shared_call:
       irel->r_size = 0xf;
@@ -5563,7 +5555,7 @@ xcoff_link_input_bfd (struct xcoff_final_link_info *flinfo,
                    {
                      unsigned long indx;
 
-                     indx = aux.x_csect.x_scnlen.l;
+                     indx = aux.x_csect.x_scnlen.u64;
                      if (indx < obj_raw_syment_count (input_bfd))
                        {
                          long symindx;
@@ -5571,11 +5563,11 @@ xcoff_link_input_bfd (struct xcoff_final_link_info *flinfo,
                          symindx = flinfo->sym_indices[indx];
                          if (symindx < 0)
                            {
-                             aux.x_csect.x_scnlen.l = 0;
+                             aux.x_csect.x_scnlen.u64 = 0;
                            }
                          else
                            {
-                             aux.x_csect.x_scnlen.l = symindx;
+                             aux.x_csect.x_scnlen.u64 = symindx;
                            }
                        }
                    }
@@ -5589,7 +5581,7 @@ xcoff_link_input_bfd (struct xcoff_final_link_info *flinfo,
                      || isymp->n_sclass == C_BLOCK
                      || isymp->n_sclass == C_FCN)
                    {
-                     indx = aux.x_sym.x_fcnary.x_fcn.x_endndx.l;
+                     indx = aux.x_sym.x_fcnary.x_fcn.x_endndx.u32;
                      if (indx > 0
                          && indx < obj_raw_syment_count (input_bfd))
                        {
@@ -5604,21 +5596,21 @@ xcoff_link_input_bfd (struct xcoff_final_link_info *flinfo,
                            indx = output_index;
                          else
                            indx = flinfo->sym_indices[indx];
-                         aux.x_sym.x_fcnary.x_fcn.x_endndx.l = indx;
+                         aux.x_sym.x_fcnary.x_fcn.x_endndx.u32 = indx;
 
                        }
                    }
 
-                 indx = aux.x_sym.x_tagndx.l;
+                 indx = aux.x_sym.x_tagndx.u32;
                  if (indx > 0 && indx < obj_raw_syment_count (input_bfd))
                    {
                      long symindx;
 
                      symindx = flinfo->sym_indices[indx];
                      if (symindx < 0)
-                       aux.x_sym.x_tagndx.l = 0;
+                       aux.x_sym.x_tagndx.u32 = 0;
                      else
-                       aux.x_sym.x_tagndx.l = symindx;
+                       aux.x_sym.x_tagndx.u32 = symindx;
                    }
 
                }
@@ -6215,7 +6207,7 @@ xcoff_find_tc0 (bfd *output_bfd, struct xcoff_final_link_info *flinfo)
   memset (&iraux, 0, sizeof iraux);
   iraux.x_csect.x_smtyp = XTY_SD;
   iraux.x_csect.x_smclas = XMC_TC0;
-  iraux.x_csect.x_scnlen.l = 0;
+  iraux.x_csect.x_scnlen.u64 = 0;
   bfd_coff_swap_aux_out (output_bfd, &iraux, T_NULL, C_HIDEXT, 0, 1,
                         flinfo->outsyms + bfd_coff_symesz (output_bfd));
 
@@ -6431,7 +6423,7 @@ xcoff_write_global_symbol (struct bfd_hash_entry *bh, void * inf)
         whether the output is 32 or 64 bit.  */
       memset (&iraux, 0, sizeof iraux);
       iraux.x_csect.x_smtyp = XTY_SD;
-      /* iraux.x_csect.x_scnlen.l = 4 or 8, see below.  */
+      /* iraux.x_csect.x_scnlen.u64 = 4 or 8, see below.  */
       iraux.x_csect.x_smclas = XMC_TC;
 
       /* 32 bit uses a 32 bit R_POS to do the relocations
@@ -6443,12 +6435,12 @@ xcoff_write_global_symbol (struct bfd_hash_entry *bh, void * inf)
       if (bfd_xcoff_is_xcoff64 (output_bfd))
        {
          irel->r_size = 63;
-         iraux.x_csect.x_scnlen.l = 8;
+         iraux.x_csect.x_scnlen.u64 = 8;
        }
       else if (bfd_xcoff_is_xcoff32 (output_bfd))
        {
          irel->r_size = 31;
-         iraux.x_csect.x_scnlen.l = 4;
+         iraux.x_csect.x_scnlen.u64 = 4;
        }
       else
        return false;
@@ -6723,7 +6715,7 @@ xcoff_write_global_symbol (struct bfd_hash_entry *bh, void * inf)
       /* For stub symbols, the section already has its correct size.  */
       if (h->root.u.def.section->owner == xcoff_hash_table (flinfo->info)->params->stub_bfd)
        {
-         aux.x_csect.x_scnlen.l = h->root.u.def.section->size;
+         aux.x_csect.x_scnlen.u64 = h->root.u.def.section->size;
        }
       else if ((h->flags & XCOFF_HAS_SIZE) != 0)
        {
@@ -6733,7 +6725,7 @@ xcoff_write_global_symbol (struct bfd_hash_entry *bh, void * inf)
            {
              if (l->h == h)
                {
-                 aux.x_csect.x_scnlen.l = l->size;
+                 aux.x_csect.x_scnlen.u64 = l->size;
                  break;
                }
            }
@@ -6746,7 +6738,7 @@ xcoff_write_global_symbol (struct bfd_hash_entry *bh, void * inf)
       isym.n_scnum = h->root.u.c.p->section->output_section->target_index;
       isym.n_sclass = C_EXT;
       aux.x_csect.x_smtyp = XTY_CM;
-      aux.x_csect.x_scnlen.l = h->root.u.c.size;
+      aux.x_csect.x_scnlen.u64 = h->root.u.c.size;
     }
   else
     abort ();
@@ -6778,7 +6770,7 @@ xcoff_write_global_symbol (struct bfd_hash_entry *bh, void * inf)
       outsym += bfd_coff_symesz (output_bfd);
 
       aux.x_csect.x_smtyp = XTY_LD;
-      aux.x_csect.x_scnlen.l = obj_raw_syment_count (output_bfd);
+      aux.x_csect.x_scnlen.u64 = obj_raw_syment_count (output_bfd);
       bfd_coff_swap_aux_out (output_bfd, (void *) &aux, T_NULL, C_EXT, 0, 1,
                             (void *) outsym);
       outsym += bfd_coff_auxesz (output_bfd);