/* a.out object file format
- Copyright (C) 1989, 1990, 1991 Free Software Foundation, Inc.
+ Copyright (C) 1989, 90, 91, 92, 93, 94, 95, 96, 97, 98, 1999
+ Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
the GNU General Public License for more details.
-You should have received a copy of the GNU General Public
-License along with GAS; see the file COPYING. If not, write
-to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+You should have received a copy of the GNU General Public License
+along with GAS; see the file COPYING. If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+02111-1307, USA. */
#include "as.h"
#ifdef BFD_ASSEMBLER
static void obj_aout_line PARAMS ((int));
static void obj_aout_weak PARAMS ((int));
+static void obj_aout_type PARAMS ((int));
const pseudo_typeS obj_pseudo_table[] =
{
{"weak", obj_aout_weak, 0}, /* mark symbol as weak. */
+ {"type", obj_aout_type, 0},
+
/* coff debug pseudos (ignored) */
{"def", s_ignore, 0},
{"dim", s_ignore, 0},
{"scl", s_ignore, 0},
{"size", s_ignore, 0},
{"tag", s_ignore, 0},
- {"type", s_ignore, 0},
{"val", s_ignore, 0},
{"version", s_ignore, 0},
asection *sec;
int desc, type, other;
- flags = sym->bsym->flags;
+ flags = symbol_get_bfdsym (sym)->flags;
desc = S_GET_DESC (sym);
type = S_GET_TYPE (sym);
other = S_GET_OTHER (sym);
- sec = sym->bsym->section;
+ sec = S_GET_SEGMENT (sym);
/* Only frob simple symbols this way right now. */
if (! (type & ~ (N_TYPE | N_EXT)))
{
if (type == (N_UNDF | N_EXT)
&& sec == &bfd_abs_section)
- sym->bsym->section = sec = &bfd_und_section;
+ {
+ sec = bfd_und_section_ptr;
+ S_SET_SEGMENT (sym, sec);
+ }
if ((type & N_TYPE) != N_INDR
&& (type & N_TYPE) != N_SETA
case N_SETB:
/* Set the debugging flag for constructor symbols so that
BFD leaves them alone. */
- sym->bsym->flags |= BSF_DEBUGGING;
+ symbol_get_bfdsym (sym)->flags |= BSF_DEBUGGING;
+
+ /* You can't put a common symbol in a set. The way a set
+ element works is that the symbol has a definition and a
+ name, and the linker adds the definition to the set of
+ that name. That does not work for a common symbol,
+ because the linker can't tell which common symbol the
+ user means. FIXME: Using as_bad here may be
+ inappropriate, since the user may want to force a
+ particular type without regard to the semantics of sets;
+ on the other hand, we certainly don't want anybody to be
+ mislead into thinking that their code will work. */
+ if (S_IS_COMMON (sym))
+ as_bad (_("Attempt to put a common symbol into set %s"),
+ S_GET_NAME (sym));
+ /* Similarly, you can't put an undefined symbol in a set. */
+ else if (! S_IS_DEFINED (sym))
+ as_bad (_("Attempt to put an undefined symbol into set %s"),
+ S_GET_NAME (sym));
+
break;
case N_INDR:
/* Put indirect symbols in the indirect section. */
- sym->bsym->section = &bfd_ind_section;
- sym->bsym->flags |= BSF_INDIRECT;
+ S_SET_SEGMENT (sym, bfd_ind_section_ptr);
+ symbol_get_bfdsym (sym)->flags |= BSF_INDIRECT;
if (type & N_EXT)
{
- sym->bsym->flags |= BSF_EXPORT;
- sym->bsym->flags &=~ BSF_LOCAL;
+ symbol_get_bfdsym (sym)->flags |= BSF_EXPORT;
+ symbol_get_bfdsym (sym)->flags &=~ BSF_LOCAL;
}
break;
case N_WARNING:
/* Mark warning symbols. */
- sym->bsym->flags |= BSF_WARNING;
+ symbol_get_bfdsym (sym)->flags |= BSF_WARNING;
break;
}
}
else
{
- sym->bsym->flags |= BSF_DEBUGGING;
+ symbol_get_bfdsym (sym)->flags |= BSF_DEBUGGING;
}
S_SET_TYPE (sym, type);
+
+ /* Double check weak symbols. */
+ if (S_IS_WEAK (sym))
+ {
+ if (S_IS_COMMON (sym))
+ as_bad (_("Symbol `%s' can not be both weak and common"),
+ S_GET_NAME (sym));
+ }
}
void
assert (x == true);
}
-#else
+#else /* ! BFD_ASSEMBLER */
/* Relocation. */
for (; fixP; fixP = fixP->fx_next)
if (fixP->fx_done == 0)
{
+ symbolS *sym;
+
+ sym = fixP->fx_addsy;
+ while (sym->sy_value.X_op == O_symbol
+ && (! S_IS_DEFINED (sym) || S_IS_COMMON (sym)))
+ sym = sym->sy_value.X_add_symbol;
+ fixP->fx_addsy = sym;
+
+ if (! sym->sy_resolved && ! S_IS_DEFINED (sym))
+ {
+ char *file;
+ unsigned int line;
+
+ if (expr_symbol_where (sym, &file, &line))
+ as_bad_where (file, line, _("unresolved relocation"));
+ else
+ as_bad (_("bad relocation: symbol `%s' not in symbol table"),
+ S_GET_NAME (sym));
+ }
+
tc_aout_fix_to_chars (*where, fixP, segment_address_in_file);
*where += md_reloc_size;
}
#endif /* CROSS_COMPILE */
}
-#endif
+#endif /* ! defined (obj_header_append) */
void
obj_symbol_to_chars (where, symbolP)
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;
+ default: as_bad (_("%s: bad type for weak symbol"), temp); break;
}
}
demand_empty_rest_of_line ();
}
+/* Handle .type. On {Net,Open}BSD, this is used to set the n_other field,
+ which is then apparently used when doing dynamic linking. Older
+ versions ogas ignored the .type pseudo-op, so we also ignore it if
+ we can't parse it. */
+
+static void
+obj_aout_type (ignore)
+ int ignore;
+{
+ char *name;
+ int c;
+ symbolS *sym;
+
+ name = input_line_pointer;
+ c = get_symbol_end ();
+ sym = symbol_find (name);
+ *input_line_pointer = c;
+ if (sym != NULL)
+ {
+ SKIP_WHITESPACE ();
+ if (*input_line_pointer == ',')
+ {
+ ++input_line_pointer;
+ SKIP_WHITESPACE ();
+ if (*input_line_pointer == '@')
+ {
+ ++input_line_pointer;
+ if (strncmp (input_line_pointer, "object", 6) == 0)
+ S_SET_OTHER (sym, 1);
+ else if (strncmp (input_line_pointer, "function", 8) == 0)
+ S_SET_OTHER (sym, 2);
+ }
+ }
+ }
+
+ /* Ignore everything else on the line. */
+ s_ignore (0);
+}
+
void
obj_read_begin_hook ()
{
symbolPP = &symbol_rootP; /*->last symbol chain link. */
while ((symbolP = *symbolPP) != NULL)
{
+ if (symbolP->sy_mri_common)
+ {
+ if (S_IS_EXTERNAL (symbolP))
+ as_bad (_("%s: global symbols not supported in common sections"),
+ S_GET_NAME (symbolP));
+ *symbolPP = symbol_next (symbolP);
+ continue;
+ }
+
if (flag_readonly_data_in_text && (S_GET_SEGMENT (symbolP) == SEG_DATA))
{
S_SET_SEGMENT (symbolP, SEG_TEXT);
} /* if pusing data into text */
- resolve_symbol_value (symbolP);
+ resolve_symbol_value (symbolP, 1);
+
+ /* Skip symbols which were equated to undefined or common
+ symbols. */
+ if (symbolP->sy_value.X_op == O_symbol
+ && (! S_IS_DEFINED (symbolP) || S_IS_COMMON (symbolP)))
+ {
+ *symbolPP = symbol_next (symbolP);
+ continue;
+ }
/* OK, here is how we decide which symbols go out into the brave
new symtab. Symbols that do are:
}
else /* .Stabd case. */
symbolP->sy_name_offset = 0;
- symbolPP = &(symbol_next (symbolP));
+ symbolPP = &symbolP->sy_next;
}
else
{
Well, maybe if you're doing twisted things with
register names... */
{
- as_bad ("Local symbol %s never defined.", decode_local_label_name (S_GET_NAME (symbolP)));
+ as_bad (_("Local symbol %s never defined."), decode_local_label_name (S_GET_NAME (symbolP)));
} /* oops. */
/* Unhook it from the chain */
}
if (exp >= 1000)
{
- as_bad ("subsegment index too high");
+ as_bad (_("subsegment index too high"));
}
if (strcmp (section_name, ".text") == 0)