Add weak symbols as an extension to a.out.
authorIan Lance Taylor <ian@airs.com>
Sat, 11 Jun 1994 20:45:49 +0000 (20:45 +0000)
committerIan Lance Taylor <ian@airs.com>
Sat, 11 Jun 1994 20:45:49 +0000 (20:45 +0000)
* read.c (pseudo_set): Only preserve external bit for OBJ_AOUT and
OBJ_BOUT if not BFD_ASSEMBLER.
* config/aout_gnu.h (N_WEAKU, N_WEAKA, N_WEAKT, N_WEAKD, N_WEAKB):
Define as in ../include/aout/aout64.h.
* config/obj-aout.h (OBJ_SYMFIELD_TYPE): If not BFD_ASSEMBLER,
define as char.
(S_GET_WEAK, S_SET_WEAK): Define if not BFD_ASSEMBLER.
* config/obj-aout.c (obj_pseudo_table): Add "weak".
(obj_emit_symbols): Adjust type of weak symbols.
(obj_aout_weak): New static function.

gas/ChangeLog
gas/config/obj-aout.c

index 8b77ff0..17cdc36 100644 (file)
@@ -1,3 +1,17 @@
+Sat Jun 11 16:41:21 1994  Ian Lance Taylor  (ian@tweedledumb.cygnus.com)
+
+       Add weak symbols as an extension to a.out.
+       * read.c (pseudo_set): Only preserve external bit for OBJ_AOUT and
+       OBJ_BOUT if not BFD_ASSEMBLER.
+       * config/aout_gnu.h (N_WEAKU, N_WEAKA, N_WEAKT, N_WEAKD, N_WEAKB):
+       Define as in ../include/aout/aout64.h.
+       * config/obj-aout.h (OBJ_SYMFIELD_TYPE): If not BFD_ASSEMBLER,
+       define as char.
+       (S_GET_WEAK, S_SET_WEAK): Define if not BFD_ASSEMBLER.
+       * config/obj-aout.c (obj_pseudo_table): Add "weak".
+       (obj_emit_symbols): Adjust type of weak symbols.
+       (obj_aout_weak): New static function.
+
 Fri Jun 10 13:48:49 1994  Ian Lance Taylor  (ian@tweedledumb.cygnus.com)
 
        * config/obj-elf.c (obj_elf_section): Don't set any flags based on
index 944d8e0..00e7794 100644 (file)
@@ -62,12 +62,15 @@ const segT N_TYPE_seg[N_TYPE + 2] =
 #endif
 
 static void obj_aout_line PARAMS ((int));
+static void obj_aout_weak PARAMS ((int));
 
 const pseudo_typeS obj_pseudo_table[] =
 {
   {"line", obj_aout_line, 0},  /* source code line number */
   {"ln", obj_aout_line, 0},    /* coff line number that we use anyway */
 
+  {"weak", obj_aout_weak, 0},  /* mark symbol as weak.  */
+
   /* coff debug pseudos (ignored) */
   {"def", s_ignore, 0},
   {"dim", s_ignore, 0},
@@ -273,6 +276,20 @@ obj_emit_symbols (where, symbol_rootP)
       if (!S_IS_DEBUG (symbolP) && !S_IS_DEFINED (symbolP))
        S_SET_EXTERNAL (symbolP);
 
+      /* Adjust the type of a weak symbol.  */
+      if (S_GET_WEAK (symbolP))
+       {
+         switch (S_GET_TYPE (symbolP))
+           {
+           case N_UNDF: S_SET_TYPE (symbolP, N_WEAKU); break;
+           case N_ABS:  S_SET_TYPE (symbolP, N_WEAKA); break;
+           case N_TEXT: S_SET_TYPE (symbolP, N_WEAKT); break;
+           case N_DATA: S_SET_TYPE (symbolP, N_WEAKD); break;
+           case N_BSS:  S_SET_TYPE (symbolP, N_WEAKB); break;
+           default: as_bad ("%s: bad type for weak symbol", temp); break;
+           }
+       }
+
       obj_symbol_to_chars (where, symbolP);
       S_SET_NAME (symbolP, temp);
     }
@@ -291,6 +308,36 @@ obj_aout_line (ignore)
   demand_empty_rest_of_line ();
 }                              /* obj_aout_line() */
 
+/* Handle .weak.  This is a GNU extension.  */
+
+static void
+obj_aout_weak (ignore)
+     int ignore;
+{
+  char *name;
+  int c;
+  symbolS *symbolP;
+
+  do
+    {
+      name = input_line_pointer;
+      c = get_symbol_end ();
+      symbolP = symbol_find_or_make (name);
+      *input_line_pointer = c;
+      SKIP_WHITESPACE ();
+      S_SET_WEAK (symbolP);
+      if (c == ',')
+       {
+         input_line_pointer++;
+         SKIP_WHITESPACE ();
+         if (*input_line_pointer == '\n')
+           c = '\n';
+       }
+    }
+  while (c == ',');
+  demand_empty_rest_of_line ();
+}
+
 void
 obj_read_begin_hook ()
 {