Browse Source

Patches from Jerry Blakely <gerry_blakley@wellfleet.com>:

* as.c (listing_filename): New static variable.
	(show_usage): Mention -a=file.
	(parse_args): Support = option of -a to set name of listing file.
	(main): Pass listing_filename to listing_print.
	* listing.c (list_file): New static variable.
	(various): Replace printf with fprintf to list_file.
	(listing_print): If name argument is not NULL, open it as
	list_file.
	* doc/as.texinfo, doc/as.1: Document -a=file.
PR 6354.
gdb-4_18-branch
Ian Lance Taylor 32 years ago
parent
commit
85a961c6a1
  1. 11
      gas/ChangeLog
  2. 13
      gas/as.c
  3. 34
      gas/doc/as.1
  4. 10
      gas/doc/as.texinfo
  5. 75
      gas/listing.c

11
gas/ChangeLog

@ -1,5 +1,16 @@
Thu Jul 6 12:54:27 1995 Ian Lance Taylor <ian@cygnus.com> Thu Jul 6 12:54:27 1995 Ian Lance Taylor <ian@cygnus.com>
Patches from Jerry Blakely <gerry_blakley@wellfleet.com>:
* as.c (listing_filename): New static variable.
(show_usage): Mention -a=file.
(parse_args): Support = option of -a to set name of listing file.
(main): Pass listing_filename to listing_print.
* listing.c (list_file): New static variable.
(various): Replace printf with fprintf to list_file.
(listing_print): If name argument is not NULL, open it as
list_file.
* doc/as.texinfo, doc/as.1: Document -a=file.
* config/tc-sparc.c (s_reserve): Don't permit redefinition, even * config/tc-sparc.c (s_reserve): Don't permit redefinition, even
if the symbol was already in bss_section. Fix warning message. if the symbol was already in bss_section. Fix warning message.

13
gas/as.c

@ -45,6 +45,8 @@ static void perform_an_assembly_pass PARAMS ((int argc, char **argv));
int listing; /* true if a listing is wanted */ int listing; /* true if a listing is wanted */
static char *listing_filename = NULL; /* Name of listing file. */
char *myname; /* argv[0] */ char *myname; /* argv[0] */
#ifdef BFD_ASSEMBLER #ifdef BFD_ASSEMBLER
segT reg_section, expr_section; segT reg_section, expr_section;
@ -81,7 +83,8 @@ Options:\n\
h include high-level source\n\ h include high-level source\n\
l include assembly\n\ l include assembly\n\
n omit forms processing\n\ n omit forms processing\n\
s include symbols\n"); s include symbols\n\
=file set listing file name (must be last sub-option)\n");
fprintf (stream, "\ fprintf (stream, "\
-D produce assembler debugging messages\n\ -D produce assembler debugging messages\n\
-f skip whitespace and comment preprocessing\n\ -f skip whitespace and comment preprocessing\n\
@ -401,6 +404,12 @@ parse_args (pargc, pargv)
case 's': case 's':
listing |= LISTING_SYMBOLS; listing |= LISTING_SYMBOLS;
break; break;
case '=':
listing_filename = strdup (optarg + 1);
if (listing_filename == NULL)
as_fatal ("virtual memory exhausted");
optarg += strlen (listing_filename);
break;
default: default:
as_fatal ("invalid listing option `%c'", *optarg); as_fatal ("invalid listing option `%c'", *optarg);
break; break;
@ -528,7 +537,7 @@ main (argc, argv)
write_object_file (); write_object_file ();
#ifndef NO_LISTING #ifndef NO_LISTING
listing_print (""); listing_print (listing_filename);
#endif #endif
#ifndef OBJ_VMS /* does its own file handling */ #ifndef OBJ_VMS /* does its own file handling */

34
gas/doc/as.1

@ -8,8 +8,10 @@ GNU as\-\-the portable GNU assembler.
.SH SYNOPSIS .SH SYNOPSIS
.na .na
.B as .B as
.RB "[\|" \-a "\||\|" \-al "\||\|" -as\c .RB "[\|" \-a "[\|" dhlns "\|]" \c
\&\|] \&\[\|\=\c
.I file\c
\&\|]\|]
.RB "[\|" \-D "\|]" .RB "[\|" \-D "\|]"
.RB "[\|" \-f "\|]" .RB "[\|" \-f "\|]"
.RB "[\|" \-I .RB "[\|" \-I
@ -118,15 +120,25 @@ grave problem that stops the assembly.
.SH OPTIONS .SH OPTIONS
.TP .TP
.BR \-a \||\| \-al \||\| \-as .BR \-a
Turn on assembly listings; `\|\c Turn on assembly listings. There are various suboptions.
.B \-al\c .B d
\&\|', listing only, `\|\c omits debugging directives.
.B \-as\c .B h
\&\|', symbols includes the high level source code; this is only available if the
only, `\|\c source file can be found, and the code was compiled with
.B \-a\c .B \-g.
\&\|', everything. .B l
includes an assembly listing.
.B n
omits forms processing.
.B s
includes a symbol listing.
.B =
.I file
sets the listing file name; this must be the last suboption.
The default suboptions are
.B hls.
.TP .TP
.B \-D .B \-D
This option is accepted only for script compatibility with calls to This option is accepted only for script compatibility with calls to

10
gas/doc/as.texinfo

@ -194,7 +194,7 @@ Here is a brief summary of how to invoke @code{@value{AS}}. For details,
@c We don't use deffn and friends for the following because they seem @c We don't use deffn and friends for the following because they seem
@c to be limited to one line for the header. @c to be limited to one line for the header.
@smallexample @smallexample
@value{AS} [ -a[dhlns] ] [ -D ] [ -f ] [ --help ] @value{AS} [ -a[dhlns][=file] ] [ -D ] [ -f ] [ --help ]
[ -I @var{dir} ] [ -J ] [ -K ] [ -L ] [ -o @var{objfile} ] [ -I @var{dir} ] [ -J ] [ -K ] [ -L ] [ -o @var{objfile} ]
[ -R ] [ --statistics ] [ -v ] [ -version ] [ --version ] [ -R ] [ --statistics ] [ -v ] [ -version ] [ --version ]
[ -W ] [ -w ] [ -x ] [ -Z ] [ -W ] [ -w ] [ -x ] [ -Z ]
@ -254,11 +254,15 @@ omit forms processing
@item -as @item -as
include symbols include symbols
@item =file
set the name of the listing file
@end table @end table
You may combine these options; for example, use @samp{-aln} for assembly You may combine these options; for example, use @samp{-aln} for assembly
listing without forms processing. By itself, @samp{-a} defaults to listing without forms processing. The @samp{=file} option, if used, must be
@samp{-ahls}---that is, all listings turned on. the last one. By itself, @samp{-a} defaults to @samp{-ahls}---that is, all
listings turned on.
@item -D @item -D
Ignored. This option is accepted for script compatibility with calls to Ignored. This option is accepted for script compatibility with calls to

75
gas/listing.c

@ -186,6 +186,8 @@ extern fragS *frag_now;
static int paper_width = 200; static int paper_width = 200;
static int paper_height = 60; static int paper_height = 60;
/* File to output listings to. */
static FILE *list_file;
/* this static array is used to keep the text of data to be printed /* this static array is used to keep the text of data to be printed
before the start of the line. before the start of the line.
@ -455,12 +457,12 @@ listing_page (list)
if (page > 1) if (page > 1)
{ {
printf ("\f"); fprintf (list_file, "\f");
} }
printf ("%s %s \t\t\tpage %d\n", LISTING_HEADER, fn, page); fprintf (list_file, "%s %s \t\t\tpage %d\n", LISTING_HEADER, fn, page);
printf ("%s\n", title); fprintf (list_file, "%s\n", title);
printf ("%s\n", subtitle); fprintf (list_file, "%s\n", subtitle);
on_page = 3; on_page = 3;
eject = 0; eject = 0;
} }
@ -565,11 +567,11 @@ print_lines (list, string, address)
/* Print the hex for the first line */ /* Print the hex for the first line */
if (address == ~0) if (address == ~0)
{ {
printf ("% 4d ", list->line); fprintf (list_file, "% 4d ", list->line);
for (idx = 0; idx < nchars; idx++) for (idx = 0; idx < nchars; idx++)
printf (" "); fprintf (list_file, " ");
printf ("\t%s\n", string ? string : ""); fprintf (list_file, "\t%s\n", string ? string : "");
on_page++; on_page++;
listing_page (0); listing_page (0);
@ -578,11 +580,11 @@ print_lines (list, string, address)
{ {
if (had_errors ()) if (had_errors ())
{ {
printf ("% 4d ???? ", list->line); fprintf (list_file, "% 4d ???? ", list->line);
} }
else else
{ {
printf ("% 4d %04x ", list->line, address); fprintf (list_file, "% 4d %04x ", list->line, address);
} }
/* And the data to go along with it */ /* And the data to go along with it */
@ -590,12 +592,12 @@ print_lines (list, string, address)
while (*src && idx < nchars) while (*src && idx < nchars)
{ {
printf ("%c%c", src[0], src[1]); fprintf (list_file, "%c%c", src[0], src[1]);
src += 2; src += 2;
byte_in_word++; byte_in_word++;
if (byte_in_word == LISTING_WORD_SIZE) if (byte_in_word == LISTING_WORD_SIZE)
{ {
printf (" "); fprintf (list_file, " ");
idx++; idx++;
byte_in_word = 0; byte_in_word = 0;
} }
@ -603,14 +605,14 @@ print_lines (list, string, address)
} }
for (; idx < nchars; idx++) for (; idx < nchars; idx++)
printf (" "); fprintf (list_file, " ");
printf ("\t%s\n", string ? string : ""); fprintf (list_file, "\t%s\n", string ? string : "");
on_page++; on_page++;
listing_page (list); listing_page (list);
if (list->message) if (list->message)
{ {
printf ("**** %s\n", list->message); fprintf (list_file, "**** %s\n", list->message);
listing_page (list); listing_page (list);
on_page++; on_page++;
} }
@ -623,23 +625,23 @@ print_lines (list, string, address)
nchars = ((LISTING_WORD_SIZE * 2) + 1) * LISTING_LHS_WIDTH_SECOND - 1; nchars = ((LISTING_WORD_SIZE * 2) + 1) * LISTING_LHS_WIDTH_SECOND - 1;
idx = 0; idx = 0;
/* Print any more lines of data, but more compactly */ /* Print any more lines of data, but more compactly */
printf ("% 4d ", list->line); fprintf (list_file, "% 4d ", list->line);
while (*src && idx < nchars) while (*src && idx < nchars)
{ {
printf ("%c%c", src[0], src[1]); fprintf (list_file, "%c%c", src[0], src[1]);
src += 2; src += 2;
idx += 2; idx += 2;
byte_in_word++; byte_in_word++;
if (byte_in_word == LISTING_WORD_SIZE) if (byte_in_word == LISTING_WORD_SIZE)
{ {
printf (" "); fprintf (list_file, " ");
idx++; idx++;
byte_in_word = 0; byte_in_word = 0;
} }
} }
printf ("\n"); fprintf (list_file, "\n");
on_page++; on_page++;
listing_page (list); listing_page (list);
@ -693,16 +695,16 @@ list_symbol_table ()
if (!got_some) if (!got_some)
{ {
printf ("DEFINED SYMBOLS\n"); fprintf (list_file, "DEFINED SYMBOLS\n");
on_page++; on_page++;
got_some = 1; got_some = 1;
} }
printf ("%20s:%-5d %s:%s %s\n", fprintf (list_file, "%20s:%-5d %s:%s %s\n",
ptr->sy_frag->line->file->filename, ptr->sy_frag->line->file->filename,
ptr->sy_frag->line->line, ptr->sy_frag->line->line,
segment_name (S_GET_SEGMENT (ptr)), segment_name (S_GET_SEGMENT (ptr)),
buf, S_GET_NAME (ptr)); buf, S_GET_NAME (ptr));
on_page++; on_page++;
listing_page (0); listing_page (0);
@ -712,10 +714,10 @@ list_symbol_table ()
} }
if (!got_some) if (!got_some)
{ {
printf ("NO DEFINED SYMBOLS\n"); fprintf (list_file, "NO DEFINED SYMBOLS\n");
on_page++; on_page++;
} }
printf ("\n"); fprintf (list_file, "\n");
on_page++; on_page++;
listing_page (0); listing_page (0);
@ -734,11 +736,11 @@ list_symbol_table ()
if (!got_some) if (!got_some)
{ {
got_some = 1; got_some = 1;
printf ("UNDEFINED SYMBOLS\n"); fprintf (list_file, "UNDEFINED SYMBOLS\n");
on_page++; on_page++;
listing_page (0); listing_page (0);
} }
printf ("%s\n", S_GET_NAME (ptr)); fprintf (list_file, "%s\n", S_GET_NAME (ptr));
on_page++; on_page++;
listing_page (0); listing_page (0);
} }
@ -746,7 +748,7 @@ list_symbol_table ()
} }
if (!got_some) if (!got_some)
{ {
printf ("NO UNDEFINED SYMBOLS\n"); fprintf (list_file, "NO UNDEFINED SYMBOLS\n");
on_page++; on_page++;
listing_page (0); listing_page (0);
} }
@ -765,7 +767,8 @@ print_source (current_file, list, buffer, width)
&& !current_file->at_end) && !current_file->at_end)
{ {
char *p = buffer_line (current_file, buffer, width); char *p = buffer_line (current_file, buffer, width);
printf ("%4d:%-13s **** %s\n", current_file->linenum, current_file->filename, p); fprintf (list_file, "%4d:%-13s **** %s\n", current_file->linenum,
current_file->filename, p);
on_page++; on_page++;
listing_page (list); listing_page (list);
} }
@ -924,6 +927,18 @@ listing_print (name)
title = ""; title = "";
subtitle = ""; subtitle = "";
if (name == NULL)
list_file = stdout;
else
{
list_file = fopen (name, "w");
if (list_file == NULL)
{
as_perror ("can't open list file: %s", name);
list_file = stdout;
}
}
if (listing & LISTING_NOFORM) if (listing & LISTING_NOFORM)
{ {
paper_height = 0; paper_height = 0;

Loading…
Cancel
Save