From c1444ec48f5d93e491a8f5e13c11531fb4d2cbf8 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Mon, 12 Sep 1994 22:11:18 +0000 Subject: [PATCH] * 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. --- gas/ChangeLog | 7 +++++++ gas/config/tc-mips.c | 42 ++++++++++++++++++++++++++++++++++++++++++ gas/ecoff.c | 17 ++++++++++------- 3 files changed, 59 insertions(+), 7 deletions(-) diff --git a/gas/ChangeLog b/gas/ChangeLog index 1638b6548d4..b74339f7583 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -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 *. diff --git a/gas/config/tc-mips.c b/gas/config/tc-mips.c index e60755723bb..510e1149e34 100644 --- a/gas/config/tc-mips.c +++ b/gas/config/tc-mips.c @@ -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; diff --git a/gas/ecoff.c b/gas/ecoff.c index 8671b48cb77..a0644066c80 100644 --- a/gas/ecoff.c +++ b/gas/ecoff.c @@ -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; } } -- 2.30.2