From: Ian Lance Taylor Date: Wed, 5 Jul 1995 19:59:07 +0000 (+0000) Subject: * symbols.c (S_SET_EXTERNAL): Warn if symbol is weak. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=56dc989a91a6bb112bb6bd112906b55229e127f0;p=binutils-gdb.git * symbols.c (S_SET_EXTERNAL): Warn if symbol is weak. (S_CLEAR_EXTERNAL): Likewise. (S_SET_WEAK): Warn if symbol is global. PR 6750. --- diff --git a/gas/ChangeLog b/gas/ChangeLog index 749365fad10..5313453f6f6 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,5 +1,9 @@ Wed Jul 5 12:01:49 1995 Ian Lance Taylor + * symbols.c (S_SET_EXTERNAL): Warn if symbol is weak. + (S_CLEAR_EXTERNAL): Likewise. + (S_SET_WEAK): Warn if symbol is global. + * config/obj-aout.c (obj_aout_frob_symbol): Warn about an attempt to put an undefined symbol into a set. diff --git a/gas/symbols.c b/gas/symbols.c index c46876f6647..8fd395fa415 100644 --- a/gas/symbols.c +++ b/gas/symbols.c @@ -157,13 +157,10 @@ colon (sym_name) /* just seen "x:" - rattle symbols & frags */ { register symbolS *symbolP; /* symbol we are working with */ -#ifdef LOCAL_LABELS_DOLLAR /* Sun local labels go out of scope whenever a non-local symbol is defined. */ - - if (*sym_name != 'L') + if (LOCAL_LABELS_DOLLAR && *sym_name != 'L') dollar_label_clear (); -#endif /* LOCAL_LABELS_DOLLAR */ #ifndef WORKING_DOT_WORD if (new_broken_words) @@ -765,8 +762,6 @@ resolve_symbol_value (symp) } } -#ifdef LOCAL_LABELS_DOLLAR - /* Dollar labels look like a number followed by a dollar sign. Eg, "42$". They are *really* local. That is, they go out of scope whenever we see a label that isn't local. Also, like fb labels, there can be multiple @@ -918,10 +913,6 @@ dollar_label_name (n, augend) return symbol_name_build; } -#endif /* LOCAL_LABELS_DOLLAR */ - -#ifdef LOCAL_LABELS_FB - /* * Sombody else's idea of local labels. They are made by "n:" where n * is any decimal digit. Refer to them with @@ -1091,9 +1082,6 @@ fb_label_name (n, augend) return (symbol_name_build); } /* fb_label_name() */ -#endif /* LOCAL_LABELS_FB */ - - /* * decode name that may have been generated by foo_label_name() above. If * the name wasn't generated by foo_label_name(), then return it unaltered. @@ -1112,37 +1100,26 @@ decode_local_label_name (s) const char *message_format = "\"%d\" (instance number %d of a %s label)"; if (s[0] != 'L') - return (s); + return s; for (label_number = 0, p = s + 1; isdigit (*p); ++p) - { - label_number = (10 * label_number) + *p - '0'; - } + label_number = (10 * label_number) + *p - '0'; if (*p == 1) - { - type = "dollar"; - } + type = "dollar"; else if (*p == 2) - { - type = "fb"; - } + type = "fb"; else - { - return (s); - } + return s; - for (instance_number = 0, p = s + 1; isdigit (*p); ++p) - { - instance_number = (10 * instance_number) + *p - '0'; - } + for (instance_number = 0, p++; isdigit (*p); ++p) + instance_number = (10 * instance_number) + *p - '0'; symbol_decode = obstack_alloc (¬es, strlen (message_format) + 30); - (void) sprintf (symbol_decode, message_format, label_number, - instance_number, type); + sprintf (symbol_decode, message_format, label_number, instance_number, type); - return (symbol_decode); -} /* decode_local_label_name() */ + return symbol_decode; +} /* Get the value of a symbol. */ @@ -1281,6 +1258,8 @@ void S_SET_EXTERNAL (s) symbolS *s; { + if ((s->bsym->flags & BSF_WEAK) != 0) + as_warn ("%s already declared as weak", S_GET_NAME (s)); s->bsym->flags |= BSF_GLOBAL; s->bsym->flags &= ~(BSF_LOCAL|BSF_WEAK); } @@ -1289,6 +1268,8 @@ void S_CLEAR_EXTERNAL (s) symbolS *s; { + if ((s->bsym->flags & BSF_WEAK) != 0) + as_warn ("%s already declared as weak", S_GET_NAME (s)); s->bsym->flags |= BSF_LOCAL; s->bsym->flags &= ~(BSF_GLOBAL|BSF_WEAK); } @@ -1297,6 +1278,8 @@ void S_SET_WEAK (s) symbolS *s; { + if ((s->bsym->flags & BSF_GLOBAL) != 0) + as_warn ("%s already declared as global", S_GET_NAME (s)); s->bsym->flags |= BSF_WEAK; s->bsym->flags &= ~(BSF_GLOBAL|BSF_LOCAL); } @@ -1328,20 +1311,23 @@ symbol_begin () #endif abs_symbol.sy_value.X_op = O_constant; -#ifdef LOCAL_LABELS_FB - fb_label_init (); -#endif /* LOCAL_LABELS_FB */ + if (LOCAL_LABELS_FB) + fb_label_init (); } int indent_level; +#if 0 + static void indent () { printf ("%*s", indent_level * 4, ""); } +#endif + void print_expr_1 PARAMS ((FILE *, expressionS *)); void print_symbol_value_1 PARAMS ((FILE *, symbolS *)); @@ -1353,7 +1339,7 @@ print_symbol_value_1 (file, sym) const char *name = S_GET_NAME (sym); if (!name || !name[0]) name = "(unnamed)"; - fprintf (file, "sym %lx %s", sym, name); + fprintf (file, "sym %lx %s", (unsigned long) sym, name); if (sym->sy_frag != &zero_address_frag) fprintf (file, " frag %lx", (long) sym->sy_frag); if (sym->written)