X-Git-Url: https://oss.titaniummirror.com/gitweb?p=msp430-binutils.git;a=blobdiff_plain;f=gas%2Fsymbols.c;h=4cfa85b103b0302879d5b2a948e1761442c66bee;hp=b631a1d6aa4eea8a0363209e583c51202ac397f0;hb=88750007d7869f178f0ba528f41efd3b74c424cf;hpb=6df9443a374e2b81278c61b8afc0a1eef7db280b diff --git a/gas/symbols.c b/gas/symbols.c index b631a1d..4cfa85b 100644 --- a/gas/symbols.c +++ b/gas/symbols.c @@ -1,6 +1,6 @@ /* symbols.c -symbol table- Copyright 1987, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, - 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 + 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. This file is part of GAS, the GNU Assembler. @@ -59,7 +59,7 @@ symbolS abs_symbol; #define LOCAL_LABEL_CHAR '\002' struct obstack notes; -#ifdef USE_UNIQUE +#ifdef TE_PE /* The name of an external symbol which is used to make weak PE symbol names unique. */ const char * an_external_name; @@ -109,7 +109,7 @@ save_symbol_name (const char *name) name_length = strlen (name) + 1; /* +1 for \0. */ obstack_grow (¬es, name, name_length); - ret = obstack_finish (¬es); + ret = (char *) obstack_finish (¬es); #ifdef tc_canonicalize_symbol_name ret = tc_canonicalize_symbol_name (ret); @@ -204,7 +204,7 @@ local_symbol_make (const char *name, segT section, valueT value, fragS *frag) local_symbol_set_frag (ret, frag); ret->lsy_value = value; - hash_jam (local_hash, name_copy, (PTR) ret); + hash_jam (local_hash, name_copy, (void *) ret); return ret; } @@ -217,7 +217,7 @@ local_symbol_convert (struct local_symbol *locsym) { symbolS *ret; - assert (locsym->lsy_marker == NULL); + gas_assert (locsym->lsy_marker == NULL); if (local_symbol_converted_p (locsym)) return local_symbol_get_real_symbol (locsym); @@ -246,6 +246,17 @@ local_symbol_convert (struct local_symbol *locsym) return ret; } +static void +define_sym_at_dot (symbolS *symbolP) +{ + symbolP->sy_frag = frag_now; +#ifdef OBJ_VMS + S_SET_OTHER (symbolP, const_flag); +#endif + S_SET_VALUE (symbolP, (valueT) frag_now_fix ()); + S_SET_SEGMENT (symbolP, now_seg); +} + /* We have just seen ":". Creates a struct symbol unless it already exists. @@ -343,12 +354,7 @@ colon (/* Just seen "x:" - rattle symbols & frags. */ } if (S_GET_VALUE (symbolP) == 0) { - symbolP->sy_frag = frag_now; -#ifdef OBJ_VMS - S_SET_OTHER (symbolP, const_flag); -#endif - S_SET_VALUE (symbolP, (valueT) frag_now_fix ()); - S_SET_SEGMENT (symbolP, now_seg); + define_sym_at_dot (symbolP); #ifdef N_UNDF know (N_UNDF == 0); #endif /* if we have one, it better be zero. */ @@ -393,12 +399,7 @@ colon (/* Just seen "x:" - rattle symbols & frags. */ { /* It is a .comm/.lcomm being converted to initialized data. */ - symbolP->sy_frag = frag_now; -#ifdef OBJ_VMS - S_SET_OTHER (symbolP, const_flag); -#endif - S_SET_VALUE (symbolP, (valueT) frag_now_fix ()); - S_SET_SEGMENT (symbolP, now_seg); /* Keep N_EXT bit. */ + define_sym_at_dot (symbolP); } } else @@ -431,6 +432,7 @@ colon (/* Just seen "x:" - rattle symbols & frags. */ { as_bad (_("symbol `%s' is already defined"), sym_name); symbolP = symbol_clone (symbolP, 0); + define_sym_at_dot (symbolP); } } @@ -489,14 +491,14 @@ symbol_table_insert (symbolS *symbolP) if (LOCAL_SYMBOL_CHECK (symbolP)) { error_string = hash_jam (local_hash, S_GET_NAME (symbolP), - (PTR) symbolP); + (void *) symbolP); if (error_string != NULL) as_fatal (_("inserting \"%s\" into symbol table failed: %s"), S_GET_NAME (symbolP), error_string); return; } - if ((error_string = hash_jam (sy_hash, S_GET_NAME (symbolP), (PTR) symbolP))) + if ((error_string = hash_jam (sy_hash, S_GET_NAME (symbolP), (void *) symbolP))) { as_fatal (_("inserting \"%s\" into symbol table failed: %s"), S_GET_NAME (symbolP), error_string); @@ -563,7 +565,7 @@ symbol_clone (symbolS *orgsymP, int replace) orgsymP = local_symbol_convert ((struct local_symbol *) orgsymP); bsymorg = orgsymP->bsym; - newsymP = obstack_alloc (¬es, sizeof (*newsymP)); + newsymP = (symbolS *) obstack_alloc (¬es, sizeof (*newsymP)); *newsymP = *orgsymP; bsymnew = bfd_make_empty_symbol (bfd_asymbol_bfd (bsymorg)); if (bsymnew == NULL) @@ -596,13 +598,20 @@ symbol_clone (symbolS *orgsymP, int replace) symbol_lastP = newsymP; else if (orgsymP->sy_next) orgsymP->sy_next->sy_previous = newsymP; + + /* Symbols that won't be output can't be external. */ + S_CLEAR_EXTERNAL (orgsymP); orgsymP->sy_previous = orgsymP->sy_next = orgsymP; debug_verify_symchain (symbol_rootP, symbol_lastP); symbol_table_insert (newsymP); } else - newsymP->sy_previous = newsymP->sy_next = newsymP; + { + /* Symbols that won't be output can't be external. */ + S_CLEAR_EXTERNAL (newsymP); + newsymP->sy_previous = newsymP->sy_next = newsymP; + } return newsymP; } @@ -872,11 +881,11 @@ verify_symbol_chain (symbolS *rootP, symbolS *lastP) for (; symbol_next (symbolP) != NULL; symbolP = symbol_next (symbolP)) { - assert (symbolP->bsym != NULL); - assert (symbolP->sy_next->sy_previous == symbolP); + gas_assert (symbolP->bsym != NULL); + gas_assert (symbolP->sy_next->sy_previous == symbolP); } - assert (lastP == symbolP); + gas_assert (lastP == symbolP); } #ifdef OBJ_COMPLEX_RELC @@ -1137,13 +1146,13 @@ resolve_symbol_value (symbolS *symp) do_symbol: if (S_IS_WEAKREFR (symp)) { - assert (final_val == 0); + gas_assert (final_val == 0); if (S_IS_WEAKREFR (add_symbol)) { - assert (add_symbol->sy_value.X_op == O_symbol + gas_assert (add_symbol->sy_value.X_op == O_symbol && add_symbol->sy_value.X_add_number == 0); add_symbol = add_symbol->sy_value.X_add_symbol; - assert (! S_IS_WEAKREFR (add_symbol)); + gas_assert (! S_IS_WEAKREFR (add_symbol)); symp->sy_value.X_add_symbol = add_symbol; } } @@ -1438,15 +1447,15 @@ exit_dont_set_value: return final_val; } -static void resolve_local_symbol (const char *, PTR); +static void resolve_local_symbol (const char *, void *); /* A static function passed to hash_traverse. */ static void -resolve_local_symbol (const char *key ATTRIBUTE_UNUSED, PTR value) +resolve_local_symbol (const char *key ATTRIBUTE_UNUSED, void *value) { if (value != NULL) - resolve_symbol_value (value); + resolve_symbol_value ((symbolS *) value); } /* Resolve all local symbols. */ @@ -1505,10 +1514,7 @@ snapshot_symbol (symbolS **symbolPP, valueT *valueP, segT *segP, fragS **fragPP) } } - /* Never change a defined symbol. */ - if (symbolP->bsym->section == undefined_section - || symbolP->bsym->section == expr_section) - *symbolPP = symbolP; + *symbolPP = symbolP; *valueP = expr.X_add_number; *segP = symbolP->bsym->section; *fragPP = symbolP->sy_frag; @@ -1596,7 +1602,7 @@ define_dollar_label (long label) { dollar_labels = (long *) xmalloc (DOLLAR_LABEL_BUMP_BY * sizeof (long)); dollar_label_instances = (long *) xmalloc (DOLLAR_LABEL_BUMP_BY * sizeof (long)); - dollar_label_defines = xmalloc (DOLLAR_LABEL_BUMP_BY); + dollar_label_defines = (char *) xmalloc (DOLLAR_LABEL_BUMP_BY); dollar_label_max = DOLLAR_LABEL_BUMP_BY; dollar_label_count = 0; } @@ -1607,7 +1613,7 @@ define_dollar_label (long label) dollar_label_max * sizeof (long)); dollar_label_instances = (long *) xrealloc ((char *) dollar_label_instances, dollar_label_max * sizeof (long)); - dollar_label_defines = xrealloc (dollar_label_defines, dollar_label_max); + dollar_label_defines = (char *) xrealloc (dollar_label_defines, dollar_label_max); } /* if we needed to grow */ dollar_labels[dollar_label_count] = label; @@ -1880,7 +1886,7 @@ decode_local_label_name (char *s) instance_number = (10 * instance_number) + *p - '0'; message_format = _("\"%d\" (instance number %d of a %s label)"); - symbol_decode = obstack_alloc (¬es, strlen (message_format) + 30); + symbol_decode = (char *) obstack_alloc (¬es, strlen (message_format) + 30); sprintf (symbol_decode, message_format, label_number, instance_number, type); return symbol_decode; @@ -1941,7 +1947,8 @@ copy_symbol_attributes (symbolS *dest, symbolS *src) /* In an expression, transfer the settings of these flags. The user can override later, of course. */ -#define COPIED_SYMFLAGS (BSF_FUNCTION | BSF_OBJECT) +#define COPIED_SYMFLAGS (BSF_FUNCTION | BSF_OBJECT \ + | BSF_GNU_INDIRECT_FUNCTION) dest->bsym->flags |= src->bsym->flags & COPIED_SYMFLAGS; #ifdef OBJ_COPY_SYMBOL_ATTRIBUTES @@ -2045,6 +2052,7 @@ S_FORCE_RELOC (symbolS *s, int strict) return ((strict && ((s->bsym->flags & BSF_WEAK) != 0 + || (s->bsym->flags & BSF_GNU_INDIRECT_FUNCTION) != 0 || (EXTERN_FORCE_RELOC && (s->bsym->flags & BSF_GLOBAL) != 0))) || s->bsym->section == undefined_section @@ -2184,10 +2192,18 @@ S_SET_EXTERNAL (symbolS *s) _("section symbols are already global")); return; } +#ifndef TC_GLOBAL_REGISTER_SYMBOL_OK + if (S_GET_SEGMENT (s) == reg_section) + { + as_bad ("can't make register symbol `%s' global", + S_GET_NAME (s)); + return; + } +#endif s->bsym->flags |= BSF_GLOBAL; s->bsym->flags &= ~(BSF_LOCAL | BSF_WEAK); -#ifdef USE_UNIQUE +#ifdef TE_PE if (! an_external_name && S_GET_NAME(s)[0] != '.') an_external_name = S_GET_NAME (s); #endif @@ -2785,7 +2801,7 @@ print_symbol_value_1 (FILE *file, symbolS *sym) if (s != undefined_section && s != expr_section) - fprintf (file, " %lx", (long) S_GET_VALUE (sym)); + fprintf (file, " %lx", (unsigned long) S_GET_VALUE (sym)); } else if (indent_level < max_indent_level && S_GET_SEGMENT (sym) != undefined_section) @@ -2794,7 +2810,7 @@ print_symbol_value_1 (FILE *file, symbolS *sym) fprintf (file, "\n%*s<", indent_level * 4, ""); if (LOCAL_SYMBOL_CHECK (sym)) fprintf (file, "constant %lx", - (long) ((struct local_symbol *) sym)->lsy_value); + (unsigned long) ((struct local_symbol *) sym)->lsy_value); else print_expr_1 (file, &sym->sy_value); fprintf (file, ">"); @@ -2838,7 +2854,7 @@ print_expr_1 (FILE *file, expressionS *exp) fprintf (file, "absent"); break; case O_constant: - fprintf (file, "constant %lx", (long) exp->X_add_number); + fprintf (file, "constant %lx", (unsigned long) exp->X_add_number); break; case O_symbol: indent_level++; @@ -2848,7 +2864,7 @@ print_expr_1 (FILE *file, expressionS *exp) maybe_print_addnum: if (exp->X_add_number) fprintf (file, "\n%*s%lx", indent_level * 4, "", - (long) exp->X_add_number); + (unsigned long) exp->X_add_number); indent_level--; break; case O_register: @@ -2970,7 +2986,7 @@ symbol_relc_make_sym (symbolS * sym) char typetag; int sname_len; - assert (sym != NULL); + gas_assert (sym != NULL); /* Recurse to symbol_relc_make_expr if this symbol is defined as an expression or a plain value. */ @@ -3035,7 +3051,7 @@ symbol_relc_make_expr (expressionS * exp) operands[0] = operands[1] = operands[2] = NULL; - assert (exp != NULL); + gas_assert (exp != NULL); /* Match known operators -> fill in opstr, arity, operands[] and fall through to construct subexpression fragments; may instead return @@ -3148,7 +3164,7 @@ symbol_relc_make_expr (expressionS * exp) + (arity >= 2 ? (strlen (operands[1]) + 1 ) : 0) + (arity >= 3 ? (strlen (operands[2]) + 0 ) : 0) + 1); - assert (concat_string != NULL); + gas_assert (concat_string != NULL); /* Format the thing. */ sprintf (concat_string,