gdb/jit: return bool in jit_breakpoint_re_set_internal and jit_read_descriptor
[deliverable/binutils-gdb.git] / gas / config / obj-aout.c
index 0c89ba2c9211cec0cd0d25b6e538d177fed851b6..aee7c8180a28ad4de8dc997341f953261767c166 100644 (file)
@@ -1,6 +1,5 @@
 /* a.out object file format
-   Copyright 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1999, 2000,
-   2001, 2002, 2003, 2004, 2005, 2007 Free Software Foundation, Inc.
+   Copyright (C) 1989-2020 Free Software Foundation, Inc.
 
    This file is part of GAS, the GNU Assembler.
 
 #include "as.h"
 #undef NO_RELOC
 #include "aout/aout64.h"
-#include "obstack.h"
 
 void
 obj_aout_frob_symbol (symbolS *sym, int *punt ATTRIBUTE_UNUSED)
 {
   flagword flags;
   asection *sec;
-  int desc, type, other;
+  int type;
 
   flags = symbol_get_bfdsym (sym)->flags;
-  desc = aout_symbol (symbol_get_bfdsym (sym))->desc;
   type = aout_symbol (symbol_get_bfdsym (sym))->type;
-  other = aout_symbol (symbol_get_bfdsym (sym))->other;
   sec = S_GET_SEGMENT (sym);
 
   /* Only frob simple symbols this way right now.  */
   if (! (type & ~ (N_TYPE | N_EXT)))
     {
       if (type == (N_UNDF | N_EXT)
-         && sec == &bfd_abs_section)
+         && sec == bfd_abs_section_ptr)
        {
          sec = bfd_und_section_ptr;
          S_SET_SEGMENT (sym, sec);
@@ -55,8 +51,8 @@ obj_aout_frob_symbol (symbolS *sym, int *punt ATTRIBUTE_UNUSED)
          && (type & N_TYPE) != N_SETD
          && (type & N_TYPE) != N_SETB
          && type != N_WARNING
-         && (sec == &bfd_abs_section
-             || sec == &bfd_und_section))
+         && (sec == bfd_abs_section_ptr
+             || sec == bfd_und_section_ptr))
        return;
       if (flags & BSF_EXPORT)
        type |= N_EXT;
@@ -117,22 +113,40 @@ obj_aout_frob_symbol (symbolS *sym, int *punt ATTRIBUTE_UNUSED)
            S_GET_NAME (sym));
 }
 
+/* Relocation processing may require knowing the VMAs of the sections.
+   Writing to a section will cause the BFD back end to compute the
+   VMAs.  This function also ensures that file size is large enough
+   to cover a_text and a_data should text or data be the last section
+   in the file.  */
+
 void
 obj_aout_frob_file_before_fix (void)
 {
-  /* Relocation processing may require knowing the VMAs of the sections.
-     Since writing to a section will cause the BFD back end to compute the
-     VMAs, fake it out here....  */
-  bfd_byte b = 0;
-  bfd_boolean x = TRUE;
-  if (bfd_section_size (stdoutput, text_section) != 0)
-    x = bfd_set_section_contents (stdoutput, text_section, &b, (file_ptr) 0,
-                                 (bfd_size_type) 1);
-  else if (bfd_section_size (stdoutput, data_section) != 0)
-    x = bfd_set_section_contents (stdoutput, data_section, &b, (file_ptr) 0,
-                                 (bfd_size_type) 1);
-
-  gas_assert (x);
+  asection *sec;
+  bfd_vma *sizep = NULL;
+  if ((sec = data_section)->size != 0)
+    sizep = &exec_hdr (stdoutput)->a_data;
+  else if ((sec = text_section)->size != 0)
+    sizep = &exec_hdr (stdoutput)->a_text;
+  if (sizep)
+    {
+      bfd_size_type size = sec->size;
+      bfd_byte b = 0;
+
+      gas_assert (bfd_set_section_contents (stdoutput, sec, &b, size - 1, 1));
+
+      /* We don't know the aligned size until after VMAs and sizes are
+        set on the bfd_set_section_contents call.  If that size is
+        larger than the section then write again to ensure the file
+        contents extend to cover the aligned size.  */
+      if (*sizep > size)
+       {
+         file_ptr pos = sec->filepos + *sizep;
+
+         gas_assert (bfd_seek (stdoutput, pos - 1, SEEK_SET) == 0
+                     && bfd_bwrite (&b, 1, stdoutput) == 1);
+       }
+    }
 }
 
 static void
@@ -156,10 +170,9 @@ obj_aout_weak (int ignore ATTRIBUTE_UNUSED)
 
   do
     {
-      name = input_line_pointer;
-      c = get_symbol_end ();
+      c = get_symbol_name (&name);
       symbolP = symbol_find_or_make (name);
-      *input_line_pointer = c;
+      (void) restore_line_pointer (c);
       SKIP_WHITESPACE ();
       S_SET_WEAK (symbolP);
       if (c == ',')
@@ -186,10 +199,9 @@ obj_aout_type (int ignore ATTRIBUTE_UNUSED)
   int c;
   symbolS *sym;
 
-  name = input_line_pointer;
-  c = get_symbol_end ();
+  c = get_symbol_name (&name);
   sym = symbol_find_or_make (name);
-  *input_line_pointer = c;
+  (void) restore_line_pointer (c);
   SKIP_WHITESPACE ();
   if (*input_line_pointer == ',')
     {
@@ -310,7 +322,9 @@ const struct format_ops aout_format_ops =
   aout_pop_insert,
   0,   /* ecoff_set_ext.  */
   0,   /* read_begin_hook.  */
-  0    /* symbol_new_hook.  */
+  0,   /* symbol_new_hook.  */
+  0,   /* symbol_clone_hook.  */
+  0    /* adjust_symtab.  */
 };
 
 const pseudo_typeS aout_pseudo_table[] =
This page took 0.030259 seconds and 4 git commands to generate.