Make bfd_byte an int8_t, flagword a uint32_t
[binutils-gdb.git] / bfd / coffcode.h
index bf55d83530d8fa0867265e11472f7c97226ca7ea..594f3e0457b0bd2759fa23de0ba0bc8143081bd9 100644 (file)
@@ -294,27 +294,30 @@ CODE_FRAGMENT
 .typedef struct coff_ptr_struct
 .{
 .  {* Remembers the offset from the first symbol in the file for
-.     this symbol. Generated by coff_renumber_symbols.  *}
+.     this symbol.  Generated by coff_renumber_symbols.  *}
 .  unsigned int offset;
 .
-.  {* Should the value of this symbol be renumbered.  Used for
-.     XCOFF C_BSTAT symbols.  Set by coff_slurp_symbol_table.  *}
-.  unsigned int fix_value : 1;
+.  {* Selects between the elements of the union below.  *}
+.  unsigned int is_sym : 1;
 .
-.  {* Should the tag field of this symbol be renumbered.
-.     Created by coff_pointerize_aux.  *}
+.  {* Selects between the elements of the x_sym.x_tagndx union.  If set,
+.     p is valid and the field will be renumbered.  *}
 .  unsigned int fix_tag : 1;
 .
-.  {* Should the endidx field of this symbol be renumbered.
-.     Created by coff_pointerize_aux.  *}
+.  {* Selects between the elements of the x_sym.x_fcnary.x_fcn.x_endndx
+.     union.  If set, p is valid and the field will be renumbered.  *}
 .  unsigned int fix_end : 1;
 .
-.  {* Should the x_csect.x_scnlen field be renumbered.
-.     Created by coff_pointerize_aux.  *}
+.  {* Selects between the elements of the x_csect.x_scnlen union.  If set,
+.     p is valid and the field will be renumbered.  *}
 .  unsigned int fix_scnlen : 1;
 .
-.  {* Fix up an XCOFF C_BINCL/C_EINCL symbol.  The value is the
-.     index into the line number entries.  Set by coff_slurp_symbol_table.  *}
+.  {* If set, u.syment.n_value contains a pointer to a symbol.  The final
+.     value will be the offset field.  Used for XCOFF C_BSTAT symbols.  *}
+.  unsigned int fix_value : 1;
+.
+.  {* If set, u.syment.n_value is an index into the line number entries.
+.     Used for XCOFF C_BINCL/C_EINCL symbols.  *}
 .  unsigned int fix_line : 1;
 .
 .  {* The container for the symbol structure as read and translated
@@ -325,9 +328,6 @@ CODE_FRAGMENT
 .    struct internal_syment syment;
 .  } u;
 .
-. {* Selector for the union above.  *}
-. bool is_sym;
-.
 . {* An extra pointer which can used by format based on COFF (like XCOFF)
 .    to provide extra information to their backend.  *}
 . void *extrap;
@@ -2463,10 +2463,10 @@ coff_pointerize_aux_hook (bfd *abfd ATTRIBUTE_UNUSED,
     {
       BFD_ASSERT (! aux->is_sym);
       if (SMTYP_SMTYP (aux->u.auxent.x_csect.x_smtyp) == XTY_LD
-         && (bfd_vma) aux->u.auxent.x_csect.x_scnlen.l < obj_raw_syment_count (abfd))
+         && aux->u.auxent.x_csect.x_scnlen.u64 < obj_raw_syment_count (abfd))
        {
          aux->u.auxent.x_csect.x_scnlen.p =
-           table_base + aux->u.auxent.x_csect.x_scnlen.l;
+           table_base + aux->u.auxent.x_csect.x_scnlen.u64;
          aux->fix_scnlen = 1;
        }
 
@@ -2505,21 +2505,21 @@ coff_print_aux (bfd *abfd ATTRIBUTE_UNUSED,
       if (SMTYP_SMTYP (aux->u.auxent.x_csect.x_smtyp) != XTY_LD)
        {
          BFD_ASSERT (! aux->fix_scnlen);
-         fprintf (file, "val %5" PRId64,
-                  (int64_t) aux->u.auxent.x_csect.x_scnlen.l);
+         fprintf (file, "val %5" PRIu64,
+                  aux->u.auxent.x_csect.x_scnlen.u64);
        }
       else
        {
          fprintf (file, "indx ");
          if (! aux->fix_scnlen)
-           fprintf (file, "%4" PRId64,
-                    (int64_t) aux->u.auxent.x_csect.x_scnlen.l);
+           fprintf (file, "%4" PRIu64,
+                    aux->u.auxent.x_csect.x_scnlen.u64);
          else
            fprintf (file, "%4ld",
                     (long) (aux->u.auxent.x_csect.x_scnlen.p - table_base));
        }
       fprintf (file,
-              " prmhsh %ld snhsh %u typ %d algn %d clss %u stb %ld snstb %u",
+              " prmhsh %u snhsh %u typ %d algn %d clss %u stb %u snstb %u",
               aux->u.auxent.x_csect.x_parmhash,
               (unsigned int) aux->u.auxent.x_csect.x_snhash,
               SMTYP_SMTYP (aux->u.auxent.x_csect.x_smtyp),
@@ -4852,13 +4852,18 @@ coff_slurp_symbol_table (bfd * abfd)
            case C_BSTAT:
              dst->symbol.flags = BSF_DEBUGGING;
 
-             /* The value is actually a symbol index.  Save a pointer
-                to the symbol instead of the index.  FIXME: This
-                should use a union.  */
-             src->u.syment.n_value
-               = (uintptr_t) (native_symbols + src->u.syment.n_value);
-             dst->symbol.value = src->u.syment.n_value;
-             src->fix_value = 1;
+             if (src->u.syment.n_value >= obj_raw_syment_count (abfd))
+               dst->symbol.value = 0;
+             else
+               {
+                 /* The value is actually a symbol index.  Save a pointer
+                    to the symbol instead of the index.  FIXME: This
+                    should use a union.  */
+                 src->u.syment.n_value
+                   = (uintptr_t) (native_symbols + src->u.syment.n_value);
+                 dst->symbol.value = src->u.syment.n_value;
+                 src->fix_value = 1;
+               }
              break;
 #endif
 
@@ -5028,11 +5033,11 @@ coff_classify_symbol (bfd *abfd,
         breaks gas generated objects.  */
       if (syment->n_value == 0)
        {
-         asection *sec;
-         char * name;
+         const asection *sec;
+         const char *name;
          char buf[SYMNMLEN + 1];
 
-         name = _bfd_coff_internal_syment_name (abfd, syment, buf)
+         name = _bfd_coff_internal_syment_name (abfd, syment, buf);
          sec = coff_section_from_bfd_index (abfd, syment->n_scnum);
          if (sec != NULL && name != NULL
              && (strcmp (bfd_section_name (sec), name) == 0))
@@ -5745,7 +5750,7 @@ coff_bigobj_swap_aux_in (bfd *abfd,
       break;
 
     default:
-      in->x_sym.x_tagndx.l = H_GET_32 (abfd, ext->Sym.WeakDefaultSymIndex);
+      in->x_sym.x_tagndx.u32 = H_GET_32 (abfd, ext->Sym.WeakDefaultSymIndex);
       /* Characteristics is ignored.  */
       break;
     }
@@ -5793,7 +5798,7 @@ coff_bigobj_swap_aux_out (bfd * abfd,
       break;
     }
 
-  H_PUT_32 (abfd, in->x_sym.x_tagndx.l, ext->Sym.WeakDefaultSymIndex);
+  H_PUT_32 (abfd, in->x_sym.x_tagndx.u32, ext->Sym.WeakDefaultSymIndex);
   H_PUT_32 (abfd, 1, ext->Sym.WeakSearchType);
 
   return AUXESZ;