* config/tc-mips.c (md_pseudo_table): Handle .globl and .global.
authorIan Lance Taylor <ian@airs.com>
Mon, 12 Sep 1994 22:11:18 +0000 (22:11 +0000)
committerIan Lance Taylor <ian@airs.com>
Mon, 12 Sep 1994 22:11:18 +0000 (22:11 +0000)
(s_mips_globl): New static function; needed for Irix 5 support.
* ecoff.c (ecoff_build_symbols): If BSF_FUNCTION is set for an
external symbol with no type, set the type to st_Proc rather than
st_Global.  Don't set the index of an external st_Proc or
st_StaticProc symbol unless it is also a local symbol.

gas/ChangeLog
gas/config/tc-mips.c
gas/ecoff.c

index 1638b65..b74339f 100644 (file)
@@ -1,5 +1,12 @@
 Mon Sep 12 17:51:39 1994  Ian Lance Taylor  (ian@sanguine.cygnus.com)
 
+       * config/tc-mips.c (md_pseudo_table): Handle .globl and .global.
+       (s_mips_globl): New static function; needed for Irix 5 support.
+       * ecoff.c (ecoff_build_symbols): If BSF_FUNCTION is set for an
+       external symbol with no type, set the type to st_Proc rather than
+       st_Global.  Don't set the index of an external st_Proc or
+       st_StaticProc symbol unless it is also a local symbol.
+
        * read.c (read_a_source_file): The second argument to as_where is
        unsigned int *, not int *.
 
index e607557..510e114 100644 (file)
@@ -378,6 +378,7 @@ static void s_cons PARAMS ((int));
 static void s_err PARAMS ((int));
 static void s_extern PARAMS ((int));
 static void s_float_cons PARAMS ((int));
+static void s_mips_globl PARAMS ((int));
 static void s_option PARAMS ((int));
 static void s_mipsset PARAMS ((int));
 static void s_mips_space PARAMS ((int));
@@ -450,6 +451,8 @@ const pseudo_typeS md_pseudo_table[] =
   {"double", s_float_cons, 'd'},
   {"extern", s_extern, 0},
   {"float", s_float_cons, 'f'},
+  {"globl", s_mips_globl, 0},
+  {"global", s_mips_globl, 0},
   {"hword", s_cons, 1},
   {"int", s_cons, 2},
   {"long", s_cons, 2},
@@ -5754,6 +5757,45 @@ s_float_cons (type)
   float_cons (type);
 }
 
+/* Handle .globl.  We need to override it because on Irix 5 you are
+   permitted to say
+       .globl foo .text
+   where foo is an undefined symbol, to mean that foo should be
+   considered to be the address of a function.  */
+
+static void
+s_mips_globl (x)
+     int x;
+{
+  char *name;
+  int c;
+  symbolS *symbolP;
+
+  name = input_line_pointer;
+  c = get_symbol_end ();
+  symbolP = symbol_find_or_make (name);
+  *input_line_pointer = c;
+  SKIP_WHITESPACE ();
+  if (! is_end_of_line[(unsigned char) *input_line_pointer])
+    {
+      char *secname;
+      asection *sec;
+
+      secname = input_line_pointer;
+      c = get_symbol_end ();
+      sec = bfd_get_section_by_name (stdoutput, secname);
+      if (sec == NULL)
+       as_bad ("%s: no such section", secname);
+      *input_line_pointer = c;
+
+      if (sec != NULL && (sec->flags & SEC_CODE) != 0)
+       symbolP->bsym->flags |= BSF_FUNCTION;
+    }
+
+  S_SET_EXTERNAL (symbolP);
+  demand_empty_rest_of_line ();
+}
+
 static void
 s_option (x)
      int x;
index 8671b48..a064406 100644 (file)
@@ -3904,7 +3904,12 @@ ecoff_build_symbols (backend, buf, bufend, offset)
                          if (! ECOFF_IS_STAB (&sym_ptr->ecoff_sym.asym)
                              && (S_IS_EXTERNAL (as_sym)
                                  || ! S_IS_DEFINED (as_sym)))
-                           st = st_Global;
+                           {
+                             if ((as_sym->bsym->flags & BSF_FUNCTION) != 0)
+                               st = st_Proc;
+                             else
+                               st = st_Global;
+                           }
                          else if (seg == text_section)
                            st = st_Label;
                          else
@@ -4084,12 +4089,10 @@ ecoff_build_symbols (backend, buf, bufend, offset)
                  if (as_sym != (symbolS *) NULL
                      && as_sym->ecoff_symbol == sym_ptr)
                    {
-                     if (sym_ptr->ecoff_sym.asym.st == st_Proc
-                         || sym_ptr->ecoff_sym.asym.st == st_StaticProc)
-                       {
-                         know (local);
-                         sym_ptr->ecoff_sym.asym.index = isym - ifilesym - 1;
-                       }
+                     if ((sym_ptr->ecoff_sym.asym.st == st_Proc
+                          || sym_ptr->ecoff_sym.asym.st == st_StaticProc)
+                         && local)
+                       sym_ptr->ecoff_sym.asym.index = isym - ifilesym - 1;
                      sym_ptr->ecoff_sym.ifd = fil_ptr->file_index;
                    }
                }