Fri Jun 3 12:50:13 1994 David J. MacKenzie (djm@rtl.cygnus.com)
+ * as.h: Replace flagseen with separate variables.
+ * as.c (parse_args): Set them. Don't accept -1 option, or -v
+ explicitly (it's a synonym for --version).
+ * as.c, input-scrub.c, messages.c, read.c, symbols.c, write.c,
+ config/obj-aout.c, config/obj-aout.h, config/obj-bout.c,
+ config/obj-bout.h, config/obj-coff.c, config/obj-coff.h,
+ config/obj-vms.c, config/tc-hppa.c, config/tc-i386.c,
+ config/tc-i960.c, config/tc-m68k.c, config/tc-mips.c,
+ config/tc-vax.c: Use the new flag variables instead of flagseen.
+ * config/tc-vax.c [OBJ_VMS]: Recognize -+, -1, -v, and document in
+ usage.
+
* as.c (show_usage): Remove target specific messages;
instead, call md_show_usage.
(parse_args): Use getopt_long_only. Take pointers to argc and
-o OBJFILE name the object-file output OBJFILE (default a.out)\n\
-R fold data section into text section\n\
--statistics print maximum bytes and total seconds used\n\
--v print assembler version number\n\
--version print assembler version number and exit\n\
-W suppress warnings\n\
-w ignored\n\
}
/*
- * Parse arguments, but we are only interested in flags.
- * When we find a flag, we process it then make it's argv[] NULL.
- * This helps any future argv[] scanners avoid what we processed.
* Since it is easy to do here we interpret the special arg "-"
* to mean "use stdin" and we set that argv[] pointing to "".
* After we have munged argv[], the only things left are source file
char *shortopts;
extern CONST char *md_shortopts;
- CONST char *std_shortopts = "-1JKLRWZfa::DI:o:vwX";
+ /* -v takes an argument on VMS, so we don't make it a generic option.
+ It gets recognized as an abbreviation of -version, anyway. */
+ CONST char *std_shortopts = "-JKLRWZfa::DI:o:wX";
struct option *longopts;
extern struct option md_longopts[];
print_version_id ();
exit (0);
- case '1':
case 'J':
+ flag_signed_overflow_ok = 1;
+ break;
+
case 'K':
+ flag_warn_displacement = 1;
+ break;
+
case 'L':
+ flag_keep_locals = 1;
+ break;
+
case 'R':
+ flag_readonly_data_in_text = 1;
+ break;
+
case 'W':
+ flag_no_warnings = 1;
+ break;
+
case 'Z':
- case 'f':
- flagseen[(unsigned char) optc] = 1;
+ flag_always_generate_output = 1;
break;
case 'a':
case 'D':
/* DEBUG is implemented: it debugs different */
/* things to other people's assemblers. */
+ flag_debug = 1;
+ break;
+
+ case 'f':
+ flag_no_comments = 1;
break;
case 'I':
as_fatal ("virtual memory exhausted");
break;
- case 'v':
- print_version_id ();
- break;
-
case 'w':
break;
#endif
myname = argv[0];
- memset (flagseen, '\0', sizeof (flagseen)); /* aint seen nothing yet */
#ifndef OBJ_DEFAULT_OUTPUT_FILE_NAME
#define OBJ_DEFAULT_OUTPUT_FILE_NAME "a.out"
#endif
tc_init_after_args ();
#endif
- /* Here with flags set up in flagseen[]. */
perform_an_assembly_pass (argc, argv); /* Assemble it. */
#ifdef TC_I960
brtab_emit ();
#endif
if (seen_at_least_1_file ()
- && !((had_warnings () && flagseen['Z'])
+ && !((had_warnings () && flag_always_generate_output)
|| had_errors () > 0))
keep_it = 1;
else
myname, (long) (lim - (char *) &environ));
}
- if ((had_warnings () && flagseen['Z'])
+ if ((had_warnings () && flag_always_generate_output)
|| had_errors () > 0)
return EXIT_FAILURE;
return EXIT_SUCCESS;
/* main program "as.c" (command arguments etc) */
-/* ['x'] TRUE if "-x" seen. */
-COMMON char flagseen[128];
+COMMON unsigned char flag_no_comments; /* -f */
+COMMON unsigned char flag_debug; /* -D */
+COMMON unsigned char flag_signed_overflow_ok; /* -J */
+COMMON unsigned char flag_warn_displacement; /* -K */
+COMMON unsigned char flag_keep_locals; /* -L */
+COMMON unsigned char flag_readonly_data_in_text; /* -R */
+COMMON unsigned char flag_no_warnings; /* -W */
+COMMON unsigned char flag_always_generate_output; /* -Z */
/* name of emitted object file */
COMMON char *out_file_name;
sym->bsym->section = sec = &bfd_und_section;
if ((type & N_TYPE) != N_INDR
+ && (type & N_TYPE) != N_SETA
+ && (type & N_TYPE) != N_SETT
+ && (type & N_TYPE) != N_SETD
+ && (type & N_TYPE) != N_SETB
&& type != N_WARNING
&& (sec == &bfd_abs_section
|| sec == &bfd_und_section))
symbolPP = &symbol_rootP; /*->last symbol chain link. */
while ((symbolP = *symbolPP) != NULL)
{
- if (flagseen['R'] && (S_GET_SEGMENT (symbolP) == SEG_DATA))
+ if (flag_readonly_data_in_text && (S_GET_SEGMENT (symbolP) == SEG_DATA))
{
S_SET_SEGMENT (symbolP, SEG_TEXT);
} /* if pusing data into text */
|| !S_IS_DEFINED (symbolP)
|| S_IS_EXTERNAL (symbolP)
|| (S_GET_NAME (symbolP)[0] != '\001'
- && (flagseen['L'] || !S_LOCAL_NAME (symbolP)))))
+ && (flag_keep_locals || !S_LOCAL_NAME (symbolP)))))
{
symbolP->sy_number = symbol_number++;
if (strcmp (section_name, ".data") == 0)
{
- if (flagseen['R'])
+ if (flag_readonly_data_in_text)
subseg_set (SEG_TEXT, (subsegT) exp + 1000);
else
subseg_set (SEG_DATA, (subsegT) exp);
-/* a.out object file format
- Copyright (C) 1989, 1990, 1991 Free Software Foundation, Inc.
-
+/* obj-aout.h, a.out object file format for gas, the assembler.
+ Copyright (C) 1989, 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
+
This file is part of GAS, the GNU Assembler.
-
+
GAS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2,
or (at your option) any later version.
-
+
GAS is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
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. */
#include "targ-cpu.h"
-#ifndef VMS
-#include "a.out.gnu.h" /* Needed to define struct nlist. Sigh. */
+#ifdef BFD_ASSEMBLER
+
+#include "../bfd/libaout.h"
+
+#ifndef TARGET_FORMAT
+/* #define TARGET_FORMAT "a.out" / * There is no "a.out" target. */
+#endif
+
+#else /* ! BFD_ASSEMBLER */
+
+#ifndef VMS
+#include "aout_gnu.h" /* Needed to define struct nlist. Sigh. */
#else
#include "a_out.h"
#endif
#endif /* AOUT_MACHTYPE */
extern const short seg_N_TYPE[];
-extern const segT N_TYPE_seg[];
+extern const segT N_TYPE_seg[];
#ifndef DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE
#define DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE (OMAGIC)
#endif /* DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE */
+#endif /* ! BFD_ASSEMBLER */
+
/* SYMBOL TABLE */
/* Symbol table entry data type */
-typedef struct nlist obj_symbol_type; /* Symbol table entry */
+typedef struct nlist obj_symbol_type; /* Symbol table entry */
/* Symbol table macros and constants */
+#ifdef BFD_ASSEMBLER
+
+#define S_SET_OTHER(S,V) (aout_symbol((S)->bsym)->other = (V))
+#define S_SET_TYPE(S,T) (aout_symbol((S)->bsym)->type = (T))
+#define S_SET_DESC(S,D) (aout_symbol((S)->bsym)->desc = (D))
+#define S_GET_OTHER(S) (aout_symbol((S)->bsym)->other)
+#define S_GET_TYPE(S) (aout_symbol((S)->bsym)->type)
+#define S_GET_DESC(S) (aout_symbol((S)->bsym)->desc)
+
+asection *text_section, *data_section, *bss_section;
+
+#define obj_frob_symbol(S,PUNT) obj_aout_frob_symbol (S, &PUNT)
+#define obj_frob_file() obj_aout_frob_file ()
+extern void obj_aout_frob_symbol PARAMS ((struct symbol *, int *));
+extern void obj_aout_frob_file PARAMS ((void));
+
+#define obj_sec_sym_ok_for_reloc(SEC) (1)
+
+#else
+
/*
* Macros to extract information from a symbol table entry.
* This syntaxic indirection allows independence regarding a.out or coff.
#define S_IS_LOCAL(s) (S_GET_NAME(s) && \
!S_IS_DEBUG(s) && \
(S_GET_NAME(s)[0] == '\001' || \
- (S_LOCAL_NAME(s) && !flagseen['L'])))
+ (S_LOCAL_NAME(s) && !flag_keep_locals)))
/* True if a symbol is not defined in this file */
#define S_IS_EXTERN(s) ((s)->sy_symbol.n_type & N_EXT)
/* True if the symbol has been generated because of a .stabd directive */
#define S_IS_STABD(s) (S_GET_NAME(s) == (char *)0)
/* Accessors */
-/* The value of the symbol */
-#define S_GET_VALUE(s) (((s)->sy_symbol.n_value))
/* The name of the symbol */
#define S_GET_NAME(s) ((s)->sy_symbol.n_un.n_name)
/* The pointer to the string table */
#define S_GET_DESC(s) ((s)->sy_symbol.n_desc)
/* Modifiers */
-/* Set the value of the symbol */
-#define S_SET_VALUE(s,v) ((s)->sy_symbol.n_value = (unsigned long) (v))
/* Assume that a symbol cannot be simultaneously in more than on segment */
/* set segment */
#define S_SET_SEGMENT(s,seg) ((s)->sy_symbol.n_type &= ~N_TYPE,(s)->sy_symbol.n_type|=SEGMENT_TO_SYMBOL_TYPE(seg))
#define S_SET_NAME(s,v) ((s)->sy_symbol.n_un.n_name = (v))
/* Set the offset in the string table */
#define S_SET_OFFSET(s,v) ((s)->sy_symbol.n_un.n_strx = (v))
+/* Set the n_type field */
+#define S_SET_TYPE(s,t) ((s)->sy_symbol.n_type = (t))
/* Set the n_other expression value */
#define S_SET_OTHER(s,v) ((s)->sy_symbol.n_other = (v))
/* Set the n_desc expression value */
+ H_GET_DATA_RELOCATION_SIZE(h) \
+ H_GET_STRING_SIZE(h))
-#define H_GET_HEADER_SIZE(h) (sizeof(struct exec))
+#define H_GET_HEADER_SIZE(h) (EXEC_BYTES_SIZE)
#define H_GET_TEXT_SIZE(h) ((h)->header.a_text)
#define H_GET_DATA_SIZE(h) ((h)->header.a_data)
#define H_GET_BSS_SIZE(h) ((h)->header.a_bss)
#define H_SET_TEXT_RELOCATION_SIZE(h,v) ((h)->header.a_trsize = (v))
#define H_SET_DATA_RELOCATION_SIZE(h,v) ((h)->header.a_drsize = (v))
-#define H_SET_SYMBOL_TABLE_SIZE(h,v) ((h)->header.a_syms = (v) * \
- sizeof(struct nlist))
+#define H_SET_SYMBOL_TABLE_SIZE(h,v) ((h)->header.a_syms = (v) * 12)
#define H_SET_ENTRY_POINT(h,v) ((h)->header.a_entry = (v))
#define H_SET_STRING_SIZE(h,v) ((h)->string_table_size = (v))
-/*
- * Current means for getting the name of a segment.
- * This will change for infinite-segments support (e.g. COFF).
- */
-#define segment_name(seg) ( seg_name[(int)(seg)] )
-extern char *const seg_name[];
+typedef struct
+ {
+ struct exec header; /* a.out header */
+ long string_table_size; /* names + '\0' + sizeof(int) */
+ }
-typedef struct {
- struct exec header; /* a.out header */
- long string_table_size; /* names + '\0' + sizeof(int) */
-} object_headers;
+object_headers;
/* line numbering stuff. */
#define OBJ_EMIT_LINENO(a, b, c) {;}
-#define obj_symbol_new_hook(s) {;}
-
-#ifdef __STDC__
struct fix;
-void tc_aout_fix_to_chars(char *where, struct fix *fixP, relax_addressT segment_address);
-#else
-void tc_aout_fix_to_chars();
-#endif /* __STDC__ */
+void tc_aout_fix_to_chars PARAMS ((char *where, struct fix *fixP, relax_addressT segment_address));
-/*
- * Local Variables:
- * comment-column: 0
- * fill-column: 131
- * End:
- */
+#endif
+
+#define obj_symbol_new_hook(s) {;}
+
+#define EMIT_SECTION_SYMBOLS 0
/* end of obj-aout.h */
symbolPP = &symbol_rootP; /*->last symbol chain link. */
while ((symbolP = *symbolPP) != NULL)
{
- if (flagseen['R'] && (S_GET_SEGMENT (symbolP) == SEG_DATA))
+ if (flag_readonly_data_in_text && (S_GET_SEGMENT (symbolP) == SEG_DATA))
{
S_SET_SEGMENT (symbolP, SEG_TEXT);
} /* if pusing data into text */
|| !S_IS_DEFINED (symbolP)
|| S_IS_EXTERNAL (symbolP)
#endif /* TC_I960 */
- || (S_GET_NAME (symbolP)[0] != '\001' && (flagseen['L'] || !S_LOCAL_NAME (symbolP)))))
+ || (S_GET_NAME (symbolP)[0] != '\001' && (flag_keep_locals || !S_LOCAL_NAME (symbolP)))))
{
symbolP->sy_number = symbol_number++;
#define S_IS_LOCAL(s) (S_GET_NAME(s) && \
!S_IS_DEBUG(s) && \
(S_GET_NAME(s)[0] == '\001' || \
- (S_LOCAL_NAME(s) && !flagseen['L'])))
+ (S_LOCAL_NAME(s) && !flag_keep_locals)))
/* True if a symbol is not defined in this file */
#define S_IS_EXTERN(s) ((s)->sy_symbol.n_type & N_EXT)
/* True if the symbol has been generated because of a .stabd directive */
symbolP = real_symbolP;
} /* if not local but dup'd */
- if (flagseen['R'] && (S_GET_SEGMENT (symbolP) == SEG_E1))
+ if (flag_readonly_data_in_text && (S_GET_SEGMENT (symbolP) == SEG_E1))
{
S_SET_SEGMENT (symbolP, SEG_E0);
} /* push data into text */
obj_coff_data (ignore)
int ignore;
{
- if (flagseen['R'])
+ if (flag_readonly_data_in_text)
subseg_new (".text", get_absolute_expression () + 1000);
else
subseg_new (".data", get_absolute_expression ());
a signed number. We already know it is not too
negative. This is to catch over-large switches
generated by gcc on the 68k. */
- if (!flagseen['J']
+ if (!flag_signed_overflow_ok
&& size == 2
&& add_number > 0x7fff)
as_bad ("Signed .word overflow; switch may be too large; %ld at 0x%lx",
*/
char *compiler_version_string;
+extern int flag_hash_long_names; /* -+ */
+extern int flag_one; /* -1 */
+extern int flag_show_after_trunc; /* -H */
+extern int flag_no_hash_mixed_case; /* -h NUM */
+
/* Flag that determines how we map names. This takes several values, and
* is set with the -h switch. A value of zero implies names should be
* upper case, and the presence of the -h switch inhibits the case hack.
*cp1 = 0;
if (strlen (Module_Name) > 31)
{
- if (flagseen['+'])
+ if (flag_hash_long_names)
printf ("%s: Module name truncated: %s\n", myname, Module_Name);
Module_Name[31] = 0;
}
*cp1 = 0;
if (strlen (Module_Name) > 31)
{
- if (flagseen['+'])
+ if (flag_hash_long_names)
printf ("%s: Module name truncated: %s\n", myname, Module_Name);
Module_Name[31] = 0;
}
}
old_name = In;
-/* if (strlen(In) > 31 && flagseen['+'])
+/* if (strlen(In) > 31 && flag_hash_long_names)
printf("%s: Symbol name truncated: %s\n",myname,In);*/
/*
* Do the case conversion
/*
* If we saw a dollar sign, we don't do case hacking
*/
- if (flagseen['h'] || Saw_Dollar)
+ if (flag_no_hash_mixed_case || Saw_Dollar)
Case_Hack_Bits = 0;
/*
* and ensure that they are lowercase
*/
for (i = 0; (In[i] != 0) && (i < 8); i++)
- if (isupper(In[i]) && !Saw_Dollar && !flagseen['h'])
+ if (isupper(In[i]) && !Saw_Dollar && !flag_no_hash_mixed_case)
break;
if (In[i] == 0)
*/
/* Old behavior for regular GNU-C compiler */
- if (!flagseen['+'])
+ if (!flag_hash_long_names)
truncate = 0;
if ((Case_Hack_Bits != 0) || (truncate == 1))
{
* Done
*/
*Out = 0;
- if (truncate == 1 && flagseen['+'] && flagseen['H'])
+ if (truncate == 1 && flag_hash_long_names && flag_show_after_trunc)
printf ("%s: Symbol %s replaced by %s\n", myname, old_name, new_name);
}
\f
S_IS_EXTERNAL (symbolP) && (S_GET_TYPE (symbolP) == N_TEXT))
{
#ifdef HACK_DEC_C_STARTUP
- if (!flagseen['+'])
+ if (!flag_hash_long_names)
{
#endif
/*
if (Current_File->max_line == 0)
continue;
if ((strncmp (Current_File->name, "GNU_GXX_INCLUDE:", 16) == 0) &&
- !flagseen['D'])
+ !flag_debug)
continue;
if ((strncmp (Current_File->name, "GNU_CC_INCLUDE:", 15) == 0) &&
- !flagseen['D'])
+ !flag_debug)
continue;
/* show a few extra lines at the start of the region selected */
if (Current_File->min_line > 2)
/* Folding of text and data segments fails miserably on the PA.
Warn user and disable "-R" option. */
- if (flagseen['R'])
+ if (flag_readonly_data_in_text)
{
as_warn ("-R option not supported on this target.");
- flagseen['R'] = 0;
+ flag_readonly_data_in_text = 0;
}
pa_spaces_begin ();
#endif
/* FIXME: This breaks -L -EL. */
- flagseen['L'] = 0;
+ flag_keep_locals = 0;
break;
case 'O':
LITTLENUM_TYPE big_operand_bits[VIT_MAX_OPERANDS][SIZE_OF_LARGE_NUMBER];
FLONUM_TYPE float_operand[VIT_MAX_OPERANDS];
/* Above is made to point into big_operand_bits by md_begin(). */
+
+int flag_hash_long_names; /* -+ */
+int flag_one; /* -1 */
+int flag_show_after_trunc; /* -H */
+int flag_no_hash_mixed_case; /* -h NUM */
\f
/*
* For VAX, relative addresses of "just the right length" are easy.
}
\f
#ifdef OBJ_VMS
-CONST char *md_shortopts = "d:STt:V+h:H";
+CONST char *md_shortopts = "d:STt:V+1h:Hv:";
#else
CONST char *md_shortopts = "d:STt:V";
#endif
break;
#ifdef OBJ_VMS
- case '+': /* For g++ */
+ case '+': /* For g++. Hash any name > 31 chars long. */
+ flag_hash_long_names = 1;
+ break;
+
+ case '1': /* For backward compatibility */
+ flag_one = 1;
+ break;
+
+ case 'H': /* Show new symbol after hash truncation */
+ flag_show_after_trunc = 1;
break;
case 'h': /* No hashing of mixed-case names */
{
extern char vms_name_mapping;
vms_name_mapping = atoi (arg);
+ flag_no_hash_mixed_case = 1;
}
break;
- case 'H': /* Show new symbol after hash truncation */
+ case 'v':
+ {
+ extern char *compiler_version_string;
+ compiler_version_string = arg;
+ }
break;
#endif
-t FILE ignored\n\
-T ignored\n\
-V ignored\n");
+#ifdef OBJ_VMS
+ fprintf (stream, "\
+-+ hash names longer than 31 characters\n\
+-1 ?\n\
+-H show new symbol after hash truncation\n\
+-h do not hash mixed-case names\n\
+-vVERSION compiler version is VERSION\n");
+#endif
}
\f
/* We have no need to default values of symbols. */
S_SET_EXTERNAL (symbolP);
}
#ifdef OBJ_VMS
- if ( (!temp) || !flagseen['1'])
- S_GET_OTHER(symbolP) = const_flag;
+ {
+ extern int flag_one;
+ if ( (!temp) || !flag_one)
+ S_GET_OTHER(symbolP) = const_flag;
+ }
#endif /* not OBJ_VMS */
know (symbolP->sy_frag == &zero_address_frag);
demand_empty_rest_of_line ();
register int temp;
temp = get_absolute_expression ();
- if (flagseen['R'])
+ if (flag_readonly_data_in_text)
{
section = text_section;
temp += 1000;
n_errs = had_errors ();
/* The -Z flag indicates that an object file should be generated,
regardless of warnings and errors. */
- if (flagseen['Z'])
+ if (flag_always_generate_output)
{
if (n_warns || n_errs)
as_warn ("%d error%s, %d warning%s, generating bad object file.\n",
data frags into the text segment. Do this before relaxing so
we know to take advantage of -R and make shorter addresses. */
#if !defined (OBJ_AOUT) || defined (BFD_ASSEMBLER)
- if (flagseen['R'])
+ if (flag_readonly_data_in_text)
{
merge_data_into_text ();
}
}
}
+ /* Now do any format-specific adjustments to the symbol table, such
+ as adding file symbols. */
+#ifdef obj_adjust_symtab
+ obj_adjust_symtab ();
+#endif
+
+ /* Now that all the sizes are known, and contents correct, we can
+ start writing to the file. */
+ set_symtab ();
+
/* If *_frob_file changes the symbol value at this point, it is
responsible for moving the changed value into symp->bsym->value
as well. Hopefully all symbol value changing can be done in
obj_frob_file ();
#endif
- /* Now that all the sizes are known, and contents correct, we can
- start writing to the file. */
- set_symtab ();
-
bfd_map_over_sections (stdoutput, write_relocs, (char *) 0);
bfd_map_over_sections (stdoutput, write_contents, (char *) 0);
+ S_GET_VALUE (lie->sub)));
if (offset <= -32768 || offset >= 32767)
{
- if (flagseen['K'])
+ if (flag_warn_displacement)
{
char buf[50];
sprint_value (buf, (addressT) lie->addnum);
/* Warn if a .word value is too large when treated as a signed
number. We already know it is not too negative. This is to
catch over-large switches generated by gcc on the 68k. */
- if (!flagseen['J']
+ if (!flag_signed_overflow_ok
&& size == 2
&& add_number > 0x7fff)
as_bad_where (fixP->fx_file, fixP->fx_line,