diff options
author | Ken Raeburn <raeburn@cygnus> | 1992-11-23 20:39:57 +0000 |
---|---|---|
committer | Ken Raeburn <raeburn@cygnus> | 1992-11-23 20:39:57 +0000 |
commit | 6efd877de5ab683fc5d7c216049f9f888bf18828 (patch) | |
tree | 14fbfbcba9ec0238dad02cac1981999b99c297dd | |
parent | 5707ea9fad0ff4b51cc2c913af218c0a0b8278e9 (diff) | |
download | gdb-6efd877de5ab683fc5d7c216049f9f888bf18828.zip gdb-6efd877de5ab683fc5d7c216049f9f888bf18828.tar.gz gdb-6efd877de5ab683fc5d7c216049f9f888bf18828.tar.bz2 |
Ran "indent", for GNU coding style; some code & comments still need fixup.
Removed some unneeded files.
configure.in: Don't look for te-386bsd.h, which doesn't exist...
-rw-r--r-- | gas/ChangeLog | 29 | ||||
-rw-r--r-- | gas/app.c | 925 | ||||
-rw-r--r-- | gas/as.c | 579 | ||||
-rw-r--r-- | gas/as.h | 312 | ||||
-rw-r--r-- | gas/bignum-copy.c | 79 | ||||
-rw-r--r-- | gas/bignum.h | 21 | ||||
-rw-r--r-- | gas/configure.in | 4 | ||||
-rw-r--r-- | gas/expr.h | 41 | ||||
-rw-r--r-- | gas/flonum-konst.c | 183 | ||||
-rw-r--r-- | gas/flonum-mult.c | 222 | ||||
-rw-r--r-- | gas/flonum.h | 51 | ||||
-rw-r--r-- | gas/frags.h | 83 | ||||
-rw-r--r-- | gas/hex-value.c | 50 | ||||
-rw-r--r-- | gas/input-file.c | 465 | ||||
-rw-r--r-- | gas/input-file.h | 52 | ||||
-rw-r--r-- | gas/listing.h | 85 | ||||
-rw-r--r-- | gas/messages.c | 383 | ||||
-rw-r--r-- | gas/obj.h | 58 | ||||
-rw-r--r-- | gas/obstack.c | 54 | ||||
-rw-r--r-- | gas/obstack.h | 52 | ||||
-rw-r--r-- | gas/output-file.h | 30 | ||||
-rw-r--r-- | gas/read.c | 3113 | ||||
-rw-r--r-- | gas/read.h | 178 | ||||
-rw-r--r-- | gas/strerror.c | 8 | ||||
-rw-r--r-- | gas/strstr.c | 38 | ||||
-rw-r--r-- | gas/struc-symbol.h | 90 | ||||
-rw-r--r-- | gas/symbols.c | 1217 | ||||
-rw-r--r-- | gas/symbols.h | 99 | ||||
-rw-r--r-- | gas/tc.h | 103 | ||||
-rw-r--r-- | gas/version.c | 11 | ||||
-rw-r--r-- | gas/write.c | 1786 | ||||
-rw-r--r-- | gas/write.h | 88 | ||||
-rw-r--r-- | gas/xmalloc.c | 43 | ||||
-rw-r--r-- | gas/xrealloc.c | 40 |
34 files changed, 5847 insertions, 4725 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog index 3b33dd1..9695b1e 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,5 +1,33 @@ +Mon Nov 23 11:00:16 1992 Ken Raeburn (raeburn@cygnus.com) + + * all files: Whitespace changes for GNU indentation style, done by + GNU `indent'. Some cleanup still needed. + + * configure.in: No te-386bsd.h file exists; don't try to use it. + +Tue Nov 10 09:49:24 1992 Ian Lance Taylor (ian@cygnus.com) + + * Makefile.in (as.o, obj-format.o): added dependency on subsegs.h. + + * subsegs.h: add extern to segment_info declaration. + + * read.h: added extern declarations for comment_chars, + line_comment_chars, and line_separator_chars. + read.c, app.c: removed definitions of comment_chars, + line_comment_chars, and line_separator_chars. + +Wed Oct 28 08:52:34 1992 Ken Raeburn (raeburn@cygnus.com) + + * version.c: Put conditional "const" before version_string, not + before dummy function for VMS. Now version 1.91.03. + + * app.c (do_scrub_next_char): Need double-\ before `000' to show + printed rep of null character. + Tue Oct 20 12:18:08 1992 Ian Lance Taylor (ian@cygnus.com) + * configure.in: i386-sysv and i386-sco use coffbfd. + * app.c (do_scrub_next_char): discard whitespace after a label. Sat Oct 10 12:33:45 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com) @@ -251,7 +279,6 @@ Tue Jun 30 20:25:54 1992 D. V. Henkel-Wallace (gumby@cygnus.com) * Makefile.in: Add program_suffix (parallel to program_prefix) ->>>>>>> 1.83 Wed Jun 24 10:57:54 1992 Steve Chamberlain (sac@thepub.cygnus.com) * app.c (process_escape): new function to handle escapes the right @@ -1,22 +1,22 @@ /* Copyright (C) 1987, 1990, 1991, 1992 Free Software Foundation, Inc. - + Modified by Allen Wirfs-Brock, Instantiations Inc 2/90 */ /* This is the Assembler Pre-Processor Copyright (C) 1987 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. */ @@ -28,20 +28,16 @@ */ #include <stdio.h> -#include "as.h" /* For BAD_CASE() only */ +#include "as.h" /* For BAD_CASE() only */ +#include "read.h" #if (__STDC__ != 1) && !defined(const) -#define const /* Nothing */ +#define const /* Nothing */ #endif -static char lex [256]; -static char symbol_chars[] = - "$._ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; - -/* These will go in BSS if not defined elsewhere, producing empty strings. */ -extern const char comment_chars[]; -extern const char line_comment_chars[]; -extern const char line_separator_chars[]; +static char lex[256]; +static char symbol_chars[] = +"$._ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; #define LEX_IS_SYMBOL_COMPONENT 1 #define LEX_IS_WHITESPACE 2 @@ -65,74 +61,88 @@ extern const char line_separator_chars[]; built statically at compile time rather than dynamically each and every time the assembler is run. xoxorich. */ -void do_scrub_begin() { - const char *p; - - lex[' '] = LEX_IS_WHITESPACE; - lex['\t'] = LEX_IS_WHITESPACE; - lex['\n'] = LEX_IS_NEWLINE; - lex[';'] = LEX_IS_LINE_SEPARATOR; - lex['"'] = LEX_IS_STRINGQUOTE; - lex['\''] = LEX_IS_ONECHAR_QUOTE; - lex[':'] = LEX_IS_COLON; +void +do_scrub_begin () +{ + const char *p; + + lex[' '] = LEX_IS_WHITESPACE; + lex['\t'] = LEX_IS_WHITESPACE; + lex['\n'] = LEX_IS_NEWLINE; + lex[';'] = LEX_IS_LINE_SEPARATOR; + lex['"'] = LEX_IS_STRINGQUOTE; + lex['\''] = LEX_IS_ONECHAR_QUOTE; + lex[':'] = LEX_IS_COLON; #ifdef MRI - lex['\''] = LEX_IS_STRINGQUOTE; + lex['\''] = LEX_IS_STRINGQUOTE; #endif - /* Note that these override the previous defaults, e.g. if ';' + /* Note that these override the previous defaults, e.g. if ';' is a comment char, then it isn't a line separator. */ - for (p = symbol_chars; *p; ++p) { - lex[*p] = LEX_IS_SYMBOL_COMPONENT; - } /* declare symbol characters */ - - for (p = line_comment_chars; *p; p++) { - lex[*p] = LEX_IS_LINE_COMMENT_START; - } /* declare line comment chars */ - - for (p = comment_chars; *p; p++) { - lex[*p] = LEX_IS_COMMENT_START; - } /* declare comment chars */ - - for (p = line_separator_chars; *p; p++) { - lex[*p] = LEX_IS_LINE_SEPARATOR; - } /* declare line separators */ - - /* Only allow slash-star comments if slash is not in use */ - if (lex['/'] == 0) { - lex['/'] = LEX_IS_TWOCHAR_COMMENT_1ST; - } - /* FIXME-soon. This is a bad hack but otherwise, we + for (p = symbol_chars; *p; ++p) + { + lex[*p] = LEX_IS_SYMBOL_COMPONENT; + } /* declare symbol characters */ + + for (p = line_comment_chars; *p; p++) + { + lex[*p] = LEX_IS_LINE_COMMENT_START; + } /* declare line comment chars */ + + for (p = comment_chars; *p; p++) + { + lex[*p] = LEX_IS_COMMENT_START; + } /* declare comment chars */ + + for (p = line_separator_chars; *p; p++) + { + lex[*p] = LEX_IS_LINE_SEPARATOR; + } /* declare line separators */ + + /* Only allow slash-star comments if slash is not in use */ + if (lex['/'] == 0) + { + lex['/'] = LEX_IS_TWOCHAR_COMMENT_1ST; + } + /* FIXME-soon. This is a bad hack but otherwise, we can't do c-style comments when '/' is a line comment char. xoxorich. */ - if (lex['*'] == 0) { - lex['*'] = LEX_IS_TWOCHAR_COMMENT_2ND; - } -} /* do_scrub_begin() */ + if (lex['*'] == 0) + { + lex['*'] = LEX_IS_TWOCHAR_COMMENT_2ND; + } +} /* do_scrub_begin() */ FILE *scrub_file; -int scrub_from_file() { - return getc(scrub_file); +int +scrub_from_file () +{ + return getc (scrub_file); } -void scrub_to_file(ch) -int ch; +void +scrub_to_file (ch) + int ch; { - ungetc(ch,scrub_file); -} /* scrub_to_file() */ + ungetc (ch, scrub_file); +} /* scrub_to_file() */ char *scrub_string; char *scrub_last_string; -int scrub_from_string() { - return scrub_string == scrub_last_string ? EOF : *scrub_string++; -} /* scrub_from_string() */ +int +scrub_from_string () +{ + return scrub_string == scrub_last_string ? EOF : *scrub_string++; +} /* scrub_from_string() */ -void scrub_to_string(ch) -int ch; +void +scrub_to_string (ch) + int ch; { - *--scrub_string=ch; -} /* scrub_to_string() */ + *--scrub_string = ch; +} /* scrub_to_string() */ /* Saved state of the scrubber */ static int state; @@ -146,80 +156,86 @@ static int add_newlines = 0; state at the time .include is interpreted is completely unrelated. That's why we have to save it all. */ -struct app_save { - int state; - int old_state; - char *out_string; - char out_buf[sizeof (out_buf)]; - int add_newlines; - char *scrub_string; - char *scrub_last_string; - FILE *scrub_file; -}; - -char *app_push() { +struct app_save + { + int state; + int old_state; + char *out_string; + char out_buf[sizeof (out_buf)]; + int add_newlines; + char *scrub_string; + char *scrub_last_string; + FILE *scrub_file; + }; + +char * +app_push () +{ register struct app_save *saved; - saved = (struct app_save *) xmalloc(sizeof (*saved)); - saved->state = state; - saved->old_state = old_state; - saved->out_string = out_string; - bcopy(saved->out_buf, out_buf, sizeof(out_buf)); - saved->add_newlines = add_newlines; - saved->scrub_string = scrub_string; + saved = (struct app_save *) xmalloc (sizeof (*saved)); + saved->state = state; + saved->old_state = old_state; + saved->out_string = out_string; + bcopy (saved->out_buf, out_buf, sizeof (out_buf)); + saved->add_newlines = add_newlines; + saved->scrub_string = scrub_string; saved->scrub_last_string = scrub_last_string; - saved->scrub_file = scrub_file; + saved->scrub_file = scrub_file; /* do_scrub_begin() is not useful, just wastes time. */ - return (char *)saved; + return (char *) saved; } -void app_pop(arg) -char *arg; +void +app_pop (arg) + char *arg; { - register struct app_save *saved = (struct app_save *)arg; - - /* There is no do_scrub_end (). */ - state = saved->state; - old_state = saved->old_state; - out_string = saved->out_string; - memcpy(saved->out_buf, out_buf, sizeof (out_buf)); - add_newlines = saved->add_newlines; - scrub_string = saved->scrub_string; - scrub_last_string = saved->scrub_last_string; - scrub_file = saved->scrub_file; - - free (arg); -} /* app_pop() */ - -int process_escape(ch) -char ch; + register struct app_save *saved = (struct app_save *) arg; + + /* There is no do_scrub_end (). */ + state = saved->state; + old_state = saved->old_state; + out_string = saved->out_string; + memcpy (saved->out_buf, out_buf, sizeof (out_buf)); + add_newlines = saved->add_newlines; + scrub_string = saved->scrub_string; + scrub_last_string = saved->scrub_last_string; + scrub_file = saved->scrub_file; + + free (arg); +} /* app_pop() */ + +int +process_escape (ch) + char ch; { - switch (ch) -{ - case 'b': - return '\b'; - case 'f': - return '\f'; - case 'n': - return '\n'; - case 'r': - return '\r'; - case 't': - return '\t'; - case '\'': - return '\''; - case '"': - return '\''; - default: - return ch; - } + switch (ch) + { + case 'b': + return '\b'; + case 'f': + return '\f'; + case 'n': + return '\n'; + case 'r': + return '\r'; + case 't': + return '\t'; + case '\'': + return '\''; + case '"': + return '\''; + default: + return ch; + } } -int do_scrub_next_char(get,unget) -int (*get)(); -void (*unget)(); +int +do_scrub_next_char (get, unget) + int (*get) (); + void (*unget) (); { - /*State 0: beginning of normal line + /*State 0: beginning of normal line 1: After first whitespace on line (flush more white) 2: After first non-white (opcode) on line (keep 1white) 3: after second white on line (into operands) (flush white) @@ -231,334 +247,405 @@ void (*unget)(); -1: output string in out_string and go to the state in old_state -2: flush text until a '*' '/' is seen, then go to state old_state */ - - register int ch, ch2 = 0; - - switch (state) { - case -1: - ch= *out_string++; - if(*out_string==0) { - state=old_state; - old_state=3; - } - return ch; - - case -2: - for(;;) { - do { - ch=(*get)(); - } while(ch!=EOF && ch!='\n' && ch!='*'); - if(ch=='\n' || ch==EOF) - return ch; - - /* At this point, ch must be a '*' */ - while ( (ch=(*get)()) == '*' ){ - ; - } - if(ch==EOF || ch=='/') - break; - (*unget)(ch); - } - state=old_state; - return ' '; - - case 4: - ch=(*get)(); - if(ch==EOF || (ch>='0' && ch<='9')) - return ch; - else { - while(ch!=EOF && IS_WHITESPACE(ch)) - ch=(*get)(); - if(ch=='"') { - (*unget)(ch); - out_string="\n.app-file "; - old_state=7; - state= -1; - return *out_string++; - } else { - while(ch!=EOF && ch!='\n') - ch=(*get)(); - return ch; - } - } - - case 5: - ch=(*get)(); - if(lex[ch]==LEX_IS_STRINGQUOTE) { - state=old_state; - return ch; - } else if(ch=='\\') { - state=6; - return ch; - } else if(ch==EOF) { - as_warn("End of file in string: inserted '\"'"); - state=old_state; - (*unget)('\n'); - return '"'; - } else { - return ch; - } - - case 6: - state=5; - ch=(*get)(); - switch(ch) { - /* This is neet. Turn "string + + register int ch, ch2 = 0; + + switch (state) + { + case -1: + ch = *out_string++; + if (*out_string == 0) + { + state = old_state; + old_state = 3; + } + return ch; + + case -2: + for (;;) + { + do + { + ch = (*get) (); + } + while (ch != EOF && ch != '\n' && ch != '*'); + if (ch == '\n' || ch == EOF) + return ch; + + /* At this point, ch must be a '*' */ + while ((ch = (*get) ()) == '*') + { + ; + } + if (ch == EOF || ch == '/') + break; + (*unget) (ch); + } + state = old_state; + return ' '; + + case 4: + ch = (*get) (); + if (ch == EOF || (ch >= '0' && ch <= '9')) + return ch; + else + { + while (ch != EOF && IS_WHITESPACE (ch)) + ch = (*get) (); + if (ch == '"') + { + (*unget) (ch); + out_string = "\n.app-file "; + old_state = 7; + state = -1; + return *out_string++; + } + else + { + while (ch != EOF && ch != '\n') + ch = (*get) (); + return ch; + } + } + + case 5: + ch = (*get) (); + if (lex[ch] == LEX_IS_STRINGQUOTE) + { + state = old_state; + return ch; + } + else if (ch == '\\') + { + state = 6; + return ch; + } + else if (ch == EOF) + { + as_warn ("End of file in string: inserted '\"'"); + state = old_state; + (*unget) ('\n'); + return '"'; + } + else + { + return ch; + } + + case 6: + state = 5; + ch = (*get) (); + switch (ch) + { + /* This is neet. Turn "string more string" into "string\n more string" */ - case '\n': - (*unget)('n'); - add_newlines++; - return '\\'; - - case '"': - case '\\': - case 'b': - case 'f': - case 'n': - case 'r': - case 't': + case '\n': + (*unget) ('n'); + add_newlines++; + return '\\'; + + case '"': + case '\\': + case 'b': + case 'f': + case 'n': + case 'r': + case 't': #ifdef BACKSLASH_V - case 'v': + case 'v': #endif /* BACKSLASH_V */ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - break; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + break; #if defined(IGNORE_NONSTANDARD_ESCAPES) | defined(ONLY_STANDARD_ESCAPES) - default: - as_warn("Unknown escape '\\%c' in string: Ignored",ch); - break; + default: + as_warn ("Unknown escape '\\%c' in string: Ignored", ch); + break; #else /* ONLY_STANDARD_ESCAPES */ - default: - /* Accept \x as x for any x */ - break; + default: + /* Accept \x as x for any x */ + break; #endif /* ONLY_STANDARD_ESCAPES */ - - case EOF: - as_warn("End of file in string: '\"' inserted"); - return '"'; - } - return ch; - - case 7: - ch=(*get)(); - state=5; - old_state=8; - return ch; - - case 8: - do ch= (*get)(); - while(ch!='\n'); - state=0; - return ch; - } - /* OK, we are somewhere in states 0 through 4 */ - -/* flushchar: */ - ch=(*get)(); - recycle: - if (ch == EOF) { - if (state != 0) - as_warn("End of file not at end of a line: Newline inserted."); - return ch; + case EOF: + as_warn ("End of file in string: '\"' inserted"); + return '"'; + } + return ch; + + case 7: + ch = (*get) (); + state = 5; + old_state = 8; + return ch; + + case 8: + do + ch = (*get) (); + while (ch != '\n'); + state = 0; + return ch; + } + + /* OK, we are somewhere in states 0 through 4 */ + + /* flushchar: */ + ch = (*get) (); +recycle: + if (ch == EOF) + { + if (state != 0) + as_warn ("End of file not at end of a line: Newline inserted."); + return ch; + } + + switch (lex[ch]) + { + case LEX_IS_WHITESPACE: + do + ch = (*get) (); + while (ch != EOF && IS_WHITESPACE (ch)); + if (ch == EOF) + return ch; + + if (IS_COMMENT (ch) || (state == 0 && IS_LINE_COMMENT (ch)) || ch == '/' || IS_LINE_SEPARATOR (ch)) + { + goto recycle; } - - switch (lex[ch]) { - case LEX_IS_WHITESPACE: - do ch=(*get)(); - while(ch!=EOF && IS_WHITESPACE(ch)); - if(ch==EOF) - return ch; - - if(IS_COMMENT(ch) || (state==0 && IS_LINE_COMMENT(ch)) || ch=='/' || IS_LINE_SEPARATOR(ch)) { - goto recycle; - } #ifdef MRI - (*unget)(ch); /* Put back */ - return ' '; /* Always return one space at start of line */ + (*unget) (ch); /* Put back */ + return ' '; /* Always return one space at start of line */ #endif - switch (state) { - case 0: state++; goto recycle; /* Punted leading sp */ - case 1: BAD_CASE(state); /* We can't get here */ - case 2: state++; (*unget)(ch); return ' '; /* Sp after opco */ - case 3: goto recycle; /* Sp in operands */ - default: BAD_CASE(state); + + /* If we're in state 2, we've seen a non-white + character followed by whitespace. If the next + character is ':', this is whitespace after a label + name which we can ignore. */ + if (state == 2 && lex[ch] == LEX_IS_COLON) + { + state = 0; + return ch; + } + + switch (state) + { + case 0: + state++; + goto recycle; /* Punted leading sp */ + case 1: + BAD_CASE (state); /* We can't get here */ + case 2: + state++; + (*unget) (ch); + return ' '; /* Sp after opco */ + case 3: + goto recycle; /* Sp in operands */ + default: + BAD_CASE (state); + } + break; + + case LEX_IS_TWOCHAR_COMMENT_1ST: + ch2 = (*get) (); + if (ch2 != EOF && lex[ch2] == LEX_IS_TWOCHAR_COMMENT_2ND) + { + for (;;) + { + do + { + ch2 = (*get) (); + if (ch2 != EOF && IS_NEWLINE (ch2)) + add_newlines++; } - break; - - case LEX_IS_TWOCHAR_COMMENT_1ST: - ch2=(*get)(); - if (ch2 != EOF && lex[ch2] == LEX_IS_TWOCHAR_COMMENT_2ND) { - for(;;) { - do { - ch2=(*get)(); - if(ch2 != EOF && IS_NEWLINE(ch2)) - add_newlines++; - } while(ch2!=EOF && - (lex[ch2] != LEX_IS_TWOCHAR_COMMENT_2ND)); - - while (ch2!=EOF && - (lex[ch2] == LEX_IS_TWOCHAR_COMMENT_2ND)){ - ch2=(*get)(); - } - - if(ch2==EOF - || lex[ch2] == LEX_IS_TWOCHAR_COMMENT_1ST) - break; - (*unget)(ch); - } - if(ch2==EOF) - as_warn("End of file in multiline comment"); - - ch = ' '; - goto recycle; - } else { - if(ch2!=EOF) - (*unget)(ch2); - return ch; + while (ch2 != EOF && + (lex[ch2] != LEX_IS_TWOCHAR_COMMENT_2ND)); + + while (ch2 != EOF && + (lex[ch2] == LEX_IS_TWOCHAR_COMMENT_2ND)) + { + ch2 = (*get) (); } + + if (ch2 == EOF + || lex[ch2] == LEX_IS_TWOCHAR_COMMENT_1ST) break; - - case LEX_IS_STRINGQUOTE: - old_state=state; - state=5; - return ch; -#ifndef MRI + (*unget) (ch); + } + if (ch2 == EOF) + as_warn ("End of file in multiline comment"); + + ch = ' '; + goto recycle; + } + else + { + if (ch2 != EOF) + (*unget) (ch2); + return ch; + } + break; + + case LEX_IS_STRINGQUOTE: + old_state = state; + state = 5; + return ch; +#ifndef MRI #ifndef IEEE_STYLE - case LEX_IS_ONECHAR_QUOTE: - ch=(*get)(); - if(ch==EOF) { - as_warn("End-of-file after a one-character quote; \000 inserted"); - ch=0; - } - if (ch == '\\') { - ch = (*get)(); - ch = process_escape(ch); - } - sprintf(out_buf,"%d", (int)(unsigned char)ch); + case LEX_IS_ONECHAR_QUOTE: + ch = (*get) (); + if (ch == EOF) + { + as_warn ("End-of-file after a one-character quote; \\000 inserted"); + ch = 0; + } + if (ch == '\\') + { + ch = (*get) (); + ch = process_escape (ch); + } + sprintf (out_buf, "%d", (int) (unsigned char) ch); - /* None of these 'x constants for us. We want 'x'. + + /* None of these 'x constants for us. We want 'x'. */ - if ( (ch=(*get)()) != '\'' ) { + if ((ch = (*get) ()) != '\'') + { #ifdef REQUIRE_CHAR_CLOSE_QUOTE - as_warn("Missing close quote: (assumed)"); + as_warn ("Missing close quote: (assumed)"); #else - (*unget)(ch); + (*unget) (ch); #endif - } - - old_state=state; - state= -1; - out_string=out_buf; - return *out_string++; + } + if (strlen (out_buf) == 1) + { + return out_buf[0]; + } + old_state = state; + state = -1; + out_string = out_buf; + return *out_string++; #endif #endif - case LEX_IS_COLON: - if(state!=3) - state=0; - return ch; - - case LEX_IS_NEWLINE: - /* Roll out a bunch of newlines from inside comments, etc. */ - if(add_newlines) { - --add_newlines; - (*unget)(ch); - } - /* fall thru into... */ - - case LEX_IS_LINE_SEPARATOR: - state=0; - return ch; - - case LEX_IS_LINE_COMMENT_START: - if (state != 0) /* Not at start of line, act normal */ - goto de_fault; - - /* FIXME-someday: The two character comment stuff was badly + case LEX_IS_COLON: + if (state != 3) + state = 0; + return ch; + + case LEX_IS_NEWLINE: + /* Roll out a bunch of newlines from inside comments, etc. */ + if (add_newlines) + { + --add_newlines; + (*unget) (ch); + } + /* fall thru into... */ + + case LEX_IS_LINE_SEPARATOR: + state = 0; + return ch; + + case LEX_IS_LINE_COMMENT_START: + if (state != 0) /* Not at start of line, act normal */ + goto de_fault; + + /* FIXME-someday: The two character comment stuff was badly thought out. On i386, we want '/' as line comment start AND we want C style comments. hence this hack. The whole lexical process should be reworked. xoxorich. */ - if (ch == '/' && (ch2 = (*get)()) == '*') { - state = -2; - return(do_scrub_next_char(get, unget)); - } else { - (*unget)(ch2); - } /* bad hack */ - - do ch=(*get)(); - while(ch!=EOF && IS_WHITESPACE(ch)); - if(ch==EOF) { - as_warn("EOF in comment: Newline inserted"); - return '\n'; - } - if(ch<'0' || ch>'9') { - /* Non-numerics: Eat whole comment line */ - while(ch!=EOF && !IS_NEWLINE(ch)) - ch=(*get)(); - if(ch==EOF) - as_warn("EOF in Comment: Newline inserted"); - state=0; - return '\n'; - } - /* Numerics begin comment. Perhaps CPP `# 123 "filename"' */ - (*unget)(ch); - old_state=4; - state= -1; - out_string=".line "; - return *out_string++; - - case LEX_IS_COMMENT_START: - do ch=(*get)(); - while(ch!=EOF && !IS_NEWLINE(ch)); - if(ch==EOF) - as_warn("EOF in comment: Newline inserted"); - state=0; - return '\n'; - - default: - de_fault: - /* Some relatively `normal' character. */ - if(state==0) { - state=2; /* Now seeing opcode */ - return ch; - } else if(state==1) { - state=2; /* Ditto */ - return ch; - } else { - return ch; /* Opcode or operands already */ - } + if (ch == '/' && (ch2 = (*get) ()) == '*') + { + state = -2; + return (do_scrub_next_char (get, unget)); + } + else + { + (*unget) (ch2); + } /* bad hack */ + + do + ch = (*get) (); + while (ch != EOF && IS_WHITESPACE (ch)); + if (ch == EOF) + { + as_warn ("EOF in comment: Newline inserted"); + return '\n'; + } + if (ch < '0' || ch > '9') + { + /* Non-numerics: Eat whole comment line */ + while (ch != EOF && !IS_NEWLINE (ch)) + ch = (*get) (); + if (ch == EOF) + as_warn ("EOF in Comment: Newline inserted"); + state = 0; + return '\n'; + } + /* Numerics begin comment. Perhaps CPP `# 123 "filename"' */ + (*unget) (ch); + old_state = 4; + state = -1; + out_string = ".line "; + return *out_string++; + + case LEX_IS_COMMENT_START: + do + ch = (*get) (); + while (ch != EOF && !IS_NEWLINE (ch)); + if (ch == EOF) + as_warn ("EOF in comment: Newline inserted"); + state = 0; + return '\n'; + + default: + de_fault: + /* Some relatively `normal' character. */ + if (state == 0) + { + state = 2; /* Now seeing opcode */ + return ch; } - return -1; + else if (state == 1) + { + state = 2; /* Ditto */ + return ch; + } + else + { + return ch; /* Opcode or operands already */ + } + } + return -1; } #ifdef TEST -char comment_chars[] = "|"; -char line_comment_chars[] = "#"; +const char comment_chars[] = "|"; +const char line_comment_chars[] = "#"; -main() +main () { - int ch; - - app_begin(); - while((ch=do_scrub_next_char(stdin))!=EOF) - putc(ch,stdout); + int ch; + + app_begin (); + while ((ch = do_scrub_next_char (stdin)) != EOF) + putc (ch, stdout); } -as_warn(str) -char *str; +as_warn (str) + char *str; { - fputs(str,stderr); - putc('\n',stderr); + fputs (str, stderr); + putc ('\n', stderr); } + #endif /* @@ -1,18 +1,18 @@ /* as.c - GAS main program. Copyright (C) 1987, 1990, 1991, 1992 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. */ @@ -36,7 +36,7 @@ #include <string.h> #ifdef _POSIX_SOURCE -#include <sys/types.h> /* For pid_t in signal.h */ +#include <sys/types.h> /* For pid_t in signal.h */ #endif #include <signal.h> @@ -54,9 +54,9 @@ #define SIGTY void -static void got_sig(int sig); -static char *stralloc(char *str); -static void perform_an_assembly_pass(int argc, char **argv); +static void got_sig (int sig); +static char *stralloc (char *str); +static void perform_an_assembly_pass (int argc, char **argv); #else /* __STDC__ */ @@ -64,52 +64,54 @@ static void perform_an_assembly_pass(int argc, char **argv); #define SIGTY int #endif -static SIGTY got_sig(); -static char *stralloc(); /* Make a (safe) copy of a string. */ -static void perform_an_assembly_pass(); +static SIGTY got_sig (); +static char *stralloc (); /* Make a (safe) copy of a string. */ +static void perform_an_assembly_pass (); #endif /* not __STDC__ */ #ifdef DONTDEF -static char * gdb_symbol_file_name; -long gdb_begin(); +static char *gdb_symbol_file_name; +long gdb_begin (); #endif -int listing; /* true if a listing is wanted */ +int listing; /* true if a listing is wanted */ -char *myname; /* argv[0] */ +char *myname; /* argv[0] */ extern char version_string[]; -int main(argc,argv) -int argc; -char **argv; +int +main (argc, argv) + int argc; + char **argv; { - int work_argc; /* variable copy of argc */ - char **work_argv; /* variable copy of argv */ - char *arg; /* an arg to program */ - char a; /* an arg flag (after -) */ - static const int sig[] = { SIGHUP, SIGINT, SIGPIPE, SIGTERM, 0}; - - for(a=0;sig[a]!=0;a++) - if(signal(sig[a], SIG_IGN) != SIG_IGN) - signal(sig[a], got_sig); - - myname=argv[0]; - memset(flagseen, '\0', sizeof(flagseen)); /* aint seen nothing yet */ + int work_argc; /* variable copy of argc */ + char **work_argv; /* variable copy of argv */ + char *arg; /* an arg to program */ + char a; /* an arg flag (after -) */ + static const int sig[] = + {SIGHUP, SIGINT, SIGPIPE, SIGTERM, 0}; + + for (a = 0; sig[a] != 0; a++) + if (signal (sig[a], SIG_IGN) != SIG_IGN) + signal (sig[a], got_sig); + + 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 /* OBJ_DEFAULT_OUTPUT_FILE_NAME */ - out_file_name = OBJ_DEFAULT_OUTPUT_FILE_NAME; - - symbol_begin(); /* symbols.c */ - subsegs_begin(); /* subsegs.c */ - read_begin(); /* read.c */ - md_begin(); /* MACHINE.c */ - input_scrub_begin(); /* input_scrub.c */ + out_file_name = OBJ_DEFAULT_OUTPUT_FILE_NAME; + + symbol_begin (); /* symbols.c */ + subsegs_begin (); /* subsegs.c */ + read_begin (); /* read.c */ + md_begin (); /* MACHINE.c */ + input_scrub_begin (); /* input_scrub.c */ #ifdef DONTDEF - gdb_symbol_file_name = 0; + gdb_symbol_file_name = 0; #endif - /* + /* * 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. @@ -119,165 +121,185 @@ char **argv; * name(s) and ""(s) denoting stdin. These file names are used * (perhaps more than once) later. */ - /* FIXME-SOMEDAY this should use getopt. */ - work_argc = argc-1; /* don't count argv[0] */ - work_argv = argv+1; /* skip argv[0] */ - for (;work_argc--;work_argv++) { - arg = * work_argv; /* work_argv points to this argument */ - - if (*arg!='-') /* Filename. We need it later. */ - continue; /* Keep scanning args looking for flags. */ - if (arg[1] == '-' && arg[2] == 0) { - /* "--" as an argument means read STDIN */ - /* on this scan, we don't want to think about filenames */ - * work_argv = ""; /* Code that means 'use stdin'. */ - continue; - } - /* This better be a switch. */ - arg ++; /*->letter. */ - - while ((a = * arg) != '\0') {/* scan all the 1-char flags */ - arg ++; /* arg->after letter. */ - a &= 0x7F; /* ascii only please */ - /* if (flagseen[a]) + /* FIXME-SOMEDAY this should use getopt. */ + work_argc = argc - 1; /* don't count argv[0] */ + work_argv = argv + 1; /* skip argv[0] */ + for (; work_argc--; work_argv++) + { + arg = *work_argv; /* work_argv points to this argument */ + + if (*arg != '-') /* Filename. We need it later. */ + continue; /* Keep scanning args looking for flags. */ + if (arg[1] == '-' && arg[2] == 0) + { + /* "--" as an argument means read STDIN */ + /* on this scan, we don't want to think about filenames */ + *work_argv = ""; /* Code that means 'use stdin'. */ + continue; + } + /* This better be a switch. */ + arg++; /*->letter. */ + + while ((a = *arg) != '\0') + { /* scan all the 1-char flags */ + arg++; /* arg->after letter. */ + a &= 0x7F; /* ascii only please */ + /* if (flagseen[a]) as_tsktsk("%s: Flag option - %c has already been seen.", myname, a); */ - flagseen[a] = 1; - switch (a) { - - case 'a': - { - int loop =1; - - while (loop) { - switch (*arg) - { - case 'l': - listing |= LISTING_LISTING; - arg++; - break; - case 's': - listing |= LISTING_SYMBOLS; - arg++; - break; - case 'h': - listing |= LISTING_HLL; - arg++; - break; - - case 'n': - listing |= LISTING_NOFORM; - arg++; - break; - case 'd': - listing |= LISTING_NODEBUG; - arg++; - break; - default: - if (!listing) - listing= LISTING_DEFAULT; - loop = 0; - break; - } - } - } - - break; - - - case 'f': - break; /* -f means fast - no need for "app" preprocessor. */ - - case 'D': - /* DEBUG is implemented: it debugs different */ - /* things to other people's assemblers. */ - break; - + flagseen[a] = 1; + switch (a) + { + + case 'a': + { + int loop = 1; + + while (loop) + { + switch (*arg) + { + case 'l': + listing |= LISTING_LISTING; + arg++; + break; + case 's': + listing |= LISTING_SYMBOLS; + arg++; + break; + case 'h': + listing |= LISTING_HLL; + arg++; + break; + + case 'n': + listing |= LISTING_NOFORM; + arg++; + break; + case 'd': + listing |= LISTING_NODEBUG; + arg++; + break; + default: + if (!listing) + listing = LISTING_DEFAULT; + loop = 0; + break; + } + } + } + + break; + + + case 'f': + break; /* -f means fast - no need for "app" preprocessor. */ + + case 'D': + /* DEBUG is implemented: it debugs different */ + /* things to other people's assemblers. */ + break; + #ifdef DONTDEF - case 'G': /* GNU AS switch: include gdbsyms. */ - if (*arg) /* Rest of argument is file-name. */ - gdb_symbol_file_name = stralloc (arg); - else if (work_argc) { /* Next argument is file-name. */ - work_argc --; - * work_argv = NULL; /* Not a source file-name. */ - gdb_symbol_file_name = * ++ work_argv; - } else - as_warn("%s: I expected a filename after -G", myname); - arg = ""; /* Finished with this arg. */ - break; + case 'G': /* GNU AS switch: include gdbsyms. */ + if (*arg) /* Rest of argument is file-name. */ + gdb_symbol_file_name = stralloc (arg); + else if (work_argc) + { /* Next argument is file-name. */ + work_argc--; + *work_argv = NULL; /* Not a source file-name. */ + gdb_symbol_file_name = *++work_argv; + } + else + as_warn ("%s: I expected a filename after -G", myname); + arg = ""; /* Finished with this arg. */ + break; +#endif + + case 'I': + { /* Include file directory */ + + char *temp = NULL; + if (*arg) + temp = stralloc (arg); + else if (work_argc) + { + *work_argv = NULL; + work_argc--; + temp = *++work_argv; + } + else + as_warn ("%s: I expected a filename after -I", myname); + add_include_dir (temp); + arg = ""; /* Finished with this arg. */ + break; + } + +#ifdef WARN_SIGNED_OVERFLOW_WORD + /* Don't warn about signed overflow. */ + case 'J': + break; #endif - - case 'I': { /* Include file directory */ - - char *temp = NULL; - if (*arg) - temp = stralloc (arg); - else if (work_argc) { - * work_argv = NULL; - work_argc--; - temp = * ++ work_argv; - } else - as_warn("%s: I expected a filename after -I", myname); - add_include_dir (temp); - arg = ""; /* Finished with this arg. */ - break; - } - + #ifndef WORKING_DOT_WORD - case 'K': - break; + case 'K': + break; #endif - - case 'L': /* -L means keep L* symbols */ - break; - - case 'o': - if (*arg) /* Rest of argument is object file-name. */ - out_file_name = stralloc (arg); - else if (work_argc) { /* Want next arg for a file-name. */ - * work_argv = NULL; /* This is not a file-name. */ - work_argc--; - out_file_name = * ++ work_argv; - } else - as_warn("%s: I expected a filename after -o. \"%s\" assumed.", myname, out_file_name); - arg = ""; /* Finished with this arg. */ - break; - - case 'R': - /* -R means put data into text segment */ - break; - - case 'v': + + case 'L': /* -L means keep L* symbols */ + break; + + case 'o': + if (*arg) /* Rest of argument is object file-name. */ + out_file_name = stralloc (arg); + else if (work_argc) + { /* Want next arg for a file-name. */ + *work_argv = NULL; /* This is not a file-name. */ + work_argc--; + out_file_name = *++work_argv; + } + else + as_warn ("%s: I expected a filename after -o. \"%s\" assumed.", myname, out_file_name); + arg = ""; /* Finished with this arg. */ + break; + + case 'R': + /* -R means put data into text segment */ + break; + + case 'v': #ifdef VMS - { - extern char *compiler_version_string; - compiler_version_string = arg; - } + { + extern char *compiler_version_string; + compiler_version_string = arg; + } #else /* not VMS */ - fprintf(stderr,version_string); - if(*arg && strcmp(arg,"ersion")) - as_warn("Unknown -v option ignored"); + fprintf (stderr, version_string); + if (*arg && strcmp (arg, "ersion")) + as_warn ("Unknown -v option ignored"); #endif - while(*arg) arg++; /* Skip the rest */ - break; - - case 'W': - /* -W means don't warn about things */ - case 'X': - /* -X means treat warnings as errors */ - case 'Z': - /* -Z means attempt to generate object file even after errors. */ - break; - - default: - --arg; - if(md_parse_option(&arg,&work_argc,&work_argv)==0) - as_warn("%s: I don't understand '%c' flag.", myname, a); - if(arg && *arg) - arg++; - break; - } - } - /* + while (*arg) + arg++; /* Skip the rest */ + break; + + case 'W': + case 'w': + /* -W means don't warn about things */ + case 'X': + /* -X means treat warnings as errors */ + case 'Z': + /* -Z means attempt to generate object file even after errors. */ + break; + + default: + --arg; + if (md_parse_option (&arg, &work_argc, &work_argv) == 0) + as_warn ("%s: I don't understand '%c' flag.", myname, a); + if (arg && *arg) + arg++; + break; + } + } + /* * We have just processed a "-..." arg, which was not a * file-name. Smash it so the * things that look for filenames won't ever see it. @@ -285,41 +307,42 @@ char **argv; * Whatever work_argv points to, it has already been used * as part of a flag, so DON'T re-use it as a filename. */ - *work_argv = NULL; /* NULL means 'not a file-name' */ - } + *work_argv = NULL; /* NULL means 'not a file-name' */ + } #ifdef DONTDEF - if (gdb_begin(gdb_symbol_file_name) == 0) - flagseen ['G'] = 0; /* Don't do any gdbsym stuff. */ + if (gdb_begin (gdb_symbol_file_name) == 0) + flagseen['G'] = 0; /* Don't do any gdbsym stuff. */ #endif - /* Here with flags set up in flagseen[]. */ - perform_an_assembly_pass(argc,argv); /* Assemble it. */ + /* Here with flags set up in flagseen[]. */ + perform_an_assembly_pass (argc, argv); /* Assemble it. */ #ifdef TC_I960 - brtab_emit(); + brtab_emit (); #endif - if (seen_at_least_1_file() - && !((had_warnings() && flagseen['Z']) - || had_errors() > 0)) { - write_object_file(); /* relax() addresses then emit object file */ - } /* we also check in write_object_file() just before emit. */ - - input_scrub_end(); - md_end(); /* MACHINE.c */ - + if (seen_at_least_1_file () + && !((had_warnings () && flagseen['Z']) + || had_errors () > 0)) + { + write_object_file (); /* relax() addresses then emit object file */ + } /* we also check in write_object_file() just before emit. */ + + input_scrub_end (); + md_end (); /* MACHINE.c */ + #ifndef NO_LISTING - listing_print(""); + listing_print (""); #endif - + #ifndef VMS - return((had_warnings() && flagseen['Z']) - || had_errors() > 0); /* WIN */ -#else /* VMS */ - return(!((had_warnings() && flagseen['Z']) - || had_errors() > 0)); /* WIN */ -#endif /* VMS */ - -} /* main() */ + return ((had_warnings () && flagseen['Z']) + || had_errors () > 0);/* WIN */ +#else /* VMS */ + return (!((had_warnings () && flagseen['Z']) + || had_errors () > 0)); /* WIN */ +#endif /* VMS */ +} /* main() */ + /* perform_an_assembly_pass() * * Here to attempt 1 pass over each input file. @@ -331,51 +354,54 @@ char **argv; * Note the un*x semantics: there is only 1 logical input file, but it * may be a catenation of many 'physical' input files. */ -static void perform_an_assembly_pass(argc, argv) -int argc; -char **argv; +static void +perform_an_assembly_pass (argc, argv) + int argc; + char **argv; { - int saw_a_file = 0; - unsigned int i; - need_pass_2 = 0; - + int saw_a_file = 0; + unsigned int i; + need_pass_2 = 0; + #ifdef MANY_SEGMENTS - - for (i= SEG_E0; i < SEG_UNKNOWN; i++) - { - segment_info[i].fix_root = 0; - } - /* Create the three fixed ones */ - subseg_new (SEG_E0, 0); - subseg_new (SEG_E1, 0); - subseg_new (SEG_E2, 0); - strcpy(segment_info[SEG_E0].scnhdr.s_name,".text"); - strcpy(segment_info[SEG_E1].scnhdr.s_name,".data"); - strcpy(segment_info[SEG_E2].scnhdr.s_name,".bss"); - - subseg_new (SEG_E0, 0); + + for (i = SEG_E0; i < SEG_UNKNOWN; i++) + { + segment_info[i].fix_root = 0; + } + /* Create the three fixed ones */ + subseg_new (SEG_E0, 0); + subseg_new (SEG_E1, 0); + subseg_new (SEG_E2, 0); + strcpy (segment_info[SEG_E0].scnhdr.s_name, ".text"); + strcpy (segment_info[SEG_E1].scnhdr.s_name, ".data"); + strcpy (segment_info[SEG_E2].scnhdr.s_name, ".bss"); + + subseg_new (SEG_E0, 0); #else /* not MANY_SEGMENTS */ - text_fix_root = NULL; - data_fix_root = NULL; - bss_fix_root = NULL; - - subseg_new (SEG_TEXT, 0); + text_fix_root = NULL; + data_fix_root = NULL; + bss_fix_root = NULL; + + subseg_new (SEG_TEXT, 0); #endif /* not MANY_SEGMENTS */ - argv++; /* skip argv[0] */ - argc--; /* skip argv[0] */ - while (argc--) { - if (*argv) { /* Is it a file-name argument? */ - saw_a_file++; - /* argv->"" if stdin desired, else->filename */ - read_a_source_file(*argv); - } - argv++; /* completed that argv */ + argv++; /* skip argv[0] */ + argc--; /* skip argv[0] */ + while (argc--) + { + if (*argv) + { /* Is it a file-name argument? */ + saw_a_file++; + /* argv->"" if stdin desired, else->filename */ + read_a_source_file (*argv); } - if(!saw_a_file) - read_a_source_file(""); -} /* perform_an_assembly_pass() */ + argv++; /* completed that argv */ + } + if (!saw_a_file) + read_a_source_file (""); +} /* perform_an_assembly_pass() */ /* * stralloc() @@ -385,35 +411,38 @@ char **argv; */ static char * - stralloc (str) -char * str; +stralloc (str) + char *str; { - register char * retval; - register long len; - - len = strlen (str) + 1; - retval = xmalloc (len); - (void) strcpy(retval, str); - return(retval); + register char *retval; + register long len; + + len = strlen (str) + 1; + retval = xmalloc (len); + (void) strcpy (retval, str); + return (retval); } #ifdef comment -static void lose() { - as_fatal("%s: 2nd pass not implemented - get your code from random(3)", myname); - return; -} /* lose() */ +static void +lose () +{ + as_fatal ("%s: 2nd pass not implemented - get your code from random(3)", myname); + return; +} /* lose() */ + #endif /* comment */ static SIGTY - got_sig(sig) -int sig; +got_sig (sig) + int sig; { - static here_before = 0; - - as_bad("Interrupted by signal %d", sig); - if(here_before++) - exit(1); - return((SIGTY) 0); + static here_before = 0; + + as_bad ("Interrupted by signal %d", sig); + if (here_before++) + exit (1); + return ((SIGTY) 0); } /* @@ -1,18 +1,18 @@ /* as.h - global header file Copyright (C) 1987, 1990, 1991, 1992 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. */ @@ -22,10 +22,10 @@ #include "host.h" #include "flonum.h" -#if __STDC__ != 1 -#define volatile /**/ +#ifndef __STDC__ +#define volatile /**/ #ifndef const -#define const /**/ +#define const /**/ #endif /* const */ #endif /* __STDC__ */ @@ -76,8 +76,8 @@ as_fatal("Case value %d unexpected at line %d of file \"%s\"\n", \ value, __LINE__, __FILE__); \ } - + /* These are assembler-wide concepts */ @@ -89,7 +89,7 @@ #endif #endif /* COMMON now defined */ -#define DEBUG /* temporary */ +#define DEBUG /* temporary */ #ifdef BROKEN_ASSERT /* turn off all assertion checks */ @@ -112,8 +112,8 @@ * Supplies sanitised buffers to read.c. * Also understands printing line-number part of error messages. */ - + /* subsegs.c Sub-segments. Also, segment(=expression type)s.*/ /* @@ -160,32 +160,33 @@ #define SEG_LIST SEG_TEXT,SEG_DATA,SEG_BSS #endif -typedef enum _segT { - SEG_ABSOLUTE = 0, - SEG_LIST, - SEG_UNKNOWN, - SEG_ABSENT, /* Mythical Segment (absent): NO expression seen. */ - SEG_PASS1, /* Mythical Segment: Need another pass. */ - SEG_GOOF, /* Only happens if AS has a logic error. */ - /* Invented so we don't crash printing */ - /* error message involving weird segment. */ - SEG_BIG, /* Bigger than 32 bits constant. */ - SEG_DIFFERENCE, /* Mythical Segment: absolute difference. */ - SEG_DEBUG, /* Debug segment */ - SEG_NTV, /* Transfert vector preload segment */ - SEG_PTV, /* Transfert vector postload segment */ - SEG_REGISTER, /* Mythical: a register-valued expression */ -} segT; +typedef enum _segT + { + SEG_ABSOLUTE = 0, + SEG_LIST, + SEG_UNKNOWN, + SEG_ABSENT, /* Mythical Segment (absent): NO expression seen. */ + SEG_PASS1, /* Mythical Segment: Need another pass. */ + SEG_GOOF, /* Only happens if AS has a logic error. */ + /* Invented so we don't crash printing */ + /* error message involving weird segment. */ + SEG_BIG, /* Bigger than 32 bits constant. */ + SEG_DIFFERENCE, /* Mythical Segment: absolute difference. */ + SEG_DEBUG, /* Debug segment */ + SEG_NTV, /* Transfert vector preload segment */ + SEG_PTV, /* Transfert vector postload segment */ + SEG_REGISTER, /* Mythical: a register-valued expression */ + } segT; #define SEG_MAXIMUM_ORDINAL (SEG_REGISTER) typedef int subsegT; -COMMON subsegT now_subseg; +COMMON subsegT now_subseg; /* What subseg we are accreting now? */ -COMMON segT now_seg; +COMMON segT now_seg; /* Segment our instructions emit to. */ /* Only OK values are SEG_TEXT or SEG_DATA. */ @@ -196,33 +197,34 @@ extern int section_alignment[]; /* relax() */ -typedef enum _relax_state { - rs_fill = 1, /* Variable chars to be repeated fr_offset times. +typedef enum _relax_state + { + rs_fill = 1, /* Variable chars to be repeated fr_offset times. Fr_symbol unused. Used with fr_offset == 0 for a constant length frag. */ - - rs_align, /* Align: Fr_offset: power of 2. 1 variable char: fill + + rs_align, /* Align: Fr_offset: power of 2. 1 variable char: fill character. */ - - rs_org, /* Org: Fr_offset, fr_symbol: address. 1 variable char: fill + + rs_org, /* Org: Fr_offset, fr_symbol: address. 1 variable char: fill character. */ - - rs_machine_dependent, - + + rs_machine_dependent, + #ifndef WORKING_DOT_WORD - rs_broken_word, /* JF: gunpoint */ + rs_broken_word, /* JF: gunpoint */ #endif -} relax_stateT; + } relax_stateT; /* typedef unsigned char relax_substateT; */ /* JF this is more likely to leave the end of a struct frag on an align boundry. Be very careful with this. */ typedef unsigned long relax_substateT; -typedef unsigned long relax_addressT;/* Enough bits for address. */ +typedef unsigned long relax_addressT; /* Enough bits for address. */ /* Still an integer type. */ - + /* frags.c */ /* @@ -236,159 +238,163 @@ typedef unsigned long relax_addressT;/* Enough bits for address. */ * of the 1st char of a frag is generally not known until after relax(). * Many things at assembly time describe an address by {object-file-address * of a particular frag}+offset. - + BUG: it may be smarter to have a single pointer off to various different - notes for different frag kinds. See how code pans + notes for different frag kinds. See how code pans */ struct frag /* a code fragment */ { - unsigned long fr_address; /* Object file address. */ - struct frag *fr_next; /* Chain forward; ascending address order. */ - /* Rooted in frch_root. */ - - long fr_fix; /* (Fixed) number of chars we know we have. */ - /* May be 0. */ - long fr_var; /* (Variable) number of chars after above. */ - /* May be 0. */ - struct symbol *fr_symbol; /* For variable-length tail. */ - long fr_offset; /* For variable-length tail. */ - char *fr_opcode; /*->opcode low addr byte,for relax()ation*/ - relax_stateT fr_type; /* What state is my tail in? */ - relax_substateT fr_subtype; - /* These are needed only on the NS32K machines */ - char fr_pcrel_adjust; - char fr_bsr; + unsigned long fr_address; /* Object file address. */ + struct frag *fr_next; /* Chain forward; ascending address order. */ + /* Rooted in frch_root. */ + + long fr_fix; /* (Fixed) number of chars we know we have. */ + /* May be 0. */ + long fr_var; /* (Variable) number of chars after above. */ + /* May be 0. */ + struct symbol *fr_symbol; /* For variable-length tail. */ + long fr_offset; /* For variable-length tail. */ + char *fr_opcode; /*->opcode low addr byte,for relax()ation*/ + relax_stateT fr_type; /* What state is my tail in? */ + relax_substateT fr_subtype; + /* These are needed only on the NS32K machines */ + char fr_pcrel_adjust; + char fr_bsr; #ifndef NO_LISTING - struct list_info_struct *line; + struct list_info_struct *line; #endif - char fr_literal [1]; /* Chars begin here. */ - /* One day we will compile fr_literal[0]. */ + char fr_literal[1]; /* Chars begin here. */ + /* One day we will compile fr_literal[0]. */ }; + #define SIZEOF_STRUCT_FRAG \ ((int)zero_address_frag.fr_literal-(int)&zero_address_frag) /* We want to say fr_literal[0] above. */ typedef struct frag fragS; -COMMON fragS *frag_now; /* -> current frag we are building. */ +COMMON fragS *frag_now; /* -> current frag we are building. */ /* This frag is incomplete. */ /* It is, however, included in frchain_now. */ /* Frag_now->fr_fix is bogus. Use: */ /* Virtual frag_now->fr_fix==obstack_next_free(&frags)-frag_now->fr_literal.*/ COMMON fragS zero_address_frag; /* For foreign-segment symbol fixups. */ -COMMON fragS bss_address_frag; /* For local common (N_BSS segment) fixups. */ +COMMON fragS bss_address_frag; /* For local common (N_BSS segment) fixups. */ /* main program "as.c" (command arguments etc) */ COMMON char flagseen[128]; /* ['x'] TRUE if "-x" seen. */ -COMMON char * out_file_name; /* name of emitted object file */ +COMMON char *out_file_name; /* name of emitted object file */ COMMON int need_pass_2; /* TRUE if we need a second pass. */ COMMON int linkrelax; /* TRUE if we should do no relaxing, and leave lots of padding. */ -typedef struct { - char * poc_name; /* assembler mnemonic, lower case, no '.' */ - void (*poc_handler)(); /* Do the work */ - int poc_val; /* Value to pass to handler */ -} pseudo_typeS; +typedef struct + { + char *poc_name; /* assembler mnemonic, lower case, no '.' */ + void (*poc_handler) (); /* Do the work */ + int poc_val; /* Value to pass to handler */ + } + +pseudo_typeS; -#if (__STDC__ == 1) & !defined(NO_STDARG) +#ifdef __STDC__ -int had_errors(void); -int had_warnings(void); -void as_bad(const char *Format, ...); -void as_fatal(const char *Format, ...); -void as_tsktsk(const char *Format, ...); -void as_warn(const char *Format, ...); +int had_errors (void); +int had_warnings (void); +void as_bad (const char *Format,...); +void as_fatal (const char *Format,...); +void as_tsktsk (const char *Format,...); +void as_warn (const char *Format,...); #else -int had_errors(); -int had_warnings(); -void as_bad(); -void as_fatal(); -void as_tsktsk(); -void as_warn(); +int had_errors (); +int had_warnings (); +void as_bad (); +void as_fatal (); +void as_tsktsk (); +void as_warn (); #endif /* __STDC__ & !NO_STDARG */ -#if __STDC__ == 1 - -char *app_push(void); -char *atof_ieee(char *str, int what_kind, LITTLENUM_TYPE *words); -char *input_scrub_include_file(char *filename, char *position); -char *input_scrub_new_file(char *filename); -char *input_scrub_next_buffer(char **bufp); -char *strstr(const char *s, const char *wanted); -char *xmalloc(int size); -char *xrealloc(char *ptr, long n); -int do_scrub_next_char(int (*get)(), void (*unget)()); -int gen_to_words(LITTLENUM_TYPE *words, int precision, long exponent_bits); -int had_err(void); -int had_errors(void); -int had_warnings(void); -int ignore_input(void); -int scrub_from_file(void); -int scrub_from_file(void); -int scrub_from_string(void); -int seen_at_least_1_file(void); -void app_pop(char *arg); -void as_howmuch(FILE *stream); -void as_perror(char *gripe, char *filename); -void as_where(void); -void bump_line_counters(void); -void do_scrub_begin(void); -void input_scrub_begin(void); -void input_scrub_close(void); -void input_scrub_end(void); -void int_to_gen(long x); -void new_logical_line(char *fname, int line_number); -void scrub_to_file(int ch); -void scrub_to_string(int ch); -void subseg_change(segT seg, int subseg); -void subseg_new(segT seg, subsegT subseg); -void subsegs_begin(void); +#ifdef __STDC__ + +char *app_push (void); +char *atof_ieee (char *str, int what_kind, LITTLENUM_TYPE * words); +char *input_scrub_include_file (char *filename, char *position); +char *input_scrub_new_file (char *filename); +char *input_scrub_next_buffer (char **bufp); +char *strstr (const char *s, const char *wanted); +char *xmalloc (int size); +char *xrealloc (char *ptr, long n); +int do_scrub_next_char (int (*get) (), void (*unget) ()); +int gen_to_words (LITTLENUM_TYPE * words, int precision, long exponent_bits); +int had_err (void); +int had_errors (void); +int had_warnings (void); +int ignore_input (void); +int scrub_from_file (void); +int scrub_from_file (void); +int scrub_from_string (void); +int seen_at_least_1_file (void); +void app_pop (char *arg); +void as_howmuch (FILE * stream); +void as_perror (char *gripe, char *filename); +void as_where (void); +void bump_line_counters (void); +void do_scrub_begin (void); +void input_scrub_begin (void); +void input_scrub_close (void); +void input_scrub_end (void); +void int_to_gen (long x); +void new_logical_line (char *fname, int line_number); +void scrub_to_file (int ch); +void scrub_to_string (int ch); +void subseg_change (segT seg, int subseg); +void subseg_new (segT seg, subsegT subseg); +void subsegs_begin (void); #else /* not __STDC__ */ -char *app_push(); -char *atof_ieee(); -char *input_scrub_include_file(); -char *input_scrub_new_file(); -char *input_scrub_next_buffer(); -char *strstr(); -char *xmalloc(); -char *xrealloc(); -int do_scrub_next_char(); -int gen_to_words(); -int had_err(); -int had_errors(); -int had_warnings(); -int ignore_input(); -int scrub_from_file(); -int scrub_from_file(); -int scrub_from_string(); -int seen_at_least_1_file(); -void app_pop(); -void as_howmuch(); -void as_perror(); -void as_where(); -void bump_line_counters(); -void do_scrub_begin(); -void input_scrub_begin(); -void input_scrub_close(); -void input_scrub_end(); -void int_to_gen(); -void new_logical_line(); -void scrub_to_file(); -void scrub_to_string(); -void subseg_change(); -void subseg_new(); -void subsegs_begin(); +char *app_push (); +char *atof_ieee (); +char *input_scrub_include_file (); +char *input_scrub_new_file (); +char *input_scrub_next_buffer (); +char *strstr (); +char *xmalloc (); +char *xrealloc (); +int do_scrub_next_char (); +int gen_to_words (); +int had_err (); +int had_errors (); +int had_warnings (); +int ignore_input (); +int scrub_from_file (); +int scrub_from_file (); +int scrub_from_string (); +int seen_at_least_1_file (); +void app_pop (); +void as_howmuch (); +void as_perror (); +void as_where (); +void bump_line_counters (); +void do_scrub_begin (); +void input_scrub_begin (); +void input_scrub_close (); +void input_scrub_end (); +void int_to_gen (); +void new_logical_line (); +void scrub_to_file (); +void scrub_to_string (); +void subseg_change (); +void subseg_new (); +void subsegs_begin (); #endif /* not __STDC__ */ diff --git a/gas/bignum-copy.c b/gas/bignum-copy.c index 8e8ad9b..9ec9200 100644 --- a/gas/bignum-copy.c +++ b/gas/bignum-copy.c @@ -1,18 +1,18 @@ /* bignum_copy.c - copy a bignum Copyright (C) 1987, 1990, 1991, 1992 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. */ @@ -32,41 +32,48 @@ /* void */ int - bignum_copy(in, in_length, out, out_length) -register LITTLENUM_TYPE *in; -register int in_length; /* in sizeof(littlenum)s */ -register LITTLENUM_TYPE *out; -register int out_length; /* in sizeof(littlenum)s */ +bignum_copy (in, in_length, out, out_length) + register LITTLENUM_TYPE *in; + register int in_length; /* in sizeof(littlenum)s */ + register LITTLENUM_TYPE *out; + register int out_length; /* in sizeof(littlenum)s */ { - int significant_littlenums_dropped; - - if (out_length < in_length) { - LITTLENUM_TYPE *p; /* -> most significant (non-zero) input - littlenum. */ - - memcpy((void *) out, (void *) in, - out_length << LITTLENUM_SHIFT); - for (p = in + in_length - 1; p >= in; --p) { - if (* p) break; - } - significant_littlenums_dropped = p - in - in_length + 1; - - if (significant_littlenums_dropped < 0) { - significant_littlenums_dropped = 0; - } - } else { - memcpy((char *) out, (char *) in, - in_length << LITTLENUM_SHIFT); + int significant_littlenums_dropped; + + if (out_length < in_length) + { + LITTLENUM_TYPE *p; /* -> most significant (non-zero) input + littlenum. */ - if (out_length > in_length) { - memset((char *) (out + out_length), - '\0', (out_length - in_length) << LITTLENUM_SHIFT); - } + memcpy ((void *) out, (void *) in, + out_length << LITTLENUM_SHIFT); + for (p = in + in_length - 1; p >= in; --p) + { + if (*p) + break; + } + significant_littlenums_dropped = p - in - in_length + 1; + + if (significant_littlenums_dropped < 0) + { + significant_littlenums_dropped = 0; + } + } + else + { + memcpy ((char *) out, (char *) in, + in_length << LITTLENUM_SHIFT); - significant_littlenums_dropped = 0; + if (out_length > in_length) + { + memset ((char *) (out + out_length), + '\0', (out_length - in_length) << LITTLENUM_SHIFT); } - - return(significant_littlenums_dropped); -} /* bignum_copy() */ + + significant_littlenums_dropped = 0; + } + + return (significant_littlenums_dropped); +} /* bignum_copy() */ /* end of bignum-copy.c */ diff --git a/gas/bignum.h b/gas/bignum.h index 702a63e..2c5cd12 100644 --- a/gas/bignum.h +++ b/gas/bignum.h @@ -1,18 +1,18 @@ /* bignum.h-arbitrary precision integers Copyright (C) 1987, 1992 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. */ @@ -44,4 +44,17 @@ typedef unsigned short LITTLENUM_TYPE; #define LOG_TO_BASE_2_OF_10 (3.3219280948873623478703194294893901758651) /* WARNING: I haven't checked that the trailing digits are correct! */ +/* lengths are in sizeof(littlenum)s */ +#if __STDC__ == 1 + +int bignum_copy (LITTLENUM_TYPE * in, int in_length, + LITTLENUM_TYPE * out, int out_length); + +#else + +int bignum_copy (); + +#endif /* __STDC__ */ + + /* end of bignum.h */ diff --git a/gas/configure.in b/gas/configure.in index 9b20fe3..d222ee0 100644 --- a/gas/configure.in +++ b/gas/configure.in @@ -104,13 +104,15 @@ case ${target} in ;; i[34]86-*-bsd*) obj_format=aout - emulation=i386bsd ;; i[34]86-*-coff | i[34]86-*-sysv* | i[34]86-*-sco*) obj_format=coffbfd need_bfd="./../bfd/libbfd.a" gas_target=i386coff ;; + i[34]86-*-go32) + obj_format=aout + ;; i960-wrs-vxworks) obj_format=bout ;; @@ -1,18 +1,18 @@ /* expr.h -> header file for expr.c - Copyright (C) 1987 Free Software Foundation, Inc. - + Copyright (C) 1987, 1992 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. */ @@ -44,11 +44,12 @@ typedef struct { - symbolS *X_add_symbol; /* foo */ - symbolS *X_subtract_symbol; /* bar */ - long X_add_number; /* 42. Must be signed. */ - segT X_seg; /* What segment (expr type)? */ + symbolS *X_add_symbol; /* foo */ + symbolS *X_subtract_symbol; /* bar */ + long X_add_number; /* 42. Must be signed. */ + segT X_seg; /* What segment (expr type)? */ } + expressionS; /* result should be type (expressionS *). */ @@ -57,25 +58,25 @@ expressionS; /* If an expression is SEG_BIG, look here */ /* for its value. These common data may */ /* be clobbered whenever expr() is called. */ -extern FLONUM_TYPE generic_floating_point_number; /* Flonums returned here. */ +extern FLONUM_TYPE generic_floating_point_number; /* Flonums returned here. */ /* Enough to hold most precise flonum. */ -extern LITTLENUM_TYPE generic_bignum []; /* Bignums returned here. */ +extern LITTLENUM_TYPE generic_bignum[]; /* Bignums returned here. */ #define SIZE_OF_LARGE_NUMBER (20) /* Number of littlenums in above. */ typedef char operator_rankT; -#ifdef __STDC__ +#if __STDC__ == 1 -char get_symbol_end(void); -segT expr(int rank, expressionS *resultP); -unsigned int get_single_number(void); +char get_symbol_end (void); +segT expr (int rank, expressionS * resultP); +unsigned int get_single_number (void); -#else /* __STDC__ */ +#else /* not __STDC__ */ -char get_symbol_end(); -segT expr(); -unsigned int get_single_number(); +char get_symbol_end (); +segT expr (); +unsigned int get_single_number (); -#endif /* __STDC__ */ +#endif /* not __STDC__ */ /* end of expr.h */ diff --git a/gas/flonum-konst.c b/gas/flonum-konst.c new file mode 100644 index 0000000..e4e2c81 --- /dev/null +++ b/gas/flonum-konst.c @@ -0,0 +1,183 @@ +/* flonum_const.c - Useful Flonum constants + Copyright (C) 1987, 1990, 1991, 1992 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 "flonum.h" +/* JF: I added the last entry to this table, and I'm not + sure if its right or not. Could go either way. I wish + I really understood this stuff. */ + + +const int table_size_of_flonum_powers_of_ten = 11; + +static const LITTLENUM_TYPE zero[] = +{1}; + +/***********************************************************************\ + * * + * Warning: the low order bits may be WRONG here. * + * I took this from a suspect bc(1) script. * + * "minus_X"[] is supposed to be 10^(2^-X) expressed in base 2^16. * + * The radix point is just AFTER the highest element of the [] * + * * + * Because bc rounds DOWN for printing (I think), the lowest * + * significance littlenums should probably have 1 added to them. * + * * + \***********************************************************************/ + +/* JF: If this equals 6553/(2^16)+39321/(2^32)+... it approaches .1 */ +static const LITTLENUM_TYPE minus_1[] = +{ + 39321, 39321, 39321, 39321, 39321, 39321, 39321, 39321, 39321, 39321, + 39321, 39321, 39321, 39321, 39321, 39321, 39321, 39321, 39321, 6553}; +static const LITTLENUM_TYPE plus_1[] = +{10}; + +/* JF: If this equals 655/(2^16) + 23592/(2^32) + ... it approaches .01 */ +static const LITTLENUM_TYPE minus_2[] = +{ + 10485, 36700, 62914, 23592, 49807, 10485, 36700, 62914, 23592, 49807, + 10485, 36700, 62914, 23592, 49807, 10485, 36700, 62914, 23592, 655}; +static const LITTLENUM_TYPE plus_2[] = +{100}; + +/* This approaches .0001 */ +static const LITTLENUM_TYPE minus_3[] = +{ + 52533, 20027, 37329, 65116, 64067, 60397, 14784, 18979, 33659, 19503, + 2726, 9542, 629, 2202, 40475, 10590, 4299, 47815, 36280, 6}; +static const LITTLENUM_TYPE plus_3[] = +{10000}; + +/* JF: this approaches 1e-8 */ +static const LITTLENUM_TYPE minus_4[] = +{ + 22516, 49501, 54293, 19424, 60699, 6716, 24348, 22618, 23904, 21327, + 3919, 44703, 19149, 28803, 48959, 6259, 50273, 62237, 42}; +/* This equals 1525 * 2^16 + 57600 */ +static const LITTLENUM_TYPE plus_4[] = +{57600, 1525}; + +/* This approaches 1e-16 */ +static const LITTLENUM_TYPE minus_5[] = +{ + 22199, 45957, 17005, 26266, 10526, 16260, 55017, 35680, 40443, 19789, + 17356, 30195, 55905, 28426, 63010, 44197, 1844}; +static const LITTLENUM_TYPE plus_5[] = +{28609, 34546, 35}; + +static const LITTLENUM_TYPE minus_6[] = +{ + 30926, 26518, 13110, 43018, 54982, 48258, 24658, 15209, 63366, 11929, + 20069, 43857, 60487, 51}; +static const LITTLENUM_TYPE plus_6[] = +{61313, 34220, 16731, 11629, 1262}; + +static const LITTLENUM_TYPE minus_7[] = +{ + 29819, 14733, 21490, 40602, 31315, 65186, 2695}; +static const LITTLENUM_TYPE plus_7[] = +{ + 7937, 49002, 60772, 28216, 38893, 55975, 63988, 59711, 20227, 24}; + +static const LITTLENUM_TYPE minus_8[] = +{ + 45849, 19069, 18068, 36324, 37948, 48745, 10873, 64360, 15961, 20566, + 24178, 15922, 59427, 110}; +static const LITTLENUM_TYPE plus_8[] = +{ + 15873, 11925, 39177, 991, 14589, 19735, 25347, 65086, 53853, 938, + 37209, 47086, 33626, 23253, 32586, 42547, 9731, 59679, 590}; + +static const LITTLENUM_TYPE minus_9[] = +{ + 63601, 55221, 43562, 33661, 29067, 28203, 65417, 64352, 22462, 41110, + 12570, 28635, 23199, 50572, 28471, 27074, 46375, 64028, 13106, 63700, + 32698, 17493, 32420, 34382, 22750, 20681, 12300}; +static const LITTLENUM_TYPE plus_9[] = +{ + 63564, 61556, 29377, 54467, 18621, 28141, 36415, 61241, 47119, 30026, + 19740, 46002, 13541, 61413, 30480, 38664, 32205, 50593, 51112, 48904, + 48263, 43814, 286, 30826, 52813, 62575, 61390, 24540, 21495, 5}; + +static const LITTLENUM_TYPE minus_10[] = +{ + 50313, 34681, 1464, 25889, 19575, 41125, 17635, 4598, 49708, 13427, + 17287, 56115, 53783, 38255, 32415, 17778, 31596, 7557, 20951, 18477, + 40353, 1178, 44405, 11837, 11571, 50963, 15649, 11698, 40675, 2308,}; +static const LITTLENUM_TYPE plus_10[] = +{ + 18520, 53764, 54535, 61910, 61962, 59843, 46270, 58053, 12473, 63785, + 2449, 43230, 50044, 47595, 10403, 35766, 32607, 1124, 24966, 35044, + 25524, 23631, 18826, 14518, 58448, 14562, 49618, 5588, 25396, 28}; + +static const LITTLENUM_TYPE minus_11[] = +{ + 6223, 59909, 62437, 59960, 14652, 45336, 48800, 7647, 51962, 37982, + 60436, 58176, 26767, 8440, 9831, 48556, 20994, 14148, 6757, 17221, + 60624, 46129, 53210, 44085, 54016, 24259, 11232, 21229, 21313, 81,}; +static const LITTLENUM_TYPE plus_11[] = +{ + 36159, 2055, 33615, 61362, 23581, 62454, 9748, 15275, 39284, 58636, + 16269, 42793, 47240, 45774, 50861, 48400, 9413, 40281, 4030, 9572, + 7984, 33038, 59522, 19450, 40593, 24486, 54320, 6661, 55766, 805,}; + +/* Shut up complaints about differing pointer types. They only differ + in the const attribute, but there isn't any easy way to do this + */ +#define X (LITTLENUM_TYPE *) + +const FLONUM_TYPE flonum_negative_powers_of_ten[] = +{ + {X zero, X zero, X zero, 0, '+'}, + {X minus_1, X minus_1 + 19, X minus_1 + 19, -20, '+'}, + {X minus_2, X minus_2 + 19, X minus_2 + 19, -20, '+'}, + {X minus_3, X minus_3 + 19, X minus_3 + 19, -20, '+'}, + {X minus_4, X minus_4 + 18, X minus_4 + 18, -20, '+'}, + {X minus_5, X minus_5 + 16, X minus_5 + 16, -20, '+'}, + {X minus_6, X minus_6 + 13, X minus_6 + 13, -20, '+'}, + {X minus_7, X minus_7 + 6, X minus_7 + 6, -20, '+'}, + {X minus_8, X minus_8 + 13, X minus_8 + 13, -40, '+'}, + {X minus_9, X minus_9 + 26, X minus_9 + 26, -80, '+'}, + {X minus_10, X minus_10 + 29, X minus_10 + 29, -136, '+'}, + {X minus_11, X minus_11 + 29, X minus_11 + 29, -242, '+'}, +}; + +const FLONUM_TYPE flonum_positive_powers_of_ten[] = +{ + {X zero, X zero, X zero, 0, '+'}, + {X plus_1, X plus_1 + 0, X plus_1 + 0, 0, '+'}, + {X plus_2, X plus_2 + 0, X plus_2 + 0, 0, '+'}, + {X plus_3, X plus_3 + 0, X plus_3 + 0, 0, '+'}, + {X plus_4, X plus_4 + 1, X plus_4 + 1, 0, '+'}, + {X plus_5, X plus_5 + 2, X plus_5 + 2, 1, '+'}, + {X plus_6, X plus_6 + 4, X plus_6 + 4, 2, '+'}, + {X plus_7, X plus_7 + 9, X plus_7 + 9, 4, '+'}, + {X plus_8, X plus_8 + 18, X plus_8 + 18, 8, '+'}, + {X plus_9, X plus_9 + 29, X plus_9 + 29, 24, '+'}, + {X plus_10, X plus_10 + 29, X plus_10 + 29, 77, '+'}, + {X plus_11, X plus_11 + 29, X plus_11 + 29, 183, '+'}, +}; + +#ifdef VMS +dummy1 () +{ +} + +#endif +/* end of flonum_const.c */ diff --git a/gas/flonum-mult.c b/gas/flonum-mult.c index c5888c2..14fbd7d 100644 --- a/gas/flonum-mult.c +++ b/gas/flonum-mult.c @@ -1,15 +1,15 @@ -/* flonum_multip.c - multiply two flonums - Copyright (C) 1987, 1990, 1991 Free Software Foundation, Inc. - +/* flonum_mult.c - multiply two flonums + Copyright (C) 1987, 1990, 1991, 1992 Free Software Foundation, Inc. + This file is part of Gas, the GNU Assembler. - + The GNU assembler is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY. No author or distributor accepts responsibility to anyone for the consequences of using it or for whether it serves any particular purpose or works at all, unless he says so in writing. Refer to the GNU Assembler General Public License for full details. - + Everyone is granted permission to copy, modify and redistribute the GNU Assembler, but only under the conditions described in the GNU Assembler General Public License. A copy of this license is @@ -72,128 +72,130 @@ (C style also gives deeper insight [to me] ... oh well ...) */ -void flonum_multip (a, b, product) -const FLONUM_TYPE *a; -const FLONUM_TYPE *b; -FLONUM_TYPE *product; +void +flonum_multip (a, b, product) + const FLONUM_TYPE *a; + const FLONUM_TYPE *b; + FLONUM_TYPE *product; { - int size_of_a; /* 0 origin */ - int size_of_b; /* 0 origin */ - int size_of_product; /* 0 origin */ - int size_of_sum; /* 0 origin */ - int extra_product_positions;/* 1 origin */ - unsigned long work; - unsigned long carry; - long exponent; - LITTLENUM_TYPE * q; - long significant; /* TRUE when we emit a non-0 littlenum */ - /* ForTran accent follows. */ - int P; /* Scan product low-order -> high. */ - int N; /* As in sum above. */ - int A; /* Which [] of a? */ - int B; /* Which [] of b? */ - - if((a->sign!='-' && a->sign!='+') || (b->sign!='-' && b->sign!='+')) { - /* ... + int size_of_a; /* 0 origin */ + int size_of_b; /* 0 origin */ + int size_of_product; /* 0 origin */ + int size_of_sum; /* 0 origin */ + int extra_product_positions; /* 1 origin */ + unsigned long work; + unsigned long carry; + long exponent; + LITTLENUM_TYPE *q; + long significant; /* TRUE when we emit a non-0 littlenum */ + /* ForTran accent follows. */ + int P; /* Scan product low-order -> high. */ + int N; /* As in sum above. */ + int A; /* Which [] of a? */ + int B; /* Which [] of b? */ + + if ((a->sign != '-' && a->sign != '+') || (b->sign != '-' && b->sign != '+')) + { + /* ... Got to fail somehow. Any suggestions? */ - product->sign=0; - return; - } - product -> sign = (a->sign == b->sign) ? '+' : '-'; - size_of_a = a -> leader - a -> low; - size_of_b = b -> leader - b -> low; - exponent = a -> exponent + b -> exponent; - size_of_product = product -> high - product -> low; - size_of_sum = size_of_a + size_of_b; - extra_product_positions = size_of_product - size_of_sum; - if (extra_product_positions < 0) - { - P = extra_product_positions; /* P < 0 */ - exponent -= extra_product_positions; /* Increases exponent. */ - } - else - { - P = 0; - } - carry = 0; - significant = 0; - for (N = 0; - N <= size_of_sum; - N++) + product->sign = 0; + return; + } + product->sign = (a->sign == b->sign) ? '+' : '-'; + size_of_a = a->leader - a->low; + size_of_b = b->leader - b->low; + exponent = a->exponent + b->exponent; + size_of_product = product->high - product->low; + size_of_sum = size_of_a + size_of_b; + extra_product_positions = size_of_product - size_of_sum; + if (extra_product_positions < 0) + { + P = extra_product_positions; /* P < 0 */ + exponent -= extra_product_positions; /* Increases exponent. */ + } + else + { + P = 0; + } + carry = 0; + significant = 0; + for (N = 0; + N <= size_of_sum; + N++) + { + work = carry; + carry = 0; + for (A = 0; + A <= N; + A++) + { + B = N - A; + if (A <= size_of_a && B <= size_of_b && B >= 0) { - work = carry; - carry = 0; - for (A = 0; - A <= N; - A ++) - { - B = N - A; - if (A <= size_of_a && B <= size_of_b && B >= 0) - { #ifdef TRACE - printf("a:low[%d.]=%04x b:low[%d.]=%04x work_before=%08x\n", A, a->low[A], B, b->low[B], work); + printf ("a:low[%d.]=%04x b:low[%d.]=%04x work_before=%08x\n", A, a->low[A], B, b->low[B], work); #endif - work += a -> low [A] * b -> low [B]; - carry += work >> LITTLENUM_NUMBER_OF_BITS; - work &= LITTLENUM_MASK; + work += a->low[A] * b->low[B]; + carry += work >> LITTLENUM_NUMBER_OF_BITS; + work &= LITTLENUM_MASK; #ifdef TRACE - printf("work=%08x carry=%04x\n", work, carry); + printf ("work=%08x carry=%04x\n", work, carry); #endif - } - } - significant |= work; - if (significant || P<0) - { - if (P >= 0) - { - product -> low [P] = work; + } + } + significant |= work; + if (significant || P < 0) + { + if (P >= 0) + { + product->low[P] = work; #ifdef TRACE - printf("P=%d. work[p]:=%04x\n", P, work); + printf ("P=%d. work[p]:=%04x\n", P, work); #endif - } - P ++; - } - else - { - extra_product_positions ++; - exponent ++; - } } - /* + P++; + } + else + { + extra_product_positions++; + exponent++; + } + } + /* * [P]-> position # size_of_sum + 1. * This is where 'carry' should go. */ #ifdef TRACE - printf("final carry =%04x\n", carry); + printf ("final carry =%04x\n", carry); #endif - if (carry) - { - if (extra_product_positions > 0) - { - product -> low [P] = carry; - } - else - { - /* No room at high order for carry littlenum. */ - /* Shift right 1 to make room for most significant littlenum. */ - exponent ++; - P --; - for (q = product -> low + P; - q >= product -> low; - q --) - { - work = * q; - * q = carry; - carry = work; - } - } - } - else + if (carry) + { + if (extra_product_positions > 0) + { + product->low[P] = carry; + } + else + { + /* No room at high order for carry littlenum. */ + /* Shift right 1 to make room for most significant littlenum. */ + exponent++; + P--; + for (q = product->low + P; + q >= product->low; + q--) { - P --; + work = *q; + *q = carry; + carry = work; } - product -> leader = product -> low + P; - product -> exponent = exponent; + } + } + else + { + P--; + } + product->leader = product->low + P; + product->exponent = exponent; } /* end of flonum_mult.c */ diff --git a/gas/flonum.h b/gas/flonum.h index 4cf6614..ee45a6e 100644 --- a/gas/flonum.h +++ b/gas/flonum.h @@ -1,18 +1,19 @@ /* flonum.h - Floating point package - Copyright (C) 1987, 1990, 1991 Free Software Foundation, Inc. - + + Copyright (C) 1987, 1990, 1991, 1992 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. */ @@ -29,8 +30,8 @@ * please tell me your nomenclature for flonums! * * * \***********************************************************************/ -#if !defined(__STDC__) && !defined(const) -#define const /* empty */ +#if (__STDC__ != 1) && !defined(const) +#define const /* empty */ #endif #include "bignum.h" @@ -52,12 +53,12 @@ */ struct FLONUM_STRUCT { - LITTLENUM_TYPE * low; /* low order littlenum of a bignum */ - LITTLENUM_TYPE * high; /* high order littlenum of a bignum */ - LITTLENUM_TYPE * leader; /* -> 1st non-zero littlenum */ - /* If flonum is 0.0, leader==low-1 */ - long exponent; /* base LITTLENUM_RADIX */ - char sign; /* '+' or '-' */ + LITTLENUM_TYPE *low; /* low order littlenum of a bignum */ + LITTLENUM_TYPE *high; /* high order littlenum of a bignum */ + LITTLENUM_TYPE *leader; /* -> 1st non-zero littlenum */ + /* If flonum is 0.0, leader==low-1 */ + long exponent; /* base LITTLENUM_RADIX */ + char sign; /* '+' or '-' */ }; typedef struct FLONUM_STRUCT FLONUM_TYPE; @@ -91,23 +92,23 @@ extern const int table_size_of_flonum_powers_of_ten; * * \***********************************************************************/ -#ifdef __STDC__ +#if __STDC__ == 1 -int atof_generic(char **address_of_string_pointer, - const char *string_of_decimal_marks, - const char *string_of_decimal_exponent_marks, - FLONUM_TYPE *address_of_generic_floating_point_number); +int atof_generic (char **address_of_string_pointer, + const char *string_of_decimal_marks, + const char *string_of_decimal_exponent_marks, + FLONUM_TYPE * address_of_generic_floating_point_number); -void flonum_copy(FLONUM_TYPE *in, FLONUM_TYPE *out); -void flonum_multip(const FLONUM_TYPE *a, const FLONUM_TYPE *b, FLONUM_TYPE *product); +void flonum_copy (FLONUM_TYPE * in, FLONUM_TYPE * out); +void flonum_multip (const FLONUM_TYPE * a, const FLONUM_TYPE * b, FLONUM_TYPE * product); -#else /* __STDC__ */ +#else /* not __STDC__ */ -int atof_generic(); -void flonum_copy(); -void flonum_multip(); +int atof_generic (); +void flonum_copy (); +void flonum_multip (); -#endif /* __STDC__ */ +#endif /* not __STDC__ */ /***********************************************************************\ * * diff --git a/gas/frags.h b/gas/frags.h index 8f2edf1..756734c 100644 --- a/gas/frags.h +++ b/gas/frags.h @@ -1,23 +1,24 @@ /* frags.h - Header file for the frag concept. - Copyright (C) 1987 Free Software Foundation, Inc. - + + Copyright (C) 1987, 1992 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. */ -extern struct obstack frags; +extern struct obstack frags; /* Frags ONLY live in this obstack. */ /* We use obstack_next_free() macro */ /* so please don't put any other objects */ @@ -38,41 +39,41 @@ extern struct obstack frags; } -#ifdef __STDC__ - -char *frag_more(int nchars); -void frag_align(int alignment, int fill_character); -void frag_new(int old_frags_var_max_size); -void frag_wane(fragS *fragP); - -char *frag_variant(relax_stateT type, - int max_chars, - int var, - relax_substateT subtype, - symbolS *symbol, - long offset, - char *opcode, - int pcrel_adjust, - int bsr); - -char *frag_var(relax_stateT type, - int max_chars, - int var, - relax_substateT subtype, - symbolS *symbol, - long offset, - char *opcode); - -#else /* __STDC__ */ - -char *frag_more(); -char *frag_var(); -char *frag_variant(); -void frag_align(); -void frag_new(); -void frag_wane(); - -#endif /* __STDC__ */ +#if __STDC__ == 1 + +char *frag_more (int nchars); +void frag_align (int alignment, int fill_character); +void frag_new (int old_frags_var_max_size); +void frag_wane (fragS * fragP); + +char *frag_variant (relax_stateT type, + int max_chars, + int var, + relax_substateT subtype, + symbolS * symbol, + long offset, + char *opcode, + int pcrel_adjust, + int bsr); + +char *frag_var (relax_stateT type, + int max_chars, + int var, + relax_substateT subtype, + symbolS * symbol, + long offset, + char *opcode); + +#else /* not __STDC__ */ + +char *frag_more (); +char *frag_var (); +char *frag_variant (); +void frag_align (); +void frag_new (); +void frag_wane (); + +#endif /* not __STDC__ */ /* * Local Variables: diff --git a/gas/hex-value.c b/gas/hex-value.c index 01fe241..2c05a83 100644 --- a/gas/hex-value.c +++ b/gas/hex-value.c @@ -1,18 +1,18 @@ /* hex_value.c - char=>radix-value - Copyright (C) 1987, 1990, 1991, 1992 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. */ @@ -26,32 +26,34 @@ /* exceeds any normal radix */ #if (__STDC__ != 1) && !defined(const) -#define const /* empty */ +#define const /* empty */ #endif const char - hex_value [256] = { /* for fast ASCII -> binary */ - __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, - __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, - __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, __, __, __, __, __, __, - __, 10, 11, 12, 13, 14, 15, __, __, __, __, __, __, __, __, __, - __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, - __, 10, 11, 12, 13, 14, 15, __, __, __, __, __, __, __, __, __, - __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, - __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, - __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, - __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, - __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, - __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, - __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, - __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, - __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __ - }; + hex_value[256] = +{ /* for fast ASCII -> binary */ + __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, + __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, + __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, __, __, __, __, __, __, + __, 10, 11, 12, 13, 14, 15, __, __, __, __, __, __, __, __, __, + __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, + __, 10, 11, 12, 13, 14, 15, __, __, __, __, __, __, __, __, __, + __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, + __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, + __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, + __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, + __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, + __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, + __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, + __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, + __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __ +}; #ifdef VMS -dummy2() +dummy2 () { } + #endif /* end of hex_value.c */ diff --git a/gas/input-file.c b/gas/input-file.c index 7c1b51d..ca84f6b 100644 --- a/gas/input-file.c +++ b/gas/input-file.c @@ -1,18 +1,18 @@ /* input_file.c - Deal with Input Files - - Copyright (C) 1987, 1990, 1991 Free Software Foundation, Inc. - + Copyright (C) 1987, 1990, 1991, 1992 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. */ @@ -56,269 +56,298 @@ int preprocess = 0; FILE *f_in; /* static JF remove static so app.c can use file_name */ -char * file_name; +char *file_name; /* Struct for saving the state of this module for file includes. */ -struct saved_file { - FILE *f_in; - char *file_name; - int preprocess; - char *app_save; -}; +struct saved_file + { + FILE *f_in; + char *file_name; + int preprocess; + char *app_save; + }; /* These hooks accomodate most operating systems. */ -void input_file_begin() { - f_in = (FILE *)0; +void +input_file_begin () +{ + f_in = (FILE *) 0; } -void input_file_end () { } +void +input_file_end () +{ +} /* Return BUFFER_SIZE. */ -int input_file_buffer_size() { - return (BUFFER_SIZE); +int +input_file_buffer_size () +{ + return (BUFFER_SIZE); } -int input_file_is_open() { - return f_in!=(FILE *)0; +int +input_file_is_open () +{ + return f_in != (FILE *) 0; } /* Push the state of our input, returning a pointer to saved info that can be restored with input_file_pop (). */ -char *input_file_push () { - register struct saved_file *saved; - - saved = (struct saved_file *)xmalloc (sizeof *saved); - - saved->f_in = f_in; - saved->file_name = file_name; - saved->preprocess = preprocess; - if (preprocess) - saved->app_save = app_push (); - - input_file_begin (); /* Initialize for new file */ - - return (char *)saved; +char * +input_file_push () +{ + register struct saved_file *saved; + + saved = (struct saved_file *) xmalloc (sizeof *saved); + + saved->f_in = f_in; + saved->file_name = file_name; + saved->preprocess = preprocess; + if (preprocess) + saved->app_save = app_push (); + + input_file_begin (); /* Initialize for new file */ + + return (char *) saved; } void - input_file_pop (arg) -char *arg; +input_file_pop (arg) + char *arg; { - register struct saved_file *saved = (struct saved_file *)arg; - - input_file_end (); /* Close out old file */ - - f_in = saved->f_in; - file_name = saved->file_name; - preprocess = saved->preprocess; - if (preprocess) - app_pop (saved->app_save); - - free(arg); + register struct saved_file *saved = (struct saved_file *) arg; + + input_file_end (); /* Close out old file */ + + f_in = saved->f_in; + file_name = saved->file_name; + preprocess = saved->preprocess; + if (preprocess) + app_pop (saved->app_save); + + free (arg); } -#ifdef DONTDEF /* JF save old version in case we need it */ +#ifdef DONTDEF /* JF save old version in case we need it */ void - input_file_open (filename, preprocess, debugging) -char * filename; /* "" means use stdin. Must not be 0. */ -int preprocess; /* TRUE if needs app. */ -int debugging; /* TRUE if we are debugging assembler. */ +input_file_open (filename, preprocess, debugging) + char *filename; /* "" means use stdin. Must not be 0. */ + int preprocess; /* TRUE if needs app. */ + int debugging; /* TRUE if we are debugging assembler. */ { - assert( filename != 0 ); /* Filename may not be NULL. */ - if (filename [0]) - { /* We have a file name. Suck it and see. */ - file_handle = open (filename, O_RDONLY, 0); - file_name = filename; - } - else - { /* use stdin for the input file. */ - file_handle = fileno (stdin); - file_name = "{standard input}"; /* For error messages. */ - } - if (file_handle < 0) - as_perror ("Can't open %s for reading", file_name); - if ( preprocess ) - { - /* + assert (filename != 0); /* Filename may not be NULL. */ + if (filename[0]) + { /* We have a file name. Suck it and see. */ + file_handle = open (filename, O_RDONLY, 0); + file_name = filename; + } + else + { /* use stdin for the input file. */ + file_handle = fileno (stdin); + file_name = "{standard input}"; /* For error messages. */ + } + if (file_handle < 0) + as_perror ("Can't open %s for reading", file_name); + if (preprocess) + { + /* * This code was written in haste for a frobbed BSD 4.2. * I have a flight to catch: will someone please do proper * error checks? - Dean. */ - int pid; - char temporary_file_name [12]; - int fd; - union wait status; - - (void)strcpy (temporary_file_name, "#appXXXXXX"); - (void)mktemp (temporary_file_name); - pid = vfork (); - if (pid == -1) - { - as_perror ("Vfork failed", file_name); - _exit (144); - } - if (pid == 0) - { - (void)dup2 (file_handle, fileno(stdin)); - fd = open (temporary_file_name, O_WRONLY + O_TRUNC + O_CREAT, 0666); - if (fd == -1) - { - (void)write(2,"Can't open temporary\n",21); - _exit (99); - } - (void)dup2 (fd, fileno(stdout)); - /* JF for testing #define PREPROCESSOR "/lib/app" */ -#define PREPROCESSOR "./app" - execl (PREPROCESSOR, PREPROCESSOR, 0); - execl ("app","app",0); - (void)write(2,"Exec of app failed. Get help.\n",31); - (void)unlink(temporary_file_name); - _exit (11); - } - (void)wait (& status); - if (status.w_status & 0xFF00) /* JF was 0xF000, was wrong */ - { - file_handle = -1; - as_bad( "Can't preprocess file \"%s\", status = %xx", file_name, status.w_status ); - } - else - { - file_handle = open (temporary_file_name, O_RDONLY, 0); - if ( ! debugging && unlink(temporary_file_name)) - as_perror ("Can't delete temp file %s", temporary_file_name); - } - if (file_handle == -1) - as_perror ("Can't retrieve temp file %s", temporary_file_name); + int pid; + char temporary_file_name[12]; + int fd; + union wait status; + + (void) strcpy (temporary_file_name, "#appXXXXXX"); + (void) mktemp (temporary_file_name); + pid = vfork (); + if (pid == -1) + { + as_perror ("Vfork failed", file_name); + _exit (144); + } + if (pid == 0) + { + (void) dup2 (file_handle, fileno (stdin)); + fd = open (temporary_file_name, O_WRONLY + O_TRUNC + O_CREAT, 0666); + if (fd == -1) + { + (void) write (2, "Can't open temporary\n", 21); + _exit (99); } + (void) dup2 (fd, fileno (stdout)); + /* JF for testing #define PREPROCESSOR "/lib/app" */ +#define PREPROCESSOR "./app" + execl (PREPROCESSOR, PREPROCESSOR, 0); + execl ("app", "app", 0); + (void) write (2, "Exec of app failed. Get help.\n", 31); + (void) unlink (temporary_file_name); + _exit (11); + } + (void) wait (&status); + if (status.w_status & 0xFF00) /* JF was 0xF000, was wrong */ + { + file_handle = -1; + as_bad ("Can't preprocess file \"%s\", status = %xx", file_name, status.w_status); + } + else + { + file_handle = open (temporary_file_name, O_RDONLY, 0); + if (!debugging && unlink (temporary_file_name)) + as_perror ("Can't delete temp file %s", temporary_file_name); + } + if (file_handle == -1) + as_perror ("Can't retrieve temp file %s", temporary_file_name); + } } + #else void - input_file_open (filename,pre) -char * filename; /* "" means use stdin. Must not be 0. */ -int pre; +input_file_open (filename, pre) + char *filename; /* "" means use stdin. Must not be 0. */ + int pre; { - int c; - char buf[80]; - - preprocess = pre; - - assert( filename != 0 ); /* Filename may not be NULL. */ - if (filename [0]) { /* We have a file name. Suck it and see. */ - f_in=fopen(filename,"r"); - file_name=filename; - } else { /* use stdin for the input file. */ - f_in = stdin; - file_name = "{standard input}"; /* For error messages. */ - } - if (f_in==(FILE *)0) { - as_perror ("Can't open %s for reading", file_name); - return; - } - -#ifndef VMS - /* Ask stdio to buffer our input at BUFFER_SIZE, with a dynamically + int c; + char buf[80]; + + preprocess = pre; + + assert (filename != 0); /* Filename may not be NULL. */ + if (filename[0]) + { /* We have a file name. Suck it and see. */ + f_in = fopen (filename, "r"); + file_name = filename; + } + else + { /* use stdin for the input file. */ + f_in = stdin; + file_name = "{standard input}"; /* For error messages. */ + } + if (f_in == (FILE *) 0) + { + as_perror ("Can't open %s for reading", file_name); + return; + } + +#ifdef _IOFBF + /* Ask stdio to buffer our input at BUFFER_SIZE, with a dynamically allocated buffer. */ - setvbuf(f_in, (char *)NULL, _IOFBF, BUFFER_SIZE); + setvbuf (f_in, (char *) NULL, _IOFBF, BUFFER_SIZE); #endif /* VMS */ - - c = getc(f_in); - if (c == '#') { /* Begins with comment, may not want to preprocess */ - c = getc(f_in); - if (c == 'N') { - fgets(buf,80,f_in); - if (!strcmp(buf,"O_APP\n")) - preprocess=0; - if (!strchr(buf,'\n')) - ungetc('#',f_in); /* It was longer */ - else - ungetc('\n',f_in); - } else if(c=='\n') - ungetc('\n',f_in); - else - ungetc('#',f_in); - } else - ungetc(c,f_in); - + + c = getc (f_in); + if (c == '#') + { /* Begins with comment, may not want to preprocess */ + c = getc (f_in); + if (c == 'N') + { + fgets (buf, 80, f_in); + if (!strcmp (buf, "O_APP\n")) + preprocess = 0; + if (!strchr (buf, '\n')) + ungetc ('#', f_in); /* It was longer */ + else + ungetc ('\n', f_in); + } + else if (c == '\n') + ungetc ('\n', f_in); + else + ungetc ('#', f_in); + } + else + ungetc (c, f_in); + #ifdef DONTDEF - if ( preprocess ) { - char temporary_file_name [17]; - FILE *f_out; - - (void)strcpy (temporary_file_name, "/tmp/#appXXXXXX"); - (void)mktemp (temporary_file_name); - f_out=fopen(temporary_file_name,"w+"); - if(f_out==(FILE *)0) - as_perror("Can't open temp file %s",temporary_file_name); - - /* JF this will have to be moved on any system that + if (preprocess) + { + char temporary_file_name[17]; + FILE *f_out; + + (void) strcpy (temporary_file_name, "/tmp/#appXXXXXX"); + (void) mktemp (temporary_file_name); + f_out = fopen (temporary_file_name, "w+"); + if (f_out == (FILE *) 0) + as_perror ("Can't open temp file %s", temporary_file_name); + + /* JF this will have to be moved on any system that does not support removal of open files. */ - (void)unlink(temporary_file_name);/* JF do it NOW */ - do_scrub(f_in,f_out); - (void)fclose(f_in); /* All done with it */ - (void)rewind(f_out); - f_in=f_out; - } + (void) unlink (temporary_file_name); /* JF do it NOW */ + do_scrub (f_in, f_out); + (void) fclose (f_in); /* All done with it */ + (void) rewind (f_out); + f_in = f_out; + } #endif } + #endif /* Close input file. */ -void input_file_close() { - if (f_in != NULL) { - fclose (f_in); - } /* don't close a null file pointer */ - f_in = 0; -} /* input_file_close() */ +void +input_file_close () +{ + if (f_in != NULL) + { + fclose (f_in); + } /* don't close a null file pointer */ + f_in = 0; +} /* input_file_close() */ char * - input_file_give_next_buffer (where) -char * where; /* Where to place 1st character of new buffer. */ +input_file_give_next_buffer (where) + char *where; /* Where to place 1st character of new buffer. */ { - char * return_value; /* -> Last char of what we read, + 1. */ - register int size; - - if (f_in == (FILE *)0) - return 0; - /* + char *return_value; /* -> Last char of what we read, + 1. */ + register int size; + + if (f_in == (FILE *) 0) + return 0; + /* * fflush (stdin); could be done here if you want to synchronise * stdin and stdout, for the case where our input file is stdin. * Since the assembler shouldn't do any output to stdout, we * don't bother to synch output and input. */ - if(preprocess) { - char *p; - int n; - int ch; - extern FILE *scrub_file; - - scrub_file=f_in; - for (p = where, n = BUFFER_SIZE; n; --n) { - - ch = do_scrub_next_char(scrub_from_file, scrub_to_file); - if (ch == EOF) - break; - *p++=ch; - } - size=BUFFER_SIZE-n; - } else - size= fread(where,sizeof(char),BUFFER_SIZE,f_in); - if (size < 0) - { - as_perror ("Can't read from %s", file_name); - size = 0; - } - if (size) - return_value = where + size; - else - { - if (fclose (f_in)) - as_perror ("Can't close %s", file_name); - f_in = (FILE *)0; - return_value = 0; - } - return (return_value); + if (preprocess) + { + char *p; + int n; + int ch; + extern FILE *scrub_file; + + scrub_file = f_in; + for (p = where, n = BUFFER_SIZE; n; --n) + { + + ch = do_scrub_next_char (scrub_from_file, scrub_to_file); + if (ch == EOF) + break; + *p++ = ch; + } + size = BUFFER_SIZE - n; + } + else + size = fread (where, sizeof (char), BUFFER_SIZE, f_in); + if (size < 0) + { + as_perror ("Can't read from %s", file_name); + size = 0; + } + if (size) + return_value = where + size; + else + { + if (fclose (f_in)) + as_perror ("Can't close %s", file_name); + f_in = (FILE *) 0; + return_value = 0; + } + return (return_value); } /* end of input-file.c */ diff --git a/gas/input-file.h b/gas/input-file.h index 1bc8f05..edd9c54 100644 --- a/gas/input-file.h +++ b/gas/input-file.h @@ -1,18 +1,18 @@ /* input_file.h header for input-file.c - Copyright (C) 1987 Free Software Foundation, Inc. - + Copyright (C) 1987, 1992 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. */ @@ -55,30 +55,30 @@ * about I/O errors. No I/O errors are fatal: an end-of-file may be faked. */ -#ifdef __STDC__ +#if __STDC__ == 1 -char *input_file_give_next_buffer(char *where); -char *input_file_push(void); -int input_file_buffer_size(void); -int input_file_is_open(void); -void input_file_begin(void); -void input_file_close(void); -void input_file_end(void); -void input_file_open(char *filename, int pre); -void input_file_pop(char *arg); +char *input_file_give_next_buffer (char *where); +char *input_file_push (void); +int input_file_buffer_size (void); +int input_file_is_open (void); +void input_file_begin (void); +void input_file_close (void); +void input_file_end (void); +void input_file_open (char *filename, int pre); +void input_file_pop (char *arg); -#else /* __STDC__ */ +#else /* not __STDC__ */ -char *input_file_give_next_buffer(); -char *input_file_push(); -int input_file_buffer_size(); -int input_file_is_open(); -void input_file_begin(); -void input_file_close(); -void input_file_end(); -void input_file_open(); -void input_file_pop(); +char *input_file_give_next_buffer (); +char *input_file_push (); +int input_file_buffer_size (); +int input_file_is_open (); +void input_file_begin (); +void input_file_close (); +void input_file_end (); +void input_file_open (); +void input_file_pop (); -#endif /* __STDC__ */ +#endif /* not __STDC__ */ /* end of input_file.h */ diff --git a/gas/listing.h b/gas/listing.h index e915555..1527c3c 100644 --- a/gas/listing.h +++ b/gas/listing.h @@ -1,18 +1,19 @@ + /* This file is listing.h Copyright (C) 1987-1992 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. */ @@ -36,55 +37,55 @@ #if __STDC__ == 1 -void listing_eject(void); -void listing_error(char *message); -void listing_file(char *name); -void listing_flags(void); -void listing_list(unsigned int on); -void listing_newline(char *ps); -void listing_print(char *name); -void listing_psize(void); -void listing_source_file(char *); -void listing_source_line(unsigned int); -void listing_title(unsigned int depth); -void listing_warning(char *message); -void listing_width(unsigned int x); +void listing_eject (void); +void listing_error (char *message); +void listing_file (char *name); +void listing_flags (void); +void listing_list (unsigned int on); +void listing_newline (char *ps); +void listing_print (char *name); +void listing_psize (void); +void listing_source_file (char *); +void listing_source_line (unsigned int); +void listing_title (unsigned int depth); +void listing_warning (char *message); +void listing_width (unsigned int x); #else /* not __STDC__ */ -void listing_eject(); -void listing_error(); -void listing_file(); -void listing_flags(); -void listing_list(); -void listing_newline(); -void listing_print(); -void listing_psize(); -void listing_source_file(); -void listing_source_line(); -void listing_title(); -void listing_warning(); -void listing_width(); +void listing_eject (); +void listing_error (); +void listing_file (); +void listing_flags (); +void listing_list (); +void listing_newline (); +void listing_print (); +void listing_psize (); +void listing_source_file (); +void listing_source_line (); +void listing_title (); +void listing_warning (); +void listing_width (); #endif /* not __STDC__ */ -#else /* not NO_LISTING */ +#else /* NO_LISTING */ #define LISTING_NEWLINE() {;} /* Dummy functions for when compiled without listing enabled */ -#define listing_flags() {;] -#define listing_list() {;] -#define listing_eject() {;] -#define listing_psize() {;] -#define listing_title(depth) {;] -#define listing_file(name) {;] -#define listing_newline(name) {;] -#define listing_source_line(n) {;] -#define listing_source_file(n) [;] - -#endif /* not NO_LISTING */ +#define listing_flags() {;} +#define listing_list() {;} +#define listing_eject() {;} +#define listing_psize() {;} +#define listing_title(depth) {;} +#define listing_file(name) {;} +#define listing_newline(name) {;} +#define listing_source_line(n) {;} +#define listing_source_file(n) {;} + +#endif /* NO_LISTING */ #endif /* __listing_h__ */ diff --git a/gas/messages.c b/gas/messages.c index f292afd..ef07fc4 100644 --- a/gas/messages.c +++ b/gas/messages.c @@ -1,23 +1,23 @@ /* messages.c - error reporter - Copyright (C) 1987, 1991, 1992 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 <stdio.h> /* define stderr */ +#include <stdio.h> /* define stderr */ #include <errno.h> #include "as.h" @@ -76,10 +76,10 @@ /* ERRORS - + JF: this is now bogus. We now print more standard error messages that try to look like everyone else's. - + We print the error message 1st, beginning in column 1. All ancillary info starts in column 2 on lines after the key error text. @@ -87,31 +87,35 @@ just after the main error text. Caller then prints any appendices after that, begining all lines with at least 1 space. - + Optionally, we may die. There is no need for a trailing '\n' in your error text format because we supply one. - + as_warn(fmt,args) Like fprintf(stderr,fmt,args) but also call errwhere(). - + as_fatal(fmt,args) Like as_warn() but exit with a fatal status. - + */ -static int warning_count; /* Count of number of warnings issued */ +static int warning_count; /* Count of number of warnings issued */ -int had_warnings() { - return(warning_count); -} /* had_err() */ +int +had_warnings () +{ + return (warning_count); +} /* had_err() */ /* Nonzero if we've hit a 'bad error', and should not write an obj file, and exit with a nonzero error code */ static int error_count; -int had_errors() { - return(error_count); -} /* had_errors() */ +int +had_errors () +{ + return (error_count); +} /* had_errors() */ /* @@ -119,64 +123,70 @@ int had_errors() { * * Like perror(3), but with more info. */ -void as_perror(gripe, filename) -char *gripe; /* Unpunctuated error theme. */ -char *filename; +void +as_perror (gripe, filename) + char *gripe; /* Unpunctuated error theme. */ + char *filename; { #ifndef HAVE_STRERROR - extern char *strerror(); + extern char *strerror (); #endif /* HAVE_STRERROR */ - as_where(); - fprintf(stderr, gripe, filename); - fprintf(stderr, ": %s\n", strerror(errno)); - errno = 0; /* After reporting, clear it. */ -} /* as_perror() */ + as_where (); + fprintf (stderr, gripe, filename); + fprintf (stderr, ": %s\n", strerror (errno)); + errno = 0; /* After reporting, clear it. */ +} /* as_perror() */ /* * a s _ t s k t s k () * - * Send to stderr a string (with bell) (JF: Bell is obnoxious!) as a warning, and locate warning + * Send to stderr a string as a warning, and locate warning * in input file(s). * Please only use this for when we have some recovery action. * Please explain in string (which may have '\n's) what recovery was done. */ #ifndef NO_STDARG -void as_tsktsk(const char *Format, ...) +void +as_tsktsk (const char *Format,...) { - va_list args; - - as_where(); - va_start(args, Format); - vfprintf(stderr, Format, args); - va_end(args); - (void) putc('\n', stderr); -} /* as_tsktsk() */ + va_list args; + + as_where (); + va_start (args, Format); + vfprintf (stderr, Format, args); + va_end (args); + (void) putc ('\n', stderr); +} /* as_tsktsk() */ + #else #ifndef NO_VARARGS -void as_tsktsk(Format,va_alist) -char *Format; -va_dcl +void +as_tsktsk (Format, va_alist) + char *Format; + va_dcl { - va_list args; - - as_where(); - va_start(args); - vfprintf(stderr, Format, args); - va_end(args); - (void) putc('\n', stderr); -} /* as_tsktsk() */ + va_list args; + + as_where (); + va_start (args); + vfprintf (stderr, Format, args); + va_end (args); + (void) putc ('\n', stderr); +} /* as_tsktsk() */ + #else /*VARARGS1 */ -as_tsktsk(Format,args) -char *Format; +as_tsktsk (Format, args) + char *Format; { - as_where(); - _doprnt (Format, &args, stderr); - (void)putc ('\n', stderr); - /* as_where(); */ -} /* as_tsktsk */ + as_where (); + _doprnt (Format, &args, stderr); + (void) putc ('\n', stderr); + /* as_where(); */ +} /* as_tsktsk */ + #endif /* not NO_VARARGS */ #endif /* not NO_STDARG */ @@ -190,181 +200,198 @@ char *Format; */ #ifndef NO_STDARG -void as_warn(const char *Format, ...) +void +as_warn (const char *Format,...) { - va_list args; - char buffer[200]; - - if(!flagseen['W']) { - ++warning_count; - as_where(); - va_start(args, Format); - fprintf(stderr,"Warning: "); - vsprintf(buffer, Format, args); - fputs (buffer, stderr); + va_list args; + char buffer[200]; + + if (!flagseen['W']) + { + ++warning_count; + as_where (); + va_start (args, Format); + fprintf (stderr, "Warning: "); + vsprintf (buffer, Format, args); + fputs (buffer, stderr); #ifndef NO_LISTING - listing_warning(buffer); + listing_warning (buffer); #endif - va_end(args); - (void) putc('\n', stderr); - } -} /* as_warn() */ + va_end (args); + (void) putc ('\n', stderr); + } +} /* as_warn() */ + #else #ifndef NO_VARARGS -void as_warn(Format,va_alist) -char *Format; -va_dcl +void +as_warn (Format, va_alist) + char *Format; + va_dcl { - va_list args; - char buffer[200]; - - if(!flagseen['W']) { - ++warning_count; - as_where(); - va_start(args); - fprintf(stderr,"Warning: "); - vsprintf(buffer, Format, args); - fputs (buffer, stderr); + va_list args; + char buffer[200]; + + if (!flagseen['W']) + { + ++warning_count; + as_where (); + va_start (args); + fprintf (stderr, "Warning: "); + vsprintf (buffer, Format, args); + fputs (buffer, stderr); #ifndef NO_LISTING - listing_warning(buffer); -#endif - va_end(args); - (void) putc('\n', stderr); - } -} /* as_warn() */ + listing_warning (buffer); +#endif + va_end (args); + (void) putc ('\n', stderr); + } +} /* as_warn() */ + #else /*VARARGS1 */ -as_warn(Format,args) -char *Format; +as_warn (Format, args) + char *Format; { - /* -W supresses warning messages. */ - if (! flagseen ['W']) { - ++warning_count; - as_where(); - _doprnt (Format, &args, stderr); - (void)putc ('\n', stderr); - /* as_where(); */ - } -} /* as_warn() */ + /* -W supresses warning messages. */ + if (!flagseen['W']) + { + ++warning_count; + as_where (); + _doprnt (Format, &args, stderr); + (void) putc ('\n', stderr); + /* as_where(); */ + } +} /* as_warn() */ + #endif /* not NO_VARARGS */ #endif /* not NO_STDARG */ /* * a s _ b a d () * - * Send to stderr a string (with bell) (JF: Bell is obnoxious!) as a warning, - * and locate warning in input file(s). + * Send to stderr a string as a warning, and locate warning in input file(s). * Please us when there is no recovery, but we want to continue processing * but not produce an object file. * Please explain in string (which may have '\n's) what recovery was done. */ #ifndef NO_STDARG -void as_bad(const char *Format, ...) +void +as_bad (const char *Format,...) { - va_list args; - char buffer[200]; - - ++error_count; - as_where(); - va_start(args, Format); - fprintf(stderr,"Error: "); - - vsprintf(buffer, Format, args); - fputs (buffer,stderr); + va_list args; + char buffer[200]; + + ++error_count; + as_where (); + va_start (args, Format); + fprintf (stderr, "Error: "); + + vsprintf (buffer, Format, args); + fputs (buffer, stderr); #ifndef NO_LISTING - listing_error(buffer); + listing_error (buffer); #endif - va_end(args); - (void) putc('\n', stderr); -} /* as_bad() */ + va_end (args); + (void) putc ('\n', stderr); +} /* as_bad() */ + #else #ifndef NO_VARARGS -void as_bad(Format,va_alist) -char *Format; -va_dcl +void +as_bad (Format, va_alist) + char *Format; + va_dcl { - va_list args; - char buffer[200]; - - ++error_count; - as_where(); - va_start(args); - vsprintf(buffer, Format, args); - fputs (buffer, stderr); + va_list args; + char buffer[200]; + + ++error_count; + as_where (); + va_start (args); + vsprintf (buffer, Format, args); + fputs (buffer, stderr); #ifndef NO_LISTING - listing_error(buffer); + listing_error (buffer); #endif - - va_end(args); - (void) putc('\n', stderr); + + va_end (args); + (void) putc ('\n', stderr); } /* as_bad() */ + #else /*VARARGS1 */ -as_bad(Format,args) -char *Format; +as_bad (Format, args) + char *Format; { - ++error_count; - - as_where(); - fprintf(stderr,"Error: "); - _doprnt (Format, &args, stderr); - (void)putc ('\n', stderr); - /* as_where(); */ -} /* as_bad() */ + ++error_count; + + as_where (); + fprintf (stderr, "Error: "); + _doprnt (Format, &args, stderr); + (void) putc ('\n', stderr); + /* as_where(); */ +} /* as_bad() */ + #endif /* not NO_VARARGS */ #endif /* not NO_STDARG */ /* * a s _ f a t a l () * - * Send to stderr a string (with bell) (JF: Bell is obnoxious!) as a fatal - * message, and locate stdsource in input file(s). + * Send to stderr a string as a fatal message, and print location of error in + * input file(s). * Please only use this for when we DON'T have some recovery action. * It exit()s with a warning status. */ #ifndef NO_STDARG -void as_fatal(const char *Format, ...) +void +as_fatal (const char *Format,...) { - va_list args; - - as_where(); - va_start(args, Format); - fprintf (stderr, "FATAL:"); - vfprintf(stderr, Format, args); - (void) putc('\n', stderr); - va_end(args); - exit(33); -} /* as_fatal() */ + va_list args; + + as_where (); + va_start (args, Format); + fprintf (stderr, "FATAL:"); + vfprintf (stderr, Format, args); + (void) putc ('\n', stderr); + va_end (args); + exit (33); +} /* as_fatal() */ + #else #ifndef NO_VARARGS -void as_fatal(Format,va_alist) -char *Format; -va_dcl +void +as_fatal (Format, va_alist) + char *Format; + va_dcl { - va_list args; - - as_where(); - va_start(args); - fprintf (stderr, "FATAL:"); - vfprintf(stderr, Format, args); - (void) putc('\n', stderr); - va_end(args); - exit(33); -} /* as_fatal() */ + va_list args; + + as_where (); + va_start (args); + fprintf (stderr, "FATAL:"); + vfprintf (stderr, Format, args); + (void) putc ('\n', stderr); + va_end (args); + exit (33); +} /* as_fatal() */ + #else /*VARARGS1 */ -as_fatal(Format, args) -char *Format; +as_fatal (Format, args) + char *Format; { - as_where(); - fprintf(stderr,"FATAL:"); - _doprnt (Format, &args, stderr); - (void)putc ('\n', stderr); - /* as_where(); */ - exit(33); /* What is a good exit status? */ -} /* as_fatal() */ + as_where (); + fprintf (stderr, "FATAL:"); + _doprnt (Format, &args, stderr); + (void) putc ('\n', stderr); + /* as_where(); */ + exit (33); /* What is a good exit status? */ +} /* as_fatal() */ + #endif /* not NO_VARARGS */ #endif /* not NO_STDARG */ @@ -1,65 +1,65 @@ /* obj.h - defines the object dependent hooks for all object format backends. - - Copyright (C) 1987, 1990, 1991 Free Software Foundation, Inc. - + + Copyright (C) 1987, 1990, 1991, 1992 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. */ -#ifdef __STDC__ +#if __STDC__ == 1 -char *obj_default_output_file_name(void); -void obj_crawl_symbol_chain(object_headers *headers); -void obj_emit_relocations(char **where, fixS *fixP, relax_addressT segment_address_in_file); -void obj_emit_strings(char **where); -void obj_emit_symbols(char **where, symbolS *symbol_rootP); -void obj_header_append(char **where, object_headers *headers); -void obj_read_begin_hook(void); +char *obj_default_output_file_name (void); +void obj_crawl_symbol_chain (object_headers * headers); +void obj_emit_relocations (char **where, fixS * fixP, relax_addressT segment_address_in_file); +void obj_emit_strings (char **where); +void obj_emit_symbols (char **where, symbolS * symbol_rootP); +void obj_header_append (char **where, object_headers * headers); +void obj_read_begin_hook (void); #ifndef obj_symbol_new_hook -void obj_symbol_new_hook(symbolS *symbolP); +void obj_symbol_new_hook (symbolS * symbolP); #endif /* obj_symbol_new_hook */ -void obj_symbol_to_chars(char **where, symbolS *symbolP); +void obj_symbol_to_chars (char **where, symbolS * symbolP); #ifndef obj_pre_write_hook -void obj_pre_write_hook(object_headers *headers); +void obj_pre_write_hook (object_headers * headers); #endif /* obj_pre_write_hook */ -#else +#else /* not __STDC__ */ -char *obj_default_output_file_name(); -void obj_crawl_symbol_chain(); -void obj_emit_relocations(); -void obj_emit_strings(); -void obj_emit_symbols(); -void obj_header_append(); -void obj_read_begin_hook(); +char *obj_default_output_file_name (); +void obj_crawl_symbol_chain (); +void obj_emit_relocations (); +void obj_emit_strings (); +void obj_emit_symbols (); +void obj_header_append (); +void obj_read_begin_hook (); #ifndef obj_symbol_new_hook -void obj_symbol_new_hook(); +void obj_symbol_new_hook (); #endif /* obj_symbol_new_hook */ -void obj_symbol_to_chars(); +void obj_symbol_to_chars (); #ifndef obj_pre_write_hook -void obj_pre_write_hook(); +void obj_pre_write_hook (); #endif /* obj_pre_write_hook */ -#endif /* __STDC__ */ +#endif /* not __STDC__ */ extern const pseudo_typeS obj_pseudo_table[]; diff --git a/gas/obstack.c b/gas/obstack.c index 6c0b830..9837b1e 100644 --- a/gas/obstack.c +++ b/gas/obstack.c @@ -24,12 +24,22 @@ Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #endif /* Determine default alignment. */ -struct fooalign {char x; double d;}; +struct fooalign + { + char x; + double d; + }; + #define DEFAULT_ALIGNMENT ((char *)&((struct fooalign *) 0)->d - (char *)0) /* If malloc were really smart, it would round addresses to DEFAULT_ALIGNMENT. But in fact it might be less smart and round addresses to as much as DEFAULT_ROUNDING. So we prepare for it to do that. */ -union fooround {long x; double d;}; +union fooround + { + long x; + double d; + }; + #define DEFAULT_ROUNDING (sizeof (union fooround)) /* When we copy a long block of data, this is the unit to do it with. @@ -55,10 +65,10 @@ _obstack_begin (h, size, alignment, chunkfun, freefun) struct obstack *h; int size; int alignment; - POINTER (*chunkfun) (); +POINTER (*chunkfun) (); void (*freefun) (); { - register struct _obstack_chunk* chunk; /* points to new chunk */ + register struct _obstack_chunk *chunk; /* points to new chunk */ if (alignment == 0) alignment = DEFAULT_ALIGNMENT; @@ -84,7 +94,7 @@ _obstack_begin (h, size, alignment, chunkfun, freefun) h->chunk_size = size; h->alignment_mask = alignment - 1; - chunk = h->chunk = (*h->chunkfun) (h->chunk_size); + chunk = h->chunk = (*h->chunkfun) (h->chunk_size); h->next_free = h->object_base = chunk->contents; h->chunk_limit = chunk->limit = (char *) chunk + h->chunk_size; @@ -104,9 +114,9 @@ _obstack_newchunk (h, length) struct obstack *h; int length; { - register struct _obstack_chunk* old_chunk = h->chunk; - register struct _obstack_chunk* new_chunk; - register long new_size; + register struct _obstack_chunk *old_chunk = h->chunk; + register struct _obstack_chunk *new_chunk; + register long new_size; register int obj_size = h->next_free - h->object_base; register int i; int already; @@ -128,8 +138,8 @@ _obstack_newchunk (h, length) { for (i = obj_size / sizeof (COPYING_UNIT) - 1; i >= 0; i--) - ((COPYING_UNIT *)new_chunk->contents)[i] - = ((COPYING_UNIT *)h->object_base)[i]; + ((COPYING_UNIT *) new_chunk->contents)[i] + = ((COPYING_UNIT *) h->object_base)[i]; /* We used to copy the odd few remaining bytes as one extra COPYING_UNIT, but that can cross a page boundary on a machine which does not do strict alignment for COPYING_UNITS. */ @@ -144,7 +154,7 @@ _obstack_newchunk (h, length) /* If the object just copied was the only data in OLD_CHUNK, free that chunk and remove it from the chain. But not if that chunk might contain an empty object. */ - if (h->object_base == old_chunk->contents && ! h->maybe_empty_object) + if (h->object_base == old_chunk->contents && !h->maybe_empty_object) { new_chunk->prev = old_chunk->prev; (*h->freefun) (old_chunk); @@ -165,14 +175,14 @@ _obstack_allocated_p (h, obj) struct obstack *h; POINTER obj; { - register struct _obstack_chunk* lp; /* below addr of any objects in this chunk */ - register struct _obstack_chunk* plp; /* point to previous chunk if any */ + register struct _obstack_chunk *lp; /* below addr of any objects in this chunk */ + register struct _obstack_chunk *plp; /* point to previous chunk if any */ lp = (h)->chunk; /* We use >= rather than > since the object cannot be exactly at the beginning of the chunk but might be an empty object exactly at the end of an adjacent chunk. */ - while (lp != 0 && ((POINTER)lp >= obj || (POINTER)(lp)->limit < obj)) + while (lp != 0 && ((POINTER) lp >= obj || (POINTER) (lp)->limit < obj)) { plp = lp->prev; lp = plp; @@ -193,14 +203,14 @@ _obstack_free (h, obj) struct obstack *h; POINTER obj; { - register struct _obstack_chunk* lp; /* below addr of any objects in this chunk */ - register struct _obstack_chunk* plp; /* point to previous chunk if any */ + register struct _obstack_chunk *lp; /* below addr of any objects in this chunk */ + register struct _obstack_chunk *plp; /* point to previous chunk if any */ lp = h->chunk; /* We use >= because there cannot be an object at the beginning of a chunk. But there can be an empty object at that address at the end of another chunk. */ - while (lp != 0 && ((POINTER)lp >= obj || (POINTER)(lp)->limit < obj)) + while (lp != 0 && ((POINTER) lp >= obj || (POINTER) (lp)->limit < obj)) { plp = lp->prev; (*h->freefun) (lp); @@ -211,7 +221,7 @@ _obstack_free (h, obj) } if (lp) { - h->object_base = h->next_free = (char *)(obj); + h->object_base = h->next_free = (char *) (obj); h->chunk_limit = lp->limit; h->chunk = lp; } @@ -227,14 +237,14 @@ obstack_free (h, obj) struct obstack *h; POINTER obj; { - register struct _obstack_chunk* lp; /* below addr of any objects in this chunk */ - register struct _obstack_chunk* plp; /* point to previous chunk if any */ + register struct _obstack_chunk *lp; /* below addr of any objects in this chunk */ + register struct _obstack_chunk *plp; /* point to previous chunk if any */ lp = h->chunk; /* We use >= because there cannot be an object at the beginning of a chunk. But there can be an empty object at that address at the end of another chunk. */ - while (lp != 0 && ((POINTER)lp >= obj || (POINTER)(lp)->limit < obj)) + while (lp != 0 && ((POINTER) lp >= obj || (POINTER) (lp)->limit < obj)) { plp = lp->prev; (*h->freefun) (lp); @@ -245,7 +255,7 @@ obstack_free (h, obj) } if (lp) { - h->object_base = h->next_free = (char *)(obj); + h->object_base = h->next_free = (char *) (obj); h->chunk_limit = lp->limit; h->chunk = lp; } diff --git a/gas/obstack.h b/gas/obstack.h index efac356..c6a8e0a 100644 --- a/gas/obstack.h +++ b/gas/obstack.h @@ -117,39 +117,39 @@ Summary: struct _obstack_chunk /* Lives at front of each chunk. */ { - char *limit; /* 1 past end of this chunk */ + char *limit; /* 1 past end of this chunk */ struct _obstack_chunk *prev; /* address of prior chunk or NULL */ - char contents[4]; /* objects begin here */ + char contents[4]; /* objects begin here */ }; -struct obstack /* control current object in current chunk */ +struct obstack /* control current object in current chunk */ { - long chunk_size; /* preferred size to allocate chunks in */ - struct _obstack_chunk* chunk; /* address of current struct obstack_chunk */ - char *object_base; /* address of object we are building */ - char *next_free; /* where to add next char to current object */ - char *chunk_limit; /* address of char after current chunk */ - int temp; /* Temporary for some macros. */ - int alignment_mask; /* Mask of alignment for each object. */ - struct _obstack_chunk *(*chunkfun) (); /* User's fcn to allocate a chunk. */ + long chunk_size; /* preferred size to allocate chunks in */ + struct _obstack_chunk *chunk; /* address of current struct obstack_chunk */ + char *object_base; /* address of object we are building */ + char *next_free; /* where to add next char to current object */ + char *chunk_limit; /* address of char after current chunk */ + int temp; /* Temporary for some macros. */ + int alignment_mask; /* Mask of alignment for each object. */ + struct _obstack_chunk *(*chunkfun) (); /* User's fcn to allocate a chunk. */ void (*freefun) (); /* User's function to free a chunk. */ /* Nonzero means there is a possibility the current chunk contains a zero-length object. This prevents freeing the chunk if we allocate a bigger chunk to replace it. */ - char maybe_empty_object; + char maybe_empty_object; }; /* Declare the external functions we use; they are in obstack.c. */ #ifdef __STDC__ - extern void _obstack_newchunk (struct obstack *, int); - extern void _obstack_free (struct obstack *, void *); - extern void _obstack_begin (struct obstack *, int, int, - void *(*) (), void (*) ()); +extern void _obstack_newchunk (struct obstack *, int); +extern void _obstack_free (struct obstack *, void *); +extern void _obstack_begin (struct obstack *, int, int, + void *(*)(), void (*)()); #else - extern void _obstack_newchunk (); - extern void _obstack_free (); - extern void _obstack_begin (); +extern void _obstack_newchunk (); +extern void _obstack_free (); +extern void _obstack_begin (); #endif #ifdef __STDC__ @@ -159,10 +159,10 @@ struct obstack /* control current object in current chunk */ void obstack_init (struct obstack *obstack); -void * obstack_alloc (struct obstack *obstack, int size); +void *obstack_alloc (struct obstack *obstack, int size); -void * obstack_copy (struct obstack *obstack, void *address, int size); -void * obstack_copy0 (struct obstack *obstack, void *address, int size); +void *obstack_copy (struct obstack *obstack, void *address, int size); +void *obstack_copy0 (struct obstack *obstack, void *address, int size); void obstack_free (struct obstack *obstack, void *block); @@ -175,7 +175,7 @@ void obstack_1grow (struct obstack *obstack, int data_char); void obstack_ptr_grow (struct obstack *obstack, void *data); void obstack_int_grow (struct obstack *obstack, int data); -void * obstack_finish (struct obstack *obstack); +void *obstack_finish (struct obstack *obstack); int obstack_object_size (struct obstack *obstack); @@ -185,8 +185,8 @@ void obstack_ptr_grow_fast (struct obstack *obstack, void *data); void obstack_int_grow_fast (struct obstack *obstack, int data); void obstack_blank_fast (struct obstack *obstack, int size); -void * obstack_base (struct obstack *obstack); -void * obstack_next_free (struct obstack *obstack); +void *obstack_base (struct obstack *obstack); +void *obstack_next_free (struct obstack *obstack); int obstack_alignment_mask (struct obstack *obstack); int obstack_chunk_size (struct obstack *obstack); @@ -282,7 +282,7 @@ __extension__ \ /* These assume that the obstack alignment is good enough for pointers or ints, and that the data added so far to the current object shares that much alignment. */ - + #define obstack_ptr_grow(OBSTACK,datum) \ __extension__ \ ({ struct obstack *__o = (OBSTACK); \ diff --git a/gas/output-file.h b/gas/output-file.h index f5c8073..5182f69 100644 --- a/gas/output-file.h +++ b/gas/output-file.h @@ -1,16 +1,34 @@ +/* This file is output-file.h + Copyright (C) 1987-1992 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. */ #ifdef __STDC__ -void output_file_append(char *where, long length, char *filename); -void output_file_close(char *filename); -void output_file_create(char *name); +void output_file_append (char *where, long length, char *filename); +void output_file_close (char *filename); +void output_file_create (char *name); #else /* __STDC__ */ -void output_file_append(); -void output_file_close(); -void output_file_create(); +void output_file_append (); +void output_file_close (); +void output_file_create (); #endif /* __STDC__ */ @@ -24,14 +24,16 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ */ #define MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT (16) - /* This is the largest known floating point */ - /* format (for now). It will grow when we */ - /* do 4361 style flonums. */ +/* This is the largest known floating point */ +/* format (for now). It will grow when we */ +/* do 4361 style flonums. */ /* Routines that read assembler source text to build spagetti in memory. */ /* Another group of these functions is in the as-expr.c module */ +#include <ctype.h> + #include "as.h" #include "obstack.h" @@ -40,123 +42,123 @@ char *input_line_pointer; /*->next char of source file to parse. */ #if BITS_PER_CHAR != 8 -The following table is indexed by [ (char) ] and will break if -a char does not have exactly 256 states (hopefully 0:255!) ! +/* The following table is indexed by[(char)] and will break if + a char does not have exactly 256 states (hopefully 0:255!)! */ +die horribly; #endif -const char /* used by is_... macros. our ctype[] */ -lex_type [256] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* @ABCDEFGHIJKLMNO */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* PQRSTUVWXYZ[\]^_ */ - 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, /* _!"#$%&'()*+,-./ */ - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, /* 0123456789:;<=>? */ - 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* @ABCDEFGHIJKLMNO */ - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 3, /* PQRSTUVWXYZ[\]^_ */ - 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* `abcdefghijklmno */ - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, /* pqrstuvwxyz{|}~. */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 -}; - - -/* + const char /* used by is_... macros. our ctype[] */ + lex_type[256] = + { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* @ABCDEFGHIJKLMNO */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* PQRSTUVWXYZ[\]^_ */ + 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, /* _!"#$%&'()*+,-./ */ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, /* 0123456789:;<=>? */ + 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* @ABCDEFGHIJKLMNO */ + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 3, /* PQRSTUVWXYZ[\]^_ */ + 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* `abcdefghijklmno */ + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, /* pqrstuvwxyz{|}~. */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + }; + + + /* * In: a character. * Out: 1 if this character ends a line. */ #define _ (0) -char is_end_of_line [256] = { + char is_end_of_line[256] = + { #ifdef CR_EOL - _, _, _, _, _, _, _, _, _, _,99, _, _, 99, _, _,/* @abcdefghijklmno */ + _, _, _, _, _, _, _, _, _, _, 99, _, _, 99, _, _, /* @abcdefghijklmno */ #else - _, _, _, _, _, _, _, _, _, _,99, _, _, _, _, _, /* @abcdefghijklmno */ + _, _, _, _, _, _, _, _, _, _, 99, _, _, _, _, _, /* @abcdefghijklmno */ #endif - _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */ - _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */ - _, _, _, _, _, _, _, _, _, _, _,99, _, _, _, _, /* 0123456789:;<=>? */ - _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */ - _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */ - _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */ - _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */ - _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */ - _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */ - _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */ - _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */ - _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ /* */ -}; + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */ + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */ + _, _, _, _, _, _, _, _, _, _, _, 99, _, _, _, _, /* 0123456789:;<=>? */ + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */ + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */ + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */ + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */ + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */ + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */ + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */ + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */ + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ /* */ + }; #undef _ - /* Functions private to this file. */ + /* Functions private to this file. */ -char line_comment_chars[1]; -char line_separator_chars[1]; + static char *buffer; /* 1st char of each buffer of lines is here. */ + static char *buffer_limit; /*->1 + last char in buffer. */ -static char *buffer; /* 1st char of each buffer of lines is here. */ -static char *buffer_limit; /*->1 + last char in buffer. */ + static char *bignum_low; /* Lowest char of bignum. */ + static char *bignum_limit; /* 1st illegal address of bignum. */ + static char *bignum_high; /* Highest char of bignum. */ + /* May point to (bignum_start-1). */ + /* Never >= bignum_limit. */ + static char *old_buffer = 0; /* JF a hack */ + static char *old_input; + static char *old_limit; -static char *bignum_low; /* Lowest char of bignum. */ -static char *bignum_limit; /* 1st illegal address of bignum. */ -static char *bignum_high; /* Highest char of bignum. */ - /* May point to (bignum_start-1). */ - /* Never >= bignum_limit. */ -static char *old_buffer = 0; /* JF a hack */ -static char *old_input; -static char *old_limit; + /* Variables for handling include file directory list. */ -/* Variables for handling include file directory list. */ - -char **include_dirs; /* List of pointers to directories to + char **include_dirs; /* List of pointers to directories to search for .include's */ -int include_dir_count; /* How many are in the list */ -int include_dir_maxlen = 1; /* Length of longest in list */ + int include_dir_count; /* How many are in the list */ + int include_dir_maxlen = 1;/* Length of longest in list */ #ifndef WORKING_DOT_WORD -struct broken_word *broken_words; -int new_broken_words = 0; + struct broken_word *broken_words; + int new_broken_words = 0; #endif #ifdef __STDC__ -static char *demand_copy_string(int *lenP); -int is_it_end_of_statement(void); -unsigned int next_char_of_string(void); -static segT get_known_segmented_expression(expressionS *expP); -static void grow_bignum(void); -static void pobegin(void); - void stringer(int append_zero); + static char *demand_copy_string (int *lenP); + int is_it_end_of_statement (void); + unsigned int next_char_of_string (void); + static segT get_known_segmented_expression (expressionS * expP); + static void grow_bignum (void); + static void pobegin (void); + void stringer (int append_zero); #else /* __STDC__ */ -static char *demand_copy_string(); -int is_it_end_of_statement(); -unsigned int next_char_of_string(); -static segT get_known_segmented_expression(); -static void grow_bignum(); -static void pobegin(); - void stringer(); + static char *demand_copy_string (); + int is_it_end_of_statement (); + unsigned int next_char_of_string (); + static segT get_known_segmented_expression (); + static void grow_bignum (); + static void pobegin (); + void stringer (); #endif /* __STDC__ */ -extern int listing; - + extern int listing; -void -read_begin() + + void + read_begin () { char *p; - pobegin(); - obj_read_begin_hook(); + pobegin (); + obj_read_begin_hook (); - obstack_begin(¬es, 5000); - obstack_begin(&cond_obstack, 960); + obstack_begin (¬es, 5000); + obstack_begin (&cond_obstack, 960); #define BIGNUM_BEGIN_SIZE (16) - bignum_low = xmalloc((long)BIGNUM_BEGIN_SIZE); + bignum_low = xmalloc ((long) BIGNUM_BEGIN_SIZE); bignum_limit = bignum_low + BIGNUM_BEGIN_SIZE; /* Use machine dependent syntax */ @@ -168,134 +170,148 @@ read_begin() /* set up pseudo-op tables */ struct hash_control * -po_hash = NULL; /* use before set up: NULL->address error */ + po_hash = NULL; /* use before set up: NULL->address error */ #ifdef DONTDEF -void s_gdbline(), s_gdblinetab(); -void s_gdbbeg(), s_gdbblock(), s_gdbend(), s_gdbsym(); +void s_gdbline (), s_gdblinetab (); +void s_gdbbeg (), s_gdbblock (), s_gdbend (), s_gdbsym (); #endif static const pseudo_typeS -potable[] = + potable[] = { - { "abort", s_abort, 0 }, - { "align", s_align_ptwo, 0 }, - { "ascii", stringer, 0 }, - { "asciz", stringer, 1 }, + {"abort", s_abort, 0}, + {"align", s_align_ptwo, 0}, + {"ascii", stringer, 0}, + {"asciz", stringer, 1}, /* block */ - { "byte", cons, 1 }, - { "comm", s_comm, 0 }, - { "data", s_data, 0 }, + {"byte", cons, 1}, + {"comm", s_comm, 0}, + {"data", s_data, 0}, /* dim */ - { "double", float_cons, 'd' }, + {"double", float_cons, 'd'}, /* dsect */ - { "eject", listing_eject, 0 }, /* Formfeed listing */ - { "else", s_else, 0 }, - { "end", s_end, 0 }, - { "endif", s_endif, 0 }, + {"eject", listing_eject, 0}, /* Formfeed listing */ + {"else", s_else, 0}, + {"end", s_end, 0}, + {"endif", s_endif, 0}, /* endef */ - { "equ", s_set, 0 }, + {"equ", s_set, 0}, /* err */ /* extend */ - { "extern", s_ignore, 0 }, /* We treat all undef as ext */ - { "app-file", s_app_file, 0 }, - { "file", s_app_file, 0 }, - { "fill", s_fill, 0 }, - { "float", float_cons, 'f' }, + {"extern", s_ignore, 0}, /* We treat all undef as ext */ + {"app-file", s_app_file, 0}, + {"file", s_app_file, 0}, + {"fill", s_fill, 0}, + {"float", float_cons, 'f'}, #ifdef DONTDEF - { "gdbbeg", s_gdbbeg, 0 }, - { "gdbblock", s_gdbblock, 0 }, - { "gdbend", s_gdbend, 0 }, - { "gdbsym", s_gdbsym, 0 }, - { "gdbline", s_gdbline, 0 }, - { "gdblinetab",s_gdblinetab, 0 }, + {"gdbbeg", s_gdbbeg, 0}, + {"gdbblock", s_gdbblock, 0}, + {"gdbend", s_gdbend, 0}, + {"gdbsym", s_gdbsym, 0}, + {"gdbline", s_gdbline, 0}, + {"gdblinetab", s_gdblinetab, 0}, #endif - { "global", s_globl, 0 }, - { "globl", s_globl, 0 }, - { "hword", cons, 2 }, - { "if", s_if, 0 }, - { "ifdef", s_ifdef, 0 }, - { "ifeqs", s_ifeqs, 0 }, - { "ifndef", s_ifdef, 1 }, - { "ifnes", s_ifeqs, 1 }, - { "ifnotdef", s_ifdef, 1 }, - { "include", s_include, 0 }, - { "int", cons, 4 }, - { "lcomm", s_lcomm, 0 }, - { "lflags", listing_flags, 0 }, /* Listing flags */ - { "list", listing_list, 1 }, /* Turn listing on */ - { "long", cons, 4 }, - { "lsym", s_lsym, 0 }, - { "nolist", listing_list, 0 }, /* Turn listing off */ - { "octa", big_cons, 16 }, - { "org", s_org, 0 }, - { "psize", listing_psize, 0 }, /* set paper size */ + {"global", s_globl, 0}, + {"globl", s_globl, 0}, + {"hword", cons, 2}, + {"if", s_if, 0}, + {"ifdef", s_ifdef, 0}, + {"ifeqs", s_ifeqs, 0}, + {"ifndef", s_ifdef, 1}, + {"ifnes", s_ifeqs, 1}, + {"ifnotdef", s_ifdef, 1}, + {"include", s_include, 0}, + {"int", cons, 4}, + {"lcomm", s_lcomm, 0}, + {"lflags", listing_flags, 0}, /* Listing flags */ + {"list", listing_list, 1}, /* Turn listing on */ + {"long", cons, 4}, + {"lsym", s_lsym, 0}, + {"nolist", listing_list, 0}, /* Turn listing off */ + {"octa", big_cons, 16}, + {"org", s_org, 0}, + {"psize", listing_psize, 0}, /* set paper size */ /* print */ - { "quad", big_cons, 8 }, - { "sbttl", listing_title, 1 }, /* Subtitle of listing */ + {"quad", big_cons, 8}, + {"sbttl", listing_title, 1}, /* Subtitle of listing */ /* scl */ /* sect */ - { "set", s_set, 0 }, - { "short", cons, 2 }, - { "single", float_cons, 'f' }, + {"set", s_set, 0}, + {"short", cons, 2}, + {"single", float_cons, 'f'}, /* size */ - { "space", s_space, 0 }, + {"space", s_space, 0}, /* tag */ - { "text", s_text, 0 }, - { "title", listing_title, 0 }, /* Listing title */ + {"text", s_text, 0}, + {"title", listing_title, 0}, /* Listing title */ /* type */ /* use */ /* val */ - { "word", cons, 2 }, - { NULL} /* end sentinel */ + {"word", cons, 2}, + {NULL} /* end sentinel */ }; -static void pobegin() { - char *errtxt; /* error text */ - const pseudo_typeS * pop; - - po_hash = hash_new(); - - /* Do the target-specific pseudo ops. */ - for (pop = md_pseudo_table; pop->poc_name; pop++) { - errtxt = hash_insert(po_hash, pop->poc_name, (char *)pop); - if (errtxt && *errtxt) { - as_fatal("error constructing md pseudo-op table"); - } /* on error */ - } /* for each op */ - - /* Now object specific. Skip any that were in the target table. */ - for (pop=obj_pseudo_table; pop->poc_name; pop++) { - errtxt = hash_insert (po_hash, pop->poc_name, (char *)pop); - if (errtxt && *errtxt) { - if (!strcmp (errtxt, "exists")) { +static void +pobegin () +{ + char *errtxt; /* error text */ + const pseudo_typeS *pop; + + po_hash = hash_new (); + + /* Do the target-specific pseudo ops. */ + for (pop = md_pseudo_table; pop->poc_name; pop++) + { + errtxt = hash_insert (po_hash, pop->poc_name, (char *) pop); + if (errtxt && *errtxt) + { + as_fatal ("error constructing md pseudo-op table"); + } /* on error */ + } /* for each op */ + + /* Now object specific. Skip any that were in the target table. */ + for (pop = obj_pseudo_table; pop->poc_name; pop++) + { + errtxt = hash_insert (po_hash, pop->poc_name, (char *) pop); + if (errtxt && *errtxt) + { + if (!strcmp (errtxt, "exists")) + { #ifdef DIE_ON_OVERRIDES - as_fatal("pseudo op \".%s\" overridden.\n", pop->poc_name); + as_fatal ("pseudo op \".%s\" overridden.\n", pop->poc_name); #endif /* DIE_ON_OVERRIDES */ - continue; /* OK if target table overrides. */ - } else { - as_fatal("error constructing obj pseudo-op table"); - } /* if overridden */ - } /* on error */ - } /* for each op */ - - /* Now portable ones. Skip any that we've seen already. */ - for (pop=potable; pop->poc_name; pop++) { - errtxt = hash_insert (po_hash, pop->poc_name, (char *)pop); - if (errtxt && *errtxt) { - if (!strcmp (errtxt, "exists")) { + continue; /* OK if target table overrides. */ + } + else + { + as_fatal ("error constructing obj pseudo-op table"); + } /* if overridden */ + } /* on error */ + } /* for each op */ + + /* Now portable ones. Skip any that we've seen already. */ + for (pop = potable; pop->poc_name; pop++) + { + errtxt = hash_insert (po_hash, pop->poc_name, (char *) pop); + if (errtxt && *errtxt) + { + if (!strcmp (errtxt, "exists")) + { #ifdef DIE_ON_OVERRIDES - as_fatal("pseudo op \".%s\" overridden.\n", pop->poc_name); + as_fatal ("pseudo op \".%s\" overridden.\n", pop->poc_name); #endif /* DIE_ON_OVERRIDES */ - continue; /* OK if target table overrides. */ - } else { - as_fatal("error constructing obj pseudo-op table"); - } /* if overridden */ - } /* on error */ - } /* for each op */ - - return; -} /* pobegin() */ + continue; /* OK if target table overrides. */ + } + else + { + as_fatal ("error constructing obj pseudo-op table"); + } /* if overridden */ + } /* on error */ + } /* for each op */ + + return; +} /* pobegin() */ #define HANDLE_CONDITIONAL_ASSEMBLY() \ if (ignore_input ()) \ @@ -312,59 +328,63 @@ static void pobegin() { * We read the file, putting things into a web that * represents what we have been reading. */ -void read_a_source_file(name) -char *name; +void +read_a_source_file (name) + char *name; { register char c; - register char * s; /* string of symbol, '\0' appended */ + register char *s; /* string of symbol, '\0' appended */ register int temp; - /* register struct frag * fragP; JF unused */ /* a frag we just made */ - pseudo_typeS *pop; + /* register struct frag * fragP; JF unused *//* a frag we just made */ + pseudo_typeS *pop; #ifdef DONTDEF - void gdb_block_beg(); - void gdb_block_position(); - void gdb_block_end(); - void gdb_symbols_fixup(); + void gdb_block_beg (); + void gdb_block_position (); + void gdb_block_end (); + void gdb_symbols_fixup (); #endif - buffer = input_scrub_new_file(name); + buffer = input_scrub_new_file (name); - listing_file(name); - listing_newline(""); + listing_file (name); + listing_newline (""); - while ((buffer_limit = input_scrub_next_buffer(&input_line_pointer)) != 0) { /* We have another line to parse. */ - know(buffer_limit[-1] == '\n'); /* Must have a sentinel. */ - contin: /* JF this goto is my fault I admit it. Someone brave please re-write + while ((buffer_limit = input_scrub_next_buffer (&input_line_pointer)) != 0) + { /* We have another line to parse. */ + know (buffer_limit[-1] == '\n'); /* Must have a sentinel. */ + contin: /* JF this goto is my fault I admit it. Someone brave please re-write the whole input section here? Pleeze??? */ - while (input_line_pointer < buffer_limit) { /* We have more of this buffer to parse. */ + while (input_line_pointer < buffer_limit) + { /* We have more of this buffer to parse. */ /* * We now have input_line_pointer->1st char of next line. * If input_line_pointer [-1] == '\n' then we just * scanned another line: so bump line counters. */ - if (input_line_pointer[-1] == '\n') { - bump_line_counters(); + if (input_line_pointer[-1] == '\n') + { + bump_line_counters (); #ifdef MRI /* Text at the start of a line must be a label, we run down and stick a colon in */ - if (is_name_beginner(*input_line_pointer)) - { - char *line_start = input_line_pointer; - char c = get_symbol_end(); - colon(line_start); - *input_line_pointer = c; - if (c == ':') - input_line_pointer++; - - } + if (is_name_beginner (*input_line_pointer)) + { + char *line_start = input_line_pointer; + char c = get_symbol_end (); + colon (line_start); + *input_line_pointer = c; + if (c == ':') + input_line_pointer++; + + } #endif - } /* just passed a newline */ + } /* just passed a newline */ + - /* * We are at the begining of a line, or similar place. * We expect a well-formed assembler statement. @@ -379,20 +399,22 @@ char *name; * (And communicating via (linear) files is silly! * If you must pass stuff, please pass a tree!) */ - if ((c = *input_line_pointer++) == '\t' || c == ' ' || c=='\f' || c == 0) { - c = *input_line_pointer++; - } - know(c != ' '); /* No further leading whitespace. */ - LISTING_NEWLINE(); + if ((c = *input_line_pointer++) == '\t' || c == ' ' || c == '\f' || c == 0) + { + c = *input_line_pointer++; + } + know (c != ' '); /* No further leading whitespace. */ + LISTING_NEWLINE (); /* * C is the 1st significant character. * Input_line_pointer points after that character. */ - if (is_name_beginner(c)) { /* want user-defined label or pseudo/opcode */ - HANDLE_CONDITIONAL_ASSEMBLY(); - + if (is_name_beginner (c)) + { /* want user-defined label or pseudo/opcode */ + HANDLE_CONDITIONAL_ASSEMBLY (); + s = --input_line_pointer; - c = get_symbol_end(); /* name's delimiter */ + c = get_symbol_end (); /* name's delimiter */ /* * C is character after symbol. * That character's place in the input line is now '\0'. @@ -400,735 +422,824 @@ char *name; * [In case of pseudo-op, s->'.'.] * Input_line_pointer->'\0' where c was. */ - if (c == ':') { - colon(s); /* user-defined label */ - * input_line_pointer ++ = ':'; /* Put ':' back for error messages' sake. */ + if (c == ':') + { + colon (s); /* user-defined label */ + *input_line_pointer++ = ':'; /* Put ':' back for error messages' sake. */ /* Input_line_pointer->after ':'. */ - SKIP_WHITESPACE(); + SKIP_WHITESPACE (); + - - } else if (c == '=' || input_line_pointer[1] == '=') { /* JF deal with FOO=BAR */ - equals(s); - demand_empty_rest_of_line(); - } else { /* expect pseudo-op or machine instruction */ + } + else if (c == '=' || input_line_pointer[1] == '=') + { /* JF deal with FOO=BAR */ + equals (s); + demand_empty_rest_of_line (); + } + else + { /* expect pseudo-op or machine instruction */ #ifdef MRI - if(!done_pseudo(s)) - + if (!done_pseudo (s)) + #else - if (*s == '.') { - /* + if (*s == '.') + { + /* * PSEUDO - OP. * * WARNING: c has next char, which may be end-of-line. * We lookup the pseudo-op table with s+1 because we * already know that the pseudo-op begins with a '.'. */ - - pop = (pseudo_typeS *) hash_find(po_hash, s+1); - - /* Print the error msg now, while we still can */ - if (!pop) { - as_bad("Unknown pseudo-op: `%s'",s); - *input_line_pointer = c; - s_ignore(0); - break; - } - - /* Put it back for error messages etc. */ + + pop = (pseudo_typeS *) hash_find (po_hash, s + 1); + + /* Print the error msg now, while we still can */ + if (!pop) + { + as_bad ("Unknown pseudo-op: `%s'", s); *input_line_pointer = c; - /* The following skip of whitespace is compulsory. */ - /* A well shaped space is sometimes all that separates keyword from operands. */ - if (c == ' ' || c == '\t') { - input_line_pointer++; - } /* Skip seperator after keyword. */ - /* + s_ignore (0); + break; + } + + /* Put it back for error messages etc. */ + *input_line_pointer = c; + /* The following skip of whitespace is compulsory. */ + /* A well shaped space is sometimes all that separates keyword from operands. */ + if (c == ' ' || c == '\t') + { + input_line_pointer++; + } /* Skip seperator after keyword. */ + /* * Input_line is restored. * Input_line_pointer->1st non-blank char * after pseudo-operation. */ - if (!pop) { - ignore_rest_of_line(); - break; - } else { - (*pop->poc_handler)(pop->poc_val); - } /* if we have one */ - } else + if (!pop) + { + ignore_rest_of_line (); + break; + } + else + { + (*pop->poc_handler) (pop->poc_val); + } /* if we have one */ + } + else #endif - { /* machine instruction */ - /* WARNING: c has char, which may be end-of-line. */ - /* Also: input_line_pointer->`\0` where c was. */ - * input_line_pointer = c; - while (!is_end_of_line[*input_line_pointer]) { - input_line_pointer++; - } - - c = *input_line_pointer; - *input_line_pointer = '\0'; + { /* machine instruction */ + /* WARNING: c has char, which may be end-of-line. */ + /* Also: input_line_pointer->`\0` where c was. */ + *input_line_pointer = c; + while (!is_end_of_line[*input_line_pointer]) + { + input_line_pointer++; + } - md_assemble(s); /* Assemble 1 instruction. */ + c = *input_line_pointer; + *input_line_pointer = '\0'; - *input_line_pointer++ = c; + md_assemble (s); /* Assemble 1 instruction. */ - /* We resume loop AFTER the end-of-line from this instruction */ - } /* if (*s=='.') */ + *input_line_pointer++ = c; - } /* if c==':' */ + /* We resume loop AFTER the end-of-line from this instruction */ + } /* if (*s=='.') */ + + } /* if c==':' */ continue; - } /* if (is_name_beginner(c) */ - - - if (is_end_of_line [c]) { - continue; - } /* empty statement */ - - -#if defined(LOCAL_LABELS_DOLLAR) || defined(LOCAL_LABELS_FB) - if (isdigit(c)) { /* local label ("4:") */ - char *backup = input_line_pointer; - - HANDLE_CONDITIONAL_ASSEMBLY (); - - temp = c - '0'; - - while (isdigit(*input_line_pointer)) { - temp = (temp * 10) + *input_line_pointer - '0'; - ++input_line_pointer; - } /* read the whole number */ - -#ifdef LOCAL_LABELS_DOLLAR - if (*input_line_pointer == '$' - && *(input_line_pointer + 1) == ':') { - input_line_pointer += 2; + } /* if (is_name_beginner(c) */ - if (dollar_label_defined(temp)) { - as_fatal("label \"%d$\" redefined", temp); - } - define_dollar_label(temp); - colon(dollar_label_name(temp, 0)); + if (is_end_of_line[c]) + { continue; - } + } /* empty statement */ + + +#if defined(LOCAL_LABELS_DOLLAR) || defined(LOCAL_LABELS_FB) + if (isdigit (c)) + { /* local label ("4:") */ + char *backup = input_line_pointer; + + HANDLE_CONDITIONAL_ASSEMBLY (); + + temp = c - '0'; + + while (isdigit (*input_line_pointer)) + { + temp = (temp * 10) + *input_line_pointer - '0'; + ++input_line_pointer; + } /* read the whole number */ + +#ifdef LOCAL_LABELS_DOLLAR + if (*input_line_pointer == '$' + && *(input_line_pointer + 1) == ':') + { + input_line_pointer += 2; + + if (dollar_label_defined (temp)) + { + as_fatal ("label \"%d$\" redefined", temp); + } + + define_dollar_label (temp); + colon (dollar_label_name (temp, 0)); + continue; + } #endif /* LOCAL_LABELS_DOLLAR */ - + #ifdef LOCAL_LABELS_FB - if (*input_line_pointer++ == ':') { - fb_label_instance_inc(temp); - colon(fb_label_name(temp, 0)); - continue; - } + if (*input_line_pointer++ == ':') + { + fb_label_instance_inc (temp); + colon (fb_label_name (temp, 0)); + continue; + } #endif /* LOCAL_LABELS_FB */ - - input_line_pointer = backup; - } /* local label ("4:") */ + + input_line_pointer = backup; + } /* local label ("4:") */ #endif /* LOCAL_LABELS_DOLLAR or LOCAL_LABELS_FB */ - if (c && strchr(line_comment_chars,c)) { /* Its a comment. Better say APP or NO_APP */ + if (c && strchr (line_comment_chars, c)) + { /* Its a comment. Better say APP or NO_APP */ char *ends; char *new_buf; char *new_tmp; int new_length; char *tmp_buf = 0; - extern char *scrub_string,*scrub_last_string; - - bump_line_counters(); - s=input_line_pointer; - if (strncmp(s,"APP\n",4)) - continue; /* We ignore it */ - s+=4; - - ends=strstr(s,"#NO_APP\n"); - - if (!ends) { + extern char *scrub_string, *scrub_last_string; + + bump_line_counters (); + s = input_line_pointer; + if (strncmp (s, "APP\n", 4)) + continue; /* We ignore it */ + s += 4; + + ends = strstr (s, "#NO_APP\n"); + + if (!ends) + { int tmp_len; int num; - + /* The end of the #APP wasn't in this buffer. We keep reading in buffers until we find the #NO_APP that goes with this #APP There is one. The specs guarentee it. . . */ - tmp_len=buffer_limit-s; - tmp_buf=xmalloc(tmp_len); - bcopy(s,tmp_buf,tmp_len); - do { - new_tmp = input_scrub_next_buffer(&buffer); + tmp_len = buffer_limit - s; + tmp_buf = xmalloc (tmp_len); + bcopy (s, tmp_buf, tmp_len); + do + { + new_tmp = input_scrub_next_buffer (&buffer); if (!new_tmp) - break; + break; else - buffer_limit = new_tmp; + buffer_limit = new_tmp; input_line_pointer = buffer; - ends = strstr(buffer,"#NO_APP\n"); + ends = strstr (buffer, "#NO_APP\n"); if (ends) - num=ends-buffer; + num = ends - buffer; else - num=buffer_limit-buffer; - - tmp_buf = xrealloc(tmp_buf, tmp_len + num); - bcopy(buffer,tmp_buf+tmp_len,num); - tmp_len+=num; - } while(!ends); - - input_line_pointer= ends ? ends+8 : NULL; - - s=tmp_buf; - ends=s+tmp_len; - - } else { - input_line_pointer=ends+8; - } - new_buf=xmalloc(100); - new_length=100; - new_tmp=new_buf; - - scrub_string=s; + num = buffer_limit - buffer; + + tmp_buf = xrealloc (tmp_buf, tmp_len + num); + bcopy (buffer, tmp_buf + tmp_len, num); + tmp_len += num; + } + while (!ends); + + input_line_pointer = ends ? ends + 8 : NULL; + + s = tmp_buf; + ends = s + tmp_len; + + } + else + { + input_line_pointer = ends + 8; + } + new_buf = xmalloc (100); + new_length = 100; + new_tmp = new_buf; + + scrub_string = s; scrub_last_string = ends; - for(;;) { + for (;;) + { int ch; - ch = do_scrub_next_char(scrub_from_string, scrub_to_string); - if (ch==EOF) break; - *new_tmp++=ch; - if (new_tmp==new_buf+new_length) { - new_buf=xrealloc(new_buf,new_length+100); - new_tmp=new_buf+new_length; - new_length+=100; + ch = do_scrub_next_char (scrub_from_string, scrub_to_string); + if (ch == EOF) + break; + *new_tmp++ = ch; + if (new_tmp == new_buf + new_length) + { + new_buf = xrealloc (new_buf, new_length + 100); + new_tmp = new_buf + new_length; + new_length += 100; } } if (tmp_buf) - free(tmp_buf); - old_buffer=buffer; - old_input=input_line_pointer; - old_limit=buffer_limit; - buffer=new_buf; - input_line_pointer=new_buf; - buffer_limit=new_tmp; + free (tmp_buf); + old_buffer = buffer; + old_input = input_line_pointer; + old_limit = buffer_limit; + buffer = new_buf; + input_line_pointer = new_buf; + buffer_limit = new_tmp; continue; } - HANDLE_CONDITIONAL_ASSEMBLY(); + HANDLE_CONDITIONAL_ASSEMBLY (); /* as_warn("Junk character %d.",c); Now done by ignore_rest */ input_line_pointer--; /* Report unknown char as ignored. */ - ignore_rest_of_line(); - } /* while (input_line_pointer<buffer_limit) */ - if (old_buffer) { - bump_line_counters(); - if (old_input != 0) { - buffer=old_buffer; - input_line_pointer=old_input; - buffer_limit=old_limit; + ignore_rest_of_line (); + } /* while (input_line_pointer<buffer_limit) */ + if (old_buffer) + { + bump_line_counters (); + if (old_input != 0) + { + buffer = old_buffer; + input_line_pointer = old_input; + buffer_limit = old_limit; old_buffer = 0; goto contin; } } - } /* while (more buffers to scan) */ - input_scrub_close(); /* Close the input file */ + } /* while (more buffers to scan) */ + input_scrub_close (); /* Close the input file */ -} /* read_a_source_file() */ +} /* read_a_source_file() */ -void s_abort() { - as_fatal(".abort detected. Abandoning ship."); -} /* s_abort() */ +void +s_abort () +{ + as_fatal (".abort detected. Abandoning ship."); +} /* s_abort() */ /* For machines where ".align 4" means align to a 4 byte boundary. */ -void s_align_bytes(arg) -int arg; +void +s_align_bytes (arg) + int arg; { - register unsigned int temp; - register long temp_fill; - unsigned int i = 0; - unsigned long max_alignment = 1 << 15; + register unsigned int temp; + register long temp_fill; + unsigned int i = 0; + unsigned long max_alignment = 1 << 15; - if (is_end_of_line[*input_line_pointer]) - temp = arg; /* Default value from pseudo-op table */ - else - temp = get_absolute_expression (); + if (is_end_of_line[*input_line_pointer]) + temp = arg; /* Default value from pseudo-op table */ + else + temp = get_absolute_expression (); - if (temp > max_alignment) { - as_bad("Alignment too large: %d. assumed.", temp = max_alignment); + if (temp > max_alignment) + { + as_bad ("Alignment too large: %d. assumed.", temp = max_alignment); } - /* + /* * For the sparc, `.align (1<<n)' actually means `.align n' * so we have to convert it. */ - if (temp != 0) { - for (i = 0; (temp & 1) == 0; temp >>= 1, ++i) - ; + if (temp != 0) + { + for (i = 0; (temp & 1) == 0; temp >>= 1, ++i) + ; } - if (temp != 1) - as_bad("Alignment not a power of 2"); + if (temp != 1) + as_bad ("Alignment not a power of 2"); - temp = i; - if (*input_line_pointer == ',') { - input_line_pointer ++; - temp_fill = get_absolute_expression (); - } else { - temp_fill = 0; + temp = i; + if (*input_line_pointer == ',') + { + input_line_pointer++; + temp_fill = get_absolute_expression (); } - /* Only make a frag if we HAVE to. . . */ - if (temp && ! need_pass_2) - frag_align(temp, (int)temp_fill); + else + { + temp_fill = 0; + } + /* Only make a frag if we HAVE to. . . */ + if (temp && !need_pass_2) + frag_align (temp, (int) temp_fill); - demand_empty_rest_of_line(); -} /* s_align_bytes() */ + demand_empty_rest_of_line (); +} /* s_align_bytes() */ /* For machines where ".align 4" means align to 2**4 boundary. */ -void s_align_ptwo() { - register int temp; - register long temp_fill; - long max_alignment = 15; - - temp = get_absolute_expression (); - if (temp > max_alignment) - as_bad("Alignment too large: %d. assumed.", temp = max_alignment); - else if (temp < 0) { - as_bad("Alignment negative. 0 assumed."); - temp = 0; - } - if (*input_line_pointer == ',') { - input_line_pointer ++; - temp_fill = get_absolute_expression (); - } else - temp_fill = 0; - /* Only make a frag if we HAVE to. . . */ - if (temp && ! need_pass_2) - frag_align (temp, (int)temp_fill); - - record_alignment(now_seg, temp); - - demand_empty_rest_of_line(); -} /* s_align_ptwo() */ - -void s_comm() { - register char *name; - register char c; - register char *p; - register int temp; - register symbolS * symbolP; - - name = input_line_pointer; - c = get_symbol_end(); - /* just after name is now '\0' */ - p = input_line_pointer; - *p = c; - SKIP_WHITESPACE(); - if (*input_line_pointer != ',') { - as_bad("Expected comma after symbol-name: rest of line ignored."); - ignore_rest_of_line(); - return; - } - input_line_pointer ++; /* skip ',' */ - if ((temp = get_absolute_expression()) < 0) { - as_warn(".COMMon length (%d.) <0! Ignored.", temp); - ignore_rest_of_line(); - return; - } - *p = 0; - symbolP = symbol_find_or_make(name); - *p = c; - if (S_IS_DEFINED(symbolP)) { - as_bad("Ignoring attempt to re-define symbol"); - ignore_rest_of_line(); - return; - } - if (S_GET_VALUE(symbolP)) { - if (S_GET_VALUE(symbolP) != temp) - as_bad("Length of .comm \"%s\" is already %d. Not changed to %d.", - S_GET_NAME(symbolP), - S_GET_VALUE(symbolP), - temp); - } else { - S_SET_VALUE(symbolP, temp); - S_SET_EXTERNAL(symbolP); - } +void +s_align_ptwo () +{ + register int temp; + register long temp_fill; + long max_alignment = 15; + + temp = get_absolute_expression (); + if (temp > max_alignment) + as_bad ("Alignment too large: %d. assumed.", temp = max_alignment); + else if (temp < 0) + { + as_bad ("Alignment negative. 0 assumed."); + temp = 0; + } + if (*input_line_pointer == ',') + { + input_line_pointer++; + temp_fill = get_absolute_expression (); + } + else + temp_fill = 0; + /* Only make a frag if we HAVE to. . . */ + if (temp && !need_pass_2) + frag_align (temp, (int) temp_fill); + + record_alignment (now_seg, temp); + + demand_empty_rest_of_line (); +} /* s_align_ptwo() */ + +void +s_comm () +{ + register char *name; + register char c; + register char *p; + register int temp; + register symbolS *symbolP; + + name = input_line_pointer; + c = get_symbol_end (); + /* just after name is now '\0' */ + p = input_line_pointer; + *p = c; + SKIP_WHITESPACE (); + if (*input_line_pointer != ',') + { + as_bad ("Expected comma after symbol-name: rest of line ignored."); + ignore_rest_of_line (); + return; + } + input_line_pointer++; /* skip ',' */ + if ((temp = get_absolute_expression ()) < 0) + { + as_warn (".COMMon length (%d.) <0! Ignored.", temp); + ignore_rest_of_line (); + return; + } + *p = 0; + symbolP = symbol_find_or_make (name); + *p = c; + if (S_IS_DEFINED (symbolP)) + { + as_bad ("Ignoring attempt to re-define symbol"); + ignore_rest_of_line (); + return; + } + if (S_GET_VALUE (symbolP)) + { + if (S_GET_VALUE (symbolP) != temp) + as_bad ("Length of .comm \"%s\" is already %d. Not changed to %d.", + S_GET_NAME (symbolP), + S_GET_VALUE (symbolP), + temp); + } + else + { + S_SET_VALUE (symbolP, temp); + S_SET_EXTERNAL (symbolP); + } #ifdef VMS - if (!temp) - symbolP->sy_other = const_flag; + if (!temp) + symbolP->sy_other = const_flag; #endif - know(symbolP->sy_frag == &zero_address_frag); - demand_empty_rest_of_line(); -} /* s_comm() */ + know (symbolP->sy_frag == &zero_address_frag); + demand_empty_rest_of_line (); +} /* s_comm() */ void -s_data() +s_data () { - register int temp; + register int temp; - temp = get_absolute_expression (); + temp = get_absolute_expression (); #ifdef MANY_SEGMENTS - subseg_new (SEG_E1, (subsegT)temp); + subseg_new (SEG_E1, (subsegT) temp); #else - subseg_new (SEG_DATA, (subsegT)temp); + subseg_new (SEG_DATA, (subsegT) temp); #endif #ifdef VMS - const_flag = 0; + const_flag = 0; #endif - demand_empty_rest_of_line(); + demand_empty_rest_of_line (); } -void s_app_file() { - register char *s; - int length; +void +s_app_file () +{ + register char *s; + int length; - /* Some assemblers tolerate immediately following '"' */ - if ((s = demand_copy_string(&length)) != 0) { - new_logical_line(s, -1); - demand_empty_rest_of_line(); - } + /* Some assemblers tolerate immediately following '"' */ + if ((s = demand_copy_string (&length)) != 0) + { + new_logical_line (s, -1); + demand_empty_rest_of_line (); + } #ifdef OBJ_COFF - c_dot_file_symbol(s); + c_dot_file_symbol (s); #endif /* OBJ_COFF */ -} /* s_app_file() */ +} /* s_app_file() */ -void s_fill() { - long temp_repeat = 0; - long temp_size = 1 ; - register long temp_fill = 0; - char *p; +void +s_fill () +{ + long temp_repeat = 0; + long temp_size = 1; + register long temp_fill = 0; + char *p; - temp_repeat = get_absolute_expression(); - if (*input_line_pointer == ',') + temp_repeat = get_absolute_expression (); + if (*input_line_pointer == ',') + { + input_line_pointer++; + temp_size = get_absolute_expression (); + if (*input_line_pointer == ',') { input_line_pointer++; - temp_size = get_absolute_expression(); - if (*input_line_pointer == ',') - { - input_line_pointer++; - temp_fill = get_absolute_expression(); - } + temp_fill = get_absolute_expression (); } - /* + } + /* * This is to be compatible with BSD 4.2 AS, not for any rational reason. */ #define BSD_FILL_SIZE_CROCK_8 (8) - if (temp_size > BSD_FILL_SIZE_CROCK_8) { - as_warn(".fill size clamped to %d.", BSD_FILL_SIZE_CROCK_8); - temp_size = BSD_FILL_SIZE_CROCK_8 ; - } if (temp_size < 0) { - as_warn("Size negative: .fill ignored."); - temp_size = 0; - } else if (temp_repeat <= 0) { - as_warn("Repeat < 0, .fill ignored"); - temp_size = 0; - } + if (temp_size > BSD_FILL_SIZE_CROCK_8) + { + as_warn (".fill size clamped to %d.", BSD_FILL_SIZE_CROCK_8); + temp_size = BSD_FILL_SIZE_CROCK_8; + } + if (temp_size < 0) + { + as_warn ("Size negative: .fill ignored."); + temp_size = 0; + } + else if (temp_repeat <= 0) + { + as_warn ("Repeat < 0, .fill ignored"); + temp_size = 0; + } - if (temp_size && !need_pass_2) { - p = frag_var(rs_fill, (int)temp_size, (int)temp_size, (relax_substateT)0, (symbolS *)0, temp_repeat, (char *)0); - bzero (p, (int)temp_size); -/* + if (temp_size && !need_pass_2) + { + p = frag_var (rs_fill, (int) temp_size, (int) temp_size, (relax_substateT) 0, (symbolS *) 0, temp_repeat, (char *) 0); + bzero (p, (int) temp_size); + /* * The magic number BSD_FILL_SIZE_CROCK_4 is from BSD 4.2 VAX flavoured AS. * The following bizzare behaviour is to be compatible with above. * I guess they tried to take up to 8 bytes from a 4-byte expression * and they forgot to sign extend. Un*x Sux. */ #define BSD_FILL_SIZE_CROCK_4 (4) - md_number_to_chars (p, temp_fill, temp_size > BSD_FILL_SIZE_CROCK_4 ? BSD_FILL_SIZE_CROCK_4 : (int)temp_size); -/* + md_number_to_chars (p, temp_fill, temp_size > BSD_FILL_SIZE_CROCK_4 ? BSD_FILL_SIZE_CROCK_4 : (int) temp_size); + /* * Note: .fill (),0 emits no frag (since we are asked to .fill 0 bytes) * but emits no error message because it seems a legal thing to do. * It is a degenerate case of .fill but could be emitted by a compiler. */ - } - demand_empty_rest_of_line(); + } + demand_empty_rest_of_line (); } #ifdef DONTDEF void -s_gdbbeg() +s_gdbbeg () { - register int temp; - - temp = get_absolute_expression (); - if (temp < 0) - as_warn("Block number <0. Ignored."); - else if (flagseen ['G']) - gdb_block_beg ((long) temp, frag_now, (long)(obstack_next_free(& frags) - frag_now->fr_literal)); - demand_empty_rest_of_line (); + register int temp; + + temp = get_absolute_expression (); + if (temp < 0) + as_warn ("Block number <0. Ignored."); + else if (flagseen['G']) + gdb_block_beg ((long) temp, frag_now, (long) (obstack_next_free (&frags) - frag_now->fr_literal)); + demand_empty_rest_of_line (); } void -s_gdbblock() +s_gdbblock () { - register int position; - int temp; - - if (get_absolute_expression_and_terminator (&temp) != ',') { - as_bad("expected comma before position in .gdbblock"); - --input_line_pointer; - ignore_rest_of_line (); - return; - } - position = get_absolute_expression (); - if (flagseen ['G']) - gdb_block_position ((long) temp, (long) position); - demand_empty_rest_of_line (); + register int position; + int temp; + + if (get_absolute_expression_and_terminator (&temp) != ',') + { + as_bad ("expected comma before position in .gdbblock"); + --input_line_pointer; + ignore_rest_of_line (); + return; + } + position = get_absolute_expression (); + if (flagseen['G']) + gdb_block_position ((long) temp, (long) position); + demand_empty_rest_of_line (); } void -s_gdbend() +s_gdbend () { - register int temp; - - temp = get_absolute_expression (); - if (temp < 0) - as_warn("Block number <0. Ignored."); - else if (flagseen ['G']) - gdb_block_end ((long) temp, frag_now, (long)(obstack_next_free(& frags) - frag_now->fr_literal)); - demand_empty_rest_of_line (); + register int temp; + + temp = get_absolute_expression (); + if (temp < 0) + as_warn ("Block number <0. Ignored."); + else if (flagseen['G']) + gdb_block_end ((long) temp, frag_now, (long) (obstack_next_free (&frags) - frag_now->fr_literal)); + demand_empty_rest_of_line (); } void -s_gdbsym() +s_gdbsym () { - register char *name, - *p; - register char c; - register symbolS * symbolP; - register int temp; - - name = input_line_pointer; - c = get_symbol_end(); - p = input_line_pointer; - symbolP = symbol_find_or_make(name); - *p = c; - SKIP_WHITESPACE(); - if (* input_line_pointer != ',') { - as_bad("Expected comma after name"); - ignore_rest_of_line(); - return; - } - input_line_pointer ++; - if ((temp = get_absolute_expression ()) < 0) { - as_bad("Bad GDB symbol file offset (%d.) <0! Ignored.", temp); - ignore_rest_of_line(); - return; - } - if (flagseen ['G']) - gdb_symbols_fixup (symbolP, (long)temp); - demand_empty_rest_of_line (); + register char *name, *p; + register char c; + register symbolS *symbolP; + register int temp; + + name = input_line_pointer; + c = get_symbol_end (); + p = input_line_pointer; + symbolP = symbol_find_or_make (name); + *p = c; + SKIP_WHITESPACE (); + if (*input_line_pointer != ',') + { + as_bad ("Expected comma after name"); + ignore_rest_of_line (); + return; + } + input_line_pointer++; + if ((temp = get_absolute_expression ()) < 0) + { + as_bad ("Bad GDB symbol file offset (%d.) <0! Ignored.", temp); + ignore_rest_of_line (); + return; + } + if (flagseen['G']) + gdb_symbols_fixup (symbolP, (long) temp); + demand_empty_rest_of_line (); } void -s_gdbline() +s_gdbline () { - int file_number, - lineno; + int file_number, lineno; - if (get_absolute_expression_and_terminator(&file_number) != ',') { - as_bad("expected comman after filenum in .gdbline"); - ignore_rest_of_line(); - return; - } - lineno=get_absolute_expression(); - if (flagseen['G']) - gdb_line(file_number,lineno); - demand_empty_rest_of_line(); + if (get_absolute_expression_and_terminator (&file_number) != ',') + { + as_bad ("expected comman after filenum in .gdbline"); + ignore_rest_of_line (); + return; + } + lineno = get_absolute_expression (); + if (flagseen['G']) + gdb_line (file_number, lineno); + demand_empty_rest_of_line (); } void -s_gdblinetab() +s_gdblinetab () { - int file_number, - offset; + int file_number, offset; - if (get_absolute_expression_and_terminator(&file_number) != ',') { - as_bad("expected comma after filenum in .gdblinetab"); - ignore_rest_of_line(); - return; - } - offset=get_absolute_expression(); - if (flagseen['G']) - gdb_line_tab(file_number,offset); - demand_empty_rest_of_line(); + if (get_absolute_expression_and_terminator (&file_number) != ',') + { + as_bad ("expected comma after filenum in .gdblinetab"); + ignore_rest_of_line (); + return; + } + offset = get_absolute_expression (); + if (flagseen['G']) + gdb_line_tab (file_number, offset); + demand_empty_rest_of_line (); } + #endif -void s_globl() { - register char *name; - register int c; - register symbolS * symbolP; - - do { - name = input_line_pointer; - c = get_symbol_end(); - symbolP = symbol_find_or_make(name); - * input_line_pointer = c; - SKIP_WHITESPACE(); - S_SET_EXTERNAL(symbolP); - if (c==',') { - input_line_pointer++; - SKIP_WHITESPACE(); - if (*input_line_pointer=='\n') - c='\n'; - } - } while(c==','); - demand_empty_rest_of_line(); -} /* s_globl() */ +void +s_globl () +{ + register char *name; + register int c; + register symbolS *symbolP; -void s_lcomm(needs_align) -int needs_align; /* 1 if this was a ".bss" directive, which may require + do + { + name = input_line_pointer; + c = get_symbol_end (); + symbolP = symbol_find_or_make (name); + *input_line_pointer = c; + SKIP_WHITESPACE (); + S_SET_EXTERNAL (symbolP); + if (c == ',') + { + input_line_pointer++; + SKIP_WHITESPACE (); + if (*input_line_pointer == '\n') + c = '\n'; + } + } + while (c == ','); + demand_empty_rest_of_line (); +} /* s_globl() */ + +void +s_lcomm (needs_align) + int needs_align; /* 1 if this was a ".bss" directive, which may require * a 3rd argument (alignment). * 0 if it was an ".lcomm" (2 args only) */ { - register char *name; - register char c; - register char *p; - register int temp; - register symbolS * symbolP; - const int max_alignment = 15; - int align = 0; - - name = input_line_pointer; - c = get_symbol_end(); - p = input_line_pointer; - *p = c; - SKIP_WHITESPACE(); - if (*input_line_pointer != ',') { - as_bad("Expected comma after name"); - ignore_rest_of_line(); - return; - } + register char *name; + register char c; + register char *p; + register int temp; + register symbolS *symbolP; + const int max_alignment = 15; + int align = 0; + + name = input_line_pointer; + c = get_symbol_end (); + p = input_line_pointer; + *p = c; + SKIP_WHITESPACE (); + if (*input_line_pointer != ',') + { + as_bad ("Expected comma after name"); + ignore_rest_of_line (); + return; + } - ++input_line_pointer; + ++input_line_pointer; - if (*input_line_pointer == '\n') { - as_bad("Missing size expression"); - return; - } + if (*input_line_pointer == '\n') + { + as_bad ("Missing size expression"); + return; + } - if ((temp = get_absolute_expression ()) < 0) { - as_warn("BSS length (%d.) <0! Ignored.", temp); - ignore_rest_of_line(); - return; - } + if ((temp = get_absolute_expression ()) < 0) + { + as_warn ("BSS length (%d.) <0! Ignored.", temp); + ignore_rest_of_line (); + return; + } - if (needs_align) { - align = 0; - SKIP_WHITESPACE(); - if (*input_line_pointer != ',') { - as_bad("Expected comma after size"); - ignore_rest_of_line(); - return; - } - input_line_pointer++; - SKIP_WHITESPACE(); - if (*input_line_pointer == '\n') { - as_bad("Missing alignment"); - return; - } - align = get_absolute_expression (); - if (align > max_alignment){ - align = max_alignment; - as_warn("Alignment too large: %d. assumed.", align); - } else if (align < 0) { - align = 0; - as_warn("Alignment negative. 0 assumed."); - } + if (needs_align) + { + align = 0; + SKIP_WHITESPACE (); + if (*input_line_pointer != ',') + { + as_bad ("Expected comma after size"); + ignore_rest_of_line (); + return; + } + input_line_pointer++; + SKIP_WHITESPACE (); + if (*input_line_pointer == '\n') + { + as_bad ("Missing alignment"); + return; + } + align = get_absolute_expression (); + if (align > max_alignment) + { + align = max_alignment; + as_warn ("Alignment too large: %d. assumed.", align); + } + else if (align < 0) + { + align = 0; + as_warn ("Alignment negative. 0 assumed."); + } #ifdef MANY_SEGMENTS #define SEG_BSS SEG_E2 - record_alignment(SEG_E2, align); + record_alignment (SEG_E2, align); #else - record_alignment(SEG_BSS, align); + record_alignment (SEG_BSS, align); #endif - } /* if needs align */ + } /* if needs align */ - *p = 0; - symbolP = symbol_find_or_make(name); - *p = c; + *p = 0; + symbolP = symbol_find_or_make (name); + *p = c; - if ( + if ( #if defined(OBJ_AOUT) | defined(OBJ_BOUT) - S_GET_OTHER(symbolP) == 0 && - S_GET_DESC(symbolP) == 0 && + S_GET_OTHER (symbolP) == 0 && + S_GET_DESC (symbolP) == 0 && #endif /* OBJ_AOUT or OBJ_BOUT */ - (((S_GET_SEGMENT(symbolP) == SEG_BSS) && (S_GET_VALUE(symbolP) == local_bss_counter)) - || (!S_IS_DEFINED(symbolP) && S_GET_VALUE(symbolP) == 0))) { - if (needs_align){ - /* Align */ - align = ~ ((~0) << align); /* Convert to a mask */ - local_bss_counter = - (local_bss_counter + align) & (~align); - } + (((S_GET_SEGMENT (symbolP) == SEG_BSS) && (S_GET_VALUE (symbolP) == local_bss_counter)) + || (!S_IS_DEFINED (symbolP) && S_GET_VALUE (symbolP) == 0))) + { + if (needs_align) + { + /* Align */ + align = ~((~0) << align); /* Convert to a mask */ + local_bss_counter = + (local_bss_counter + align) & (~align); + } - S_SET_VALUE(symbolP,local_bss_counter); - S_SET_SEGMENT(symbolP, SEG_BSS); + S_SET_VALUE (symbolP, local_bss_counter); + S_SET_SEGMENT (symbolP, SEG_BSS); #ifdef OBJ_COFF - /* The symbol may already have been created with a preceding + /* The symbol may already have been created with a preceding * ".globl" directive -- be careful not to step on storage * class in that case. Otherwise, set it to static. */ - if (S_GET_STORAGE_CLASS(symbolP) != C_EXT){ - S_SET_STORAGE_CLASS(symbolP, C_STAT); - } -#endif /* OBJ_COFF */ - symbolP->sy_frag = & bss_address_frag; - local_bss_counter += temp; - } else { - as_bad("Ignoring attempt to re-define symbol from %d. to %d.", - S_GET_VALUE(symbolP), local_bss_counter); + if (S_GET_STORAGE_CLASS (symbolP) != C_EXT) + { + S_SET_STORAGE_CLASS (symbolP, C_STAT); } - demand_empty_rest_of_line(); +#endif /* OBJ_COFF */ + symbolP->sy_frag = &bss_address_frag; + local_bss_counter += temp; + } + else + { + as_bad ("Ignoring attempt to re-define symbol from %d. to %d.", + S_GET_VALUE (symbolP), local_bss_counter); + } + demand_empty_rest_of_line (); - return; -} /* s_lcomm() */ + return; +} /* s_lcomm() */ void -s_long() +s_long () { - cons(4); + cons (4); } void -s_int() +s_int () { - cons(4); + cons (4); } -void s_lsym() { - register char *name; - register char c; - register char *p; - register segT segment; - expressionS exp; - register symbolS *symbolP; - - /* we permit ANY defined expression: BSD4.2 demands constants */ - name = input_line_pointer; - c = get_symbol_end(); - p = input_line_pointer; - *p = c; - SKIP_WHITESPACE(); - if (* input_line_pointer != ',') { - *p = 0; - as_bad("Expected comma after name \"%s\"", name); - *p = c; - ignore_rest_of_line(); - return; - } - input_line_pointer ++; - segment = expression(& exp); - if (segment != SEG_ABSOLUTE +void +s_lsym () +{ + register char *name; + register char c; + register char *p; + register segT segment; + expressionS exp; + register symbolS *symbolP; + + /* we permit ANY defined expression: BSD4.2 demands constants */ + name = input_line_pointer; + c = get_symbol_end (); + p = input_line_pointer; + *p = c; + SKIP_WHITESPACE (); + if (*input_line_pointer != ',') + { + *p = 0; + as_bad ("Expected comma after name \"%s\"", name); + *p = c; + ignore_rest_of_line (); + return; + } + input_line_pointer++; + segment = expression (&exp); + if (segment != SEG_ABSOLUTE #ifdef MANY_SEGMENTS - && ! ( segment >= SEG_E0 && segment <= SEG_UNKNOWN) + && !(segment >= SEG_E0 && segment <= SEG_UNKNOWN) #else - && segment != SEG_DATA - && segment != SEG_TEXT - && segment != SEG_BSS + && segment != SEG_DATA + && segment != SEG_TEXT + && segment != SEG_BSS #endif - && segment != SEG_REGISTER) { - as_bad("Bad expression: %s", segment_name(segment)); - ignore_rest_of_line(); - return; - } - *p = 0; - symbolP = symbol_find_or_make(name); + && segment != SEG_REGISTER) + { + as_bad ("Bad expression: %s", segment_name (segment)); + ignore_rest_of_line (); + return; + } + *p = 0; + symbolP = symbol_find_or_make (name); - /* FIXME-SOON I pulled a (&& symbolP->sy_other == 0 + /* FIXME-SOON I pulled a (&& symbolP->sy_other == 0 && symbolP->sy_desc == 0) out of this test because coff doesn't have those fields, and I can't see when they'd ever be tripped. I don't @@ -1136,25 +1247,30 @@ void s_lsym() { have introduced a bug. As recently as 1.37 didn't have this test anyway. xoxorich. */ - if (S_GET_SEGMENT(symbolP) == SEG_UNKNOWN - && S_GET_VALUE(symbolP) == 0) { - /* The name might be an undefined .global symbol; be + if (S_GET_SEGMENT (symbolP) == SEG_UNKNOWN + && S_GET_VALUE (symbolP) == 0) + { + /* The name might be an undefined .global symbol; be sure to keep the "external" bit. */ - S_SET_SEGMENT(symbolP, segment); - S_SET_VALUE(symbolP, (valueT)(exp.X_add_number)); - } else { - as_bad("Symbol %s already defined", name); - } - *p = c; - demand_empty_rest_of_line(); -} /* s_lsym() */ - -void s_org() { - register segT segment; - expressionS exp; - register long temp_fill; - register char *p; -/* + S_SET_SEGMENT (symbolP, segment); + S_SET_VALUE (symbolP, (valueT) (exp.X_add_number)); + } + else + { + as_bad ("Symbol %s already defined", name); + } + *p = c; + demand_empty_rest_of_line (); +} /* s_lsym() */ + +void +s_org () +{ + register segT segment; + expressionS exp; + register long temp_fill; + register char *p; + /* * Don't believe the documentation of BSD 4.2 AS. * There is no such thing as a sub-segment-relative origin. * Any absolute origin is given a warning, then assumed to be segment-relative. @@ -1166,173 +1282,193 @@ void s_org() { * BSD will crash trying to emit -ve numbers of filler bytes in certain * .orgs. We don't crash, but see as-write for that code. */ -/* + /* * Don't make frag if need_pass_2==1. */ - segment = get_known_segmented_expression(&exp); - if (*input_line_pointer == ',') { - input_line_pointer ++; - temp_fill = get_absolute_expression (); - } else - temp_fill = 0; - if (! need_pass_2) { - if (segment != now_seg && segment != SEG_ABSOLUTE) - as_bad("Invalid segment \"%s\". Segment \"%s\" assumed.", - segment_name(segment), segment_name(now_seg)); - p = frag_var (rs_org, 1, 1, (relax_substateT)0, exp . X_add_symbol, - exp . X_add_number, (char *)0); - * p = temp_fill; - } /* if (ok to make frag) */ - demand_empty_rest_of_line(); -} /* s_org() */ - -void s_set() { - register char *name; - register char delim; - register char *end_name; - register symbolS *symbolP; - - /* + segment = get_known_segmented_expression (&exp); + if (*input_line_pointer == ',') + { + input_line_pointer++; + temp_fill = get_absolute_expression (); + } + else + temp_fill = 0; + if (!need_pass_2) + { + if (segment != now_seg && segment != SEG_ABSOLUTE) + as_bad ("Invalid segment \"%s\". Segment \"%s\" assumed.", + segment_name (segment), segment_name (now_seg)); + p = frag_var (rs_org, 1, 1, (relax_substateT) 0, exp.X_add_symbol, + exp.X_add_number, (char *) 0); + *p = temp_fill; + } /* if (ok to make frag) */ + demand_empty_rest_of_line (); +} /* s_org() */ + +void +s_set () +{ + register char *name; + register char delim; + register char *end_name; + register symbolS *symbolP; + + /* * Especial apologies for the random logic: * this just grew, and could be parsed much more simply! * Dean in haste. */ - name = input_line_pointer; - delim = get_symbol_end(); - end_name = input_line_pointer; - *end_name = delim; - SKIP_WHITESPACE(); - - if (*input_line_pointer != ',') { - *end_name = 0; - as_bad("Expected comma after name \"%s\"", name); - *end_name = delim; - ignore_rest_of_line(); - return; - } + name = input_line_pointer; + delim = get_symbol_end (); + end_name = input_line_pointer; + *end_name = delim; + SKIP_WHITESPACE (); - input_line_pointer ++; - *end_name = 0; - - if (name[0]=='.' && name[1]=='\0') { - /* Turn '. = mumble' into a .org mumble */ - register segT segment; - expressionS exp; - register char *ptr; - - segment = get_known_segmented_expression(& exp); - - if (!need_pass_2) { - if (segment != now_seg && segment != SEG_ABSOLUTE) - as_bad("Invalid segment \"%s\". Segment \"%s\" assumed.", - segment_name(segment), - segment_name (now_seg)); - ptr = frag_var(rs_org, 1, 1, (relax_substateT)0, exp.X_add_symbol, - exp.X_add_number, (char *)0); - *ptr= 0; - } /* if (ok to make frag) */ - - *end_name = delim; - return; - } + if (*input_line_pointer != ',') + { + *end_name = 0; + as_bad ("Expected comma after name \"%s\"", name); + *end_name = delim; + ignore_rest_of_line (); + return; + } + + input_line_pointer++; + *end_name = 0; + + if (name[0] == '.' && name[1] == '\0') + { + /* Turn '. = mumble' into a .org mumble */ + register segT segment; + expressionS exp; + register char *ptr; + + segment = get_known_segmented_expression (&exp); - if ((symbolP = symbol_find(name)) == NULL - && (symbolP = md_undefined_symbol(name)) == NULL) { - symbolP = symbol_new(name, - SEG_UNKNOWN, - 0, - &zero_address_frag); + if (!need_pass_2) + { + if (segment != now_seg && segment != SEG_ABSOLUTE) + as_bad ("Invalid segment \"%s\". Segment \"%s\" assumed.", + segment_name (segment), + segment_name (now_seg)); + ptr = frag_var (rs_org, 1, 1, (relax_substateT) 0, exp.X_add_symbol, + exp.X_add_number, (char *) 0); + *ptr = 0; + } /* if (ok to make frag) */ + + *end_name = delim; + return; + } + + if ((symbolP = symbol_find (name)) == NULL + && (symbolP = md_undefined_symbol (name)) == NULL) + { + symbolP = symbol_new (name, + SEG_UNKNOWN, + 0, + &zero_address_frag); #ifdef OBJ_COFF - /* "set" symbols are local unless otherwise specified. */ - SF_SET_LOCAL(symbolP); + /* "set" symbols are local unless otherwise specified. */ + SF_SET_LOCAL (symbolP); #endif /* OBJ_COFF */ - } /* make a new symbol */ + } /* make a new symbol */ - symbol_table_insert(symbolP); + symbol_table_insert (symbolP); - *end_name = delim; - pseudo_set(symbolP); - demand_empty_rest_of_line(); -} /* s_set() */ + *end_name = delim; + pseudo_set (symbolP); + demand_empty_rest_of_line (); +} /* s_set() */ -void s_space(mult) -int mult; +void +s_space (mult) + int mult; { - long temp_repeat; - register long temp_fill; - register char *p; - - /* Just like .fill, but temp_size = 1 */ - if (get_absolute_expression_and_terminator(& temp_repeat) == ',') { - temp_fill = get_absolute_expression (); - } else { - input_line_pointer --; /* Backup over what was not a ','. */ - temp_fill = 0; - } - if(mult) - { - temp_fill *= mult; - } - if (temp_repeat <= 0) { - as_warn("Repeat < 0, .space ignored"); - ignore_rest_of_line(); - return; - } - if (! need_pass_2) { - p = frag_var (rs_fill, 1, 1, (relax_substateT)0, (symbolS *)0, - temp_repeat, (char *)0); - * p = temp_fill; - } - demand_empty_rest_of_line(); -} /* s_space() */ + long temp_repeat; + register long temp_fill; + register char *p; + + /* Just like .fill, but temp_size = 1 */ + if (get_absolute_expression_and_terminator (&temp_repeat) == ',') + { + temp_fill = get_absolute_expression (); + } + else + { + input_line_pointer--; /* Backup over what was not a ','. */ + temp_fill = 0; + } + if (mult) + { + temp_fill *= mult; + } + if (temp_repeat <= 0) + { + as_warn ("Repeat < 0, .space ignored"); + ignore_rest_of_line (); + return; + } + if (!need_pass_2) + { + p = frag_var (rs_fill, 1, 1, (relax_substateT) 0, (symbolS *) 0, + temp_repeat, (char *) 0); + *p = temp_fill; + } + demand_empty_rest_of_line (); +} /* s_space() */ void -s_text() +s_text () { - register int temp; + register int temp; - temp = get_absolute_expression (); + temp = get_absolute_expression (); #ifdef MANY_SEGMENTS - subseg_new (SEG_E0, (subsegT)temp); + subseg_new (SEG_E0, (subsegT) temp); #else - subseg_new (SEG_TEXT, (subsegT)temp); + subseg_new (SEG_TEXT, (subsegT) temp); #endif - demand_empty_rest_of_line(); -} /* s_text() */ - + demand_empty_rest_of_line (); +} /* s_text() */ + /*(JF was static, but can't be if machine dependent pseudo-ops are to use it */ -void demand_empty_rest_of_line() { - SKIP_WHITESPACE(); - if (is_end_of_line [*input_line_pointer]) { - input_line_pointer++; - } else { - ignore_rest_of_line(); - } - /* Return having already swallowed end-of-line. */ -} /* Return pointing just after end-of-line. */ +void +demand_empty_rest_of_line () +{ + SKIP_WHITESPACE (); + if (is_end_of_line[*input_line_pointer]) + { + input_line_pointer++; + } + else + { + ignore_rest_of_line (); + } + /* Return having already swallowed end-of-line. */ +} /* Return pointing just after end-of-line. */ void -ignore_rest_of_line() /* For suspect lines: gives warning. */ +ignore_rest_of_line () /* For suspect lines: gives warning. */ { - if (! is_end_of_line [* input_line_pointer]) + if (!is_end_of_line[*input_line_pointer]) { - if (isprint(*input_line_pointer)) - as_bad("Rest of line ignored. First ignored character is `%c'.", + if (isprint (*input_line_pointer)) + as_bad ("Rest of line ignored. First ignored character is `%c'.", *input_line_pointer); else - as_bad("Rest of line ignored. First ignored character valued 0x%x.", + as_bad ("Rest of line ignored. First ignored character valued 0x%x.", *input_line_pointer); while (input_line_pointer < buffer_limit - && ! is_end_of_line [* input_line_pointer]) + && !is_end_of_line[*input_line_pointer]) { - input_line_pointer ++; + input_line_pointer++; } } - input_line_pointer ++; /* Return pointing just after end-of-line. */ - know(is_end_of_line [input_line_pointer [-1]]); + input_line_pointer++; /* Return pointing just after end-of-line. */ + know (is_end_of_line[input_line_pointer[-1]]); } /* @@ -1348,112 +1484,126 @@ ignore_rest_of_line() /* For suspect lines: gives warning. */ */ void pseudo_set (symbolP) - symbolS * symbolP; + symbolS *symbolP; { - expressionS exp; - register segT segment; + expressionS exp; + register segT segment; #if defined(OBJ_AOUT) | defined(OBJ_BOUT) int ext; #endif /* OBJ_AOUT or OBJ_BOUT */ - know(symbolP); /* NULL pointer is logic error. */ + know (symbolP); /* NULL pointer is logic error. */ #if defined(OBJ_AOUT) | defined(OBJ_BOUT) - ext=S_IS_EXTERNAL(symbolP); + ext = S_IS_EXTERNAL (symbolP); #endif /* OBJ_AOUT or OBJ_BOUT */ - if ((segment = expression(& exp)) == SEG_ABSENT) + if ((segment = expression (&exp)) == SEG_ABSENT) { - as_bad("Missing expression: absolute 0 assumed"); - exp . X_seg = SEG_ABSOLUTE; - exp . X_add_number = 0; + as_bad ("Missing expression: absolute 0 assumed"); + exp.X_seg = SEG_ABSOLUTE; + exp.X_add_number = 0; } switch (segment) { - case SEG_REGISTER: - S_SET_SEGMENT(symbolP, SEG_REGISTER); - S_SET_VALUE(symbolP, exp.X_add_number); - symbolP->sy_frag = & zero_address_frag; + case SEG_REGISTER: + S_SET_SEGMENT (symbolP, SEG_REGISTER); + S_SET_VALUE (symbolP, exp.X_add_number); + symbolP->sy_frag = &zero_address_frag; break; case SEG_BIG: - as_bad("%s number invalid. Absolute 0 assumed.", - exp . X_add_number > 0 ? "Bignum" : "Floating-Point"); - S_SET_SEGMENT(symbolP, SEG_ABSOLUTE); + as_bad ("%s number invalid. Absolute 0 assumed.", + exp.X_add_number > 0 ? "Bignum" : "Floating-Point"); + S_SET_SEGMENT (symbolP, SEG_ABSOLUTE); #if defined(OBJ_AOUT) | defined(OBJ_BOUT) - ext ? S_SET_EXTERNAL(symbolP) : - S_CLEAR_EXTERNAL(symbolP); + ext ? S_SET_EXTERNAL (symbolP) : + S_CLEAR_EXTERNAL (symbolP); #endif /* OBJ_AOUT or OBJ_BOUT */ - S_SET_VALUE(symbolP, 0); - symbolP->sy_frag = & zero_address_frag; + S_SET_VALUE (symbolP, 0); + symbolP->sy_frag = &zero_address_frag; break; case SEG_ABSENT: - as_warn("No expression: Using absolute 0"); - S_SET_SEGMENT(symbolP, SEG_ABSOLUTE); + as_warn ("No expression: Using absolute 0"); + S_SET_SEGMENT (symbolP, SEG_ABSOLUTE); #if defined(OBJ_AOUT) | defined(OBJ_BOUT) - ext ? S_SET_EXTERNAL(symbolP) : - S_CLEAR_EXTERNAL(symbolP); + ext ? S_SET_EXTERNAL (symbolP) : + S_CLEAR_EXTERNAL (symbolP); #endif /* OBJ_AOUT or OBJ_BOUT */ - S_SET_VALUE(symbolP, 0); - symbolP->sy_frag = & zero_address_frag; + S_SET_VALUE (symbolP, 0); + symbolP->sy_frag = &zero_address_frag; break; case SEG_DIFFERENCE: if (exp.X_add_symbol && exp.X_subtract_symbol - && (S_GET_SEGMENT(exp.X_add_symbol) == - S_GET_SEGMENT(exp.X_subtract_symbol))) { - if (exp.X_add_symbol->sy_frag != exp.X_subtract_symbol->sy_frag) { - as_bad("Unknown expression: symbols %s and %s are in different frags.", - S_GET_NAME(exp.X_add_symbol), S_GET_NAME(exp.X_subtract_symbol)); - need_pass_2++; + && (S_GET_SEGMENT (exp.X_add_symbol) == + S_GET_SEGMENT (exp.X_subtract_symbol))) + { + if (exp.X_add_symbol->sy_frag != exp.X_subtract_symbol->sy_frag) + { + as_bad ("Unknown expression: symbols %s and %s are in different frags.", + S_GET_NAME (exp.X_add_symbol), S_GET_NAME (exp.X_subtract_symbol)); + need_pass_2++; + } + exp.X_add_number += S_GET_VALUE (exp.X_add_symbol) - + S_GET_VALUE (exp.X_subtract_symbol); } - exp.X_add_number+=S_GET_VALUE(exp.X_add_symbol) - - S_GET_VALUE(exp.X_subtract_symbol); - } else - as_bad("Complex expression. Absolute segment assumed."); + else + as_bad ("Complex expression. Absolute segment assumed."); case SEG_ABSOLUTE: - S_SET_SEGMENT(symbolP, SEG_ABSOLUTE); + S_SET_SEGMENT (symbolP, SEG_ABSOLUTE); #if defined(OBJ_AOUT) | defined(OBJ_BOUT) - ext ? S_SET_EXTERNAL(symbolP) : - S_CLEAR_EXTERNAL(symbolP); + ext ? S_SET_EXTERNAL (symbolP) : + S_CLEAR_EXTERNAL (symbolP); #endif /* OBJ_AOUT or OBJ_BOUT */ - S_SET_VALUE(symbolP, exp.X_add_number); - symbolP->sy_frag = & zero_address_frag; + S_SET_VALUE (symbolP, exp.X_add_number); + symbolP->sy_frag = &zero_address_frag; break; default: #ifdef MANY_SEGMENTS - S_SET_SEGMENT(symbolP, segment); + S_SET_SEGMENT (symbolP, segment); #else - switch(segment) { - case SEG_DATA: S_SET_SEGMENT(symbolP, SEG_DATA); break; - case SEG_TEXT: S_SET_SEGMENT(symbolP, SEG_TEXT); break; - case SEG_BSS: S_SET_SEGMENT(symbolP, SEG_BSS); break; + switch (segment) + { + case SEG_DATA: + S_SET_SEGMENT (symbolP, SEG_DATA); + break; + case SEG_TEXT: + S_SET_SEGMENT (symbolP, SEG_TEXT); + break; + case SEG_BSS: + S_SET_SEGMENT (symbolP, SEG_BSS); + break; - default: as_fatal("failed sanity check."); - } /* switch on segment */ + default: + as_fatal ("failed sanity check."); + } /* switch on segment */ #endif #if defined(OBJ_AOUT) | defined(OBJ_BOUT) - if (ext) { - S_SET_EXTERNAL(symbolP); - } else { - S_CLEAR_EXTERNAL(symbolP); - } /* if external */ + if (ext) + { + S_SET_EXTERNAL (symbolP); + } + else + { + S_CLEAR_EXTERNAL (symbolP); + } /* if external */ #endif /* OBJ_AOUT or OBJ_BOUT */ - S_SET_VALUE(symbolP, exp.X_add_number + S_GET_VALUE(exp.X_add_symbol)); - symbolP->sy_frag = exp . X_add_symbol->sy_frag; + S_SET_VALUE (symbolP, exp.X_add_number + S_GET_VALUE (exp.X_add_symbol)); + symbolP->sy_frag = exp.X_add_symbol->sy_frag; break; case SEG_PASS1: /* Not an error. Just try another pass. */ - symbolP->sy_forward=exp.X_add_symbol; - as_bad("Unknown expression"); - know(need_pass_2 == 1); + symbolP->sy_forward = exp.X_add_symbol; + as_bad ("Unknown expression"); + know (need_pass_2 == 1); break; case SEG_UNKNOWN: - symbolP->sy_forward=exp.X_add_symbol; + symbolP->sy_forward = exp.X_add_symbol; /* as_warn("unknown symbol"); */ /* need_pass_2 = 1; */ break; @@ -1478,21 +1628,22 @@ pseudo_set (symbolP) * in the case of a long. Not worth the crocks required to fix it. */ - /* worker to do .byte etc statements */ - /* clobbers input_line_pointer, checks */ - /* end-of-line. */ -void cons(nbytes) -register unsigned int nbytes; /* 1=.byte, 2=.word, 4=.long */ +/* worker to do .byte etc statements */ +/* clobbers input_line_pointer, checks */ +/* end-of-line. */ +void +cons (nbytes) + register unsigned int nbytes; /* 1=.byte, 2=.word, 4=.long */ { register char c; - register long mask; /* High-order bits we will left-truncate, */ + register long mask; /* High-order bits we will left-truncate, */ /* but includes sign bit also. */ - register long get; /* what we get */ - register long use; /* get after truncation. */ - register long unmask; /* what bits we will store */ - register char * p; - register segT segment; - expressionS exp; + register long get; /* what we get */ + register long use; /* get after truncation. */ + register long unmask; /* what bits we will store */ + register char *p; + register segT segment; + expressionS exp; /* * Input_line_pointer->1st char after pseudo-op-code and could legally @@ -1501,17 +1652,20 @@ register unsigned int nbytes; /* 1=.byte, 2=.word, 4=.long */ /* JF << of >= number of bits in the object is undefined. In particular SPARC (Sun 4) has problems */ - if (nbytes>=sizeof(long)) { + if (nbytes >= sizeof (long)) + { mask = 0; - } else { - mask = ~0 << (BITS_PER_CHAR * nbytes); /* Don't store these bits. */ - } /* bigger than a long */ + } + else + { + mask = ~0 << (BITS_PER_CHAR * nbytes); /* Don't store these bits. */ + } /* bigger than a long */ - unmask = ~mask; /* Do store these bits. */ + unmask = ~mask; /* Do store these bits. */ #ifdef NEVER "Do this mod if you want every overflow check to assume SIGNED 2's complement data."; - mask = ~ (unmask >> 1); /* Includes sign bit now. */ + mask = ~(unmask >> 1); /* Includes sign bit now. */ #endif /* @@ -1520,69 +1674,73 @@ register unsigned int nbytes; /* 1=.byte, 2=.word, 4=.long */ * trailing blanks. We fake a leading ',' if there is (supposed to * be) a 1st expression, and keep demanding 1 expression for each ','. */ - if (is_it_end_of_statement()) { - c = 0; /* Skip loop. */ - input_line_pointer++; /* Matches end-of-loop 'correction'. */ - } else { - c = ','; - } /* if the end else fake it */ + if (is_it_end_of_statement ()) + { + c = 0; /* Skip loop. */ + input_line_pointer++; /* Matches end-of-loop 'correction'. */ + } + else + { + c = ','; + } /* if the end else fake it */ /* Do loop. */ - while (c == ',') { + while (c == ',') + { #ifdef WANT_BITFIELDS unsigned int bits_available = BITS_PER_CHAR * nbytes; /* used for error messages and rescanning */ char *hold = input_line_pointer; #endif /* WANT_BITFIELDS */ #ifdef MRI - if (*input_line_pointer == '\'') - { - /* An MRI style string, cut into as many bytes as will fit + if (*input_line_pointer == '\'') + { + /* An MRI style string, cut into as many bytes as will fit into a nbyte chunk, left justify if necessary, and sepatate with commas so we can try again later */ - int scan = 0; - unsigned int result = 0; - input_line_pointer++; - for (scan = 0; scan < nbytes; scan++) - { - if (*input_line_pointer == '\'') - { - if (input_line_pointer[1] == '\'') + int scan = 0; + unsigned int result = 0; + input_line_pointer++; + for (scan = 0; scan < nbytes; scan++) { - input_line_pointer++; + if (*input_line_pointer == '\'') + { + if (input_line_pointer[1] == '\'') + { + input_line_pointer++; + } + else + break; + } + result = (result << 8) | (*input_line_pointer++); } - else - break; - } - result = (result << 8) | (*input_line_pointer++); - } - - /* Left justify */ - while (scan < nbytes) - { - result <<=8; - scan++; - } - /* Create correct expression */ - exp.X_add_symbol = 0; - exp.X_add_number = result; - exp.X_seg = segment = SEG_ABSOLUTE; - /* Fake it so that we can read the next char too */ - if (input_line_pointer[0] != '\'' || - (input_line_pointer[0] == '\'' && input_line_pointer[1] == '\'')) - { - input_line_pointer-=2; - input_line_pointer[0] = ','; - input_line_pointer[1] = '\''; + + /* Left justify */ + while (scan < nbytes) + { + result <<= 8; + scan++; + } + /* Create correct expression */ + exp.X_add_symbol = 0; + exp.X_add_number = result; + exp.X_seg = segment = SEG_ABSOLUTE; + /* Fake it so that we can read the next char too */ + if (input_line_pointer[0] != '\'' || + (input_line_pointer[0] == '\'' && input_line_pointer[1] == '\'')) + { + input_line_pointer -= 2; + input_line_pointer[0] = ','; + input_line_pointer[1] = '\''; + } + else + input_line_pointer++; + } - else - input_line_pointer++; - - } - else + else #endif - /* At least scan over the expression. */ - segment = expression(&exp); + /* At least scan over the expression. */ + segment = expression (&exp); #ifdef WANT_BITFIELDS /* Some other assemblers, (eg, asm960), allow @@ -1592,28 +1750,31 @@ register unsigned int nbytes; /* 1=.byte, 2=.word, 4=.long */ better in that we allow them in words, longs, etc. and we'll pack them in target byte order for you. - + The rules are: pack least significat bit first, if a field doesn't entirely fit, put it in the next unit. Overflowing the bitfield is explicitly *not* even a warning. The bitwidth should be considered a "mask". - + FIXME-SOMEDAY: If this is considered generally useful, this logic should probably be reworked. xoxorich. */ - if (*input_line_pointer == ':') { /* bitfields */ + if (*input_line_pointer == ':') + { /* bitfields */ long value = 0; - for (;;) { + for (;;) + { unsigned long width; - - if (*input_line_pointer != ':') { + + if (*input_line_pointer != ':') + { input_line_pointer = hold; break; - } /* next piece is not a bitfield */ - + } /* next piece is not a bitfield */ + /* In the general case, we can't allow full expressions with symbol differences and such. The relocation @@ -1622,7 +1783,7 @@ register unsigned int nbytes; /* 1=.byte, 2=.word, 4=.long */ widths, positions, and masks which most of our current object formats don't support. - + In the specific case where a symbol *is* defined in this assembly, we *could* build fixups and track it, but @@ -1631,115 +1792,125 @@ register unsigned int nbytes; /* 1=.byte, 2=.word, 4=.long */ SEG_ABSOLUTE. I think that means that you can use a previous .set or .equ type symbol. xoxorich. */ - - if (segment == SEG_ABSENT) { - as_warn("Using a bit field width of zero."); + + if (segment == SEG_ABSENT) + { + as_warn ("Using a bit field width of zero."); exp.X_add_number = 0; segment = SEG_ABSOLUTE; - } /* implied zero width bitfield */ - - if (segment != SEG_ABSOLUTE) { + } /* implied zero width bitfield */ + + if (segment != SEG_ABSOLUTE) + { *input_line_pointer = '\0'; - as_bad("Field width \"%s\" too complex for a bitfield.\n", hold); + as_bad ("Field width \"%s\" too complex for a bitfield.\n", hold); *input_line_pointer = ':'; - demand_empty_rest_of_line(); + demand_empty_rest_of_line (); return; - } /* too complex */ - - if ((width = exp.X_add_number) > (BITS_PER_CHAR * nbytes)) { - as_warn("Field width %d too big to fit in %d bytes: truncated to %d bits.", - width, nbytes, (BITS_PER_CHAR * nbytes)); + } /* too complex */ + + if ((width = exp.X_add_number) > (BITS_PER_CHAR * nbytes)) + { + as_warn ("Field width %d too big to fit in %d bytes: truncated to %d bits.", + width, nbytes, (BITS_PER_CHAR * nbytes)); width = BITS_PER_CHAR * nbytes; - } /* too big */ - - if (width > bits_available) { + } /* too big */ + + if (width > bits_available) + { /* FIXME-SOMEDAY: backing up and reparsing is wasteful */ input_line_pointer = hold; exp.X_add_number = value; break; - } /* won't fit */ - - hold = ++input_line_pointer; /* skip ':' */ - - if ((segment = expression(&exp)) != SEG_ABSOLUTE) { + } /* won't fit */ + + hold = ++input_line_pointer; /* skip ':' */ + + if ((segment = expression (&exp)) != SEG_ABSOLUTE) + { char cache = *input_line_pointer; - + *input_line_pointer = '\0'; - as_bad("Field value \"%s\" too complex for a bitfield.\n", hold); + as_bad ("Field value \"%s\" too complex for a bitfield.\n", hold); *input_line_pointer = cache; - demand_empty_rest_of_line(); + demand_empty_rest_of_line (); return; - } /* too complex */ - + } /* too complex */ + value |= (~(-1 << width) & exp.X_add_number) - << ((BITS_PER_CHAR * nbytes) - bits_available); - + << ((BITS_PER_CHAR * nbytes) - bits_available); + if ((bits_available -= width) == 0 - || is_it_end_of_statement() - || *input_line_pointer != ',') { + || is_it_end_of_statement () + || *input_line_pointer != ',') + { break; - } /* all the bitfields we're gonna get */ + } /* all the bitfields we're gonna get */ hold = ++input_line_pointer; - segment = expression(&exp); - } /* forever loop */ + segment = expression (&exp); + } /* forever loop */ exp.X_add_number = value; segment = SEG_ABSOLUTE; - } /* if looks like a bitfield */ + } /* if looks like a bitfield */ #endif /* WANT_BITFIELDS */ - if (!need_pass_2) { /* Still worthwhile making frags. */ + if (!need_pass_2) + { /* Still worthwhile making frags. */ /* Don't call this if we are going to junk this pass anyway! */ - know(segment != SEG_PASS1); + know (segment != SEG_PASS1); - if (segment == SEG_DIFFERENCE && exp.X_add_symbol == NULL) { - as_bad("Subtracting symbol \"%s\"(segment\"%s\") is too hard. Absolute segment assumed.", - S_GET_NAME(exp.X_subtract_symbol), - segment_name(S_GET_SEGMENT(exp.X_subtract_symbol))); + if (segment == SEG_DIFFERENCE && exp.X_add_symbol == NULL) + { + as_bad ("Subtracting symbol \"%s\"(segment\"%s\") is too hard. Absolute segment assumed.", + S_GET_NAME (exp.X_subtract_symbol), + segment_name (S_GET_SEGMENT (exp.X_subtract_symbol))); segment = SEG_ABSOLUTE; /* Leave exp . X_add_number alone. */ } - p = frag_more(nbytes); - switch (segment) { + p = frag_more (nbytes); + switch (segment) + { case SEG_BIG: - as_bad("%s number invalid. Absolute 0 assumed.", - exp . X_add_number > 0 ? "Bignum" : "Floating-Point"); - md_number_to_chars (p, (long)0, nbytes); + as_bad ("%s number invalid. Absolute 0 assumed.", + exp.X_add_number > 0 ? "Bignum" : "Floating-Point"); + md_number_to_chars (p, (long) 0, nbytes); break; case SEG_ABSENT: - as_warn("0 assumed for missing expression"); - exp . X_add_number = 0; - know(exp . X_add_symbol == NULL); + as_warn ("0 assumed for missing expression"); + exp.X_add_number = 0; + know (exp.X_add_symbol == NULL); /* fall into SEG_ABSOLUTE */ case SEG_ABSOLUTE: - get = exp . X_add_number; + get = exp.X_add_number; use = get & unmask; if ((get & mask) && (get & mask) != mask) - { /* Leading bits contain both 0s & 1s. */ - as_warn("Value 0x%x truncated to 0x%x.", get, use); - } - md_number_to_chars (p, use, nbytes); /* put bytes in right order. */ + { /* Leading bits contain both 0s & 1s. */ + as_warn ("Value 0x%x truncated to 0x%x.", get, use); + } + md_number_to_chars (p, use, nbytes); /* put bytes in right order. */ break; case SEG_DIFFERENCE: #ifndef WORKING_DOT_WORD - if (nbytes==2) { + if (nbytes == 2) + { struct broken_word *x; - x=(struct broken_word *)xmalloc(sizeof(struct broken_word)); - x->next_broken_word=broken_words; - broken_words=x; - x->frag=frag_now; - x->word_goes_here=p; - x->dispfrag=0; - x->add=exp.X_add_symbol; - x->sub=exp.X_subtract_symbol; - x->addnum=exp.X_add_number; - x->added=0; + x = (struct broken_word *) xmalloc (sizeof (struct broken_word)); + x->next_broken_word = broken_words; + broken_words = x; + x->frag = frag_now; + x->word_goes_here = p; + x->dispfrag = 0; + x->add = exp.X_add_symbol; + x->sub = exp.X_subtract_symbol; + x->addnum = exp.X_add_number; + x->added = 0; new_broken_words++; break; } @@ -1749,35 +1920,40 @@ register unsigned int nbytes; /* 1=.byte, 2=.word, 4=.long */ case SEG_UNKNOWN: #ifdef TC_NS32K fix_new_ns32k (frag_now, p - frag_now->fr_literal, nbytes, - exp . X_add_symbol, exp . X_subtract_symbol, - exp . X_add_number, 0, 0, 2, 0, 0); + exp.X_add_symbol, exp.X_subtract_symbol, + exp.X_add_number, 0, 0, 2, 0, 0); #else # if defined(TC_SPARC) || defined(TC_A29K) fix_new (frag_now, p - frag_now->fr_literal, nbytes, - exp . X_add_symbol, exp . X_subtract_symbol, - exp . X_add_number, 0, RELOC_32); + exp.X_add_symbol, exp.X_subtract_symbol, + exp.X_add_number, 0, RELOC_32); # else # if defined(TC_H8300) fix_new (frag_now, p - frag_now->fr_literal, nbytes, - exp . X_add_symbol, exp . X_subtract_symbol, - exp . X_add_number, 0, R_RELWORD); + exp.X_add_symbol, exp.X_subtract_symbol, + exp.X_add_number, 0, R_RELWORD); # else +#ifdef NO_RELOC fix_new (frag_now, p - frag_now->fr_literal, nbytes, - exp . X_add_symbol, exp . X_subtract_symbol, - exp . X_add_number, 0, 0); - -# endif /* tc_h8300 */ -# endif /* tc_sparc|tc_a29k */ + exp.X_add_symbol, exp.X_subtract_symbol, + exp.X_add_number, 0, NO_RELOC); +#else + fix_new (frag_now, p - frag_now->fr_literal, nbytes, + exp.X_add_symbol, exp.X_subtract_symbol, + exp.X_add_number, 0, 0); +#endif /* NO_RELOC */ +# endif /* tc_h8300 */ +# endif /* tc_sparc|tc_a29k */ #endif /* TC_NS32K */ break; - } /* switch(segment) */ - } /* if (!need_pass_2) */ + } /* switch(segment) */ + } /* if (!need_pass_2) */ c = *input_line_pointer++; - } /* while(c==',') */ - input_line_pointer--; /* Put terminator back into stream. */ - demand_empty_rest_of_line(); -} /* cons() */ + } /* while(c==',') */ + input_line_pointer--; /* Put terminator back into stream. */ + demand_empty_rest_of_line (); +} /* cons() */ /* * big_cons() @@ -1804,16 +1980,17 @@ register unsigned int nbytes; /* 1=.byte, 2=.word, 4=.long */ /* end-of-line. */ /* 8=.quad 16=.octa ... */ -void big_cons(nbytes) +void +big_cons (nbytes) register int nbytes; { - register char c; /* input_line_pointer->c. */ + register char c; /* input_line_pointer->c. */ register int radix; - register long length; /* Number of chars in an object. */ - register int digit; /* Value of 1 digit. */ - register int carry; /* For multi-precision arithmetic. */ - register int work; /* For multi-precision arithmetic. */ - register char * p; /* For multi-precision arithmetic. */ + register long length; /* Number of chars in an object. */ + register int digit; /* Value of 1 digit. */ + register int carry; /* For multi-precision arithmetic. */ + register int work; /* For multi-precision arithmetic. */ + register char *p; /* For multi-precision arithmetic. */ extern char hex_value[]; /* In hex_value.c. */ @@ -1823,27 +2000,27 @@ void big_cons(nbytes) * trailing blanks. We fake a leading ',' if there is (supposed to * be) a 1st expression, and keep demanding 1 expression for each ','. */ - if (is_it_end_of_statement()) + if (is_it_end_of_statement ()) { c = 0; /* Skip loop. */ } else { c = ','; /* Do loop. */ - -- input_line_pointer; + --input_line_pointer; } while (c == ',') { - ++ input_line_pointer; - SKIP_WHITESPACE(); - c = * input_line_pointer; + ++input_line_pointer; + SKIP_WHITESPACE (); + c = *input_line_pointer; /* C contains 1st non-blank character of what we hope is a number. */ if (c == '0') { - c = * ++ input_line_pointer; - if (c == 'x' || c=='X') + c = *++input_line_pointer; + if (c == 'x' || c == 'X') { - c = * ++ input_line_pointer; + c = *++input_line_pointer; radix = 16; } else @@ -1860,15 +2037,16 @@ void big_cons(nbytes) * mysterious zero constants: which is what they get when * they completely omit digits. */ - if (hex_value[c] >= radix) { - as_bad("Missing digits. 0 assumed."); - } - bignum_high = bignum_low - 1; /* Start constant with 0 chars. */ - for(; (digit = hex_value [c]) < radix; c = * ++ input_line_pointer) + if (hex_value[c] >= radix) + { + as_bad ("Missing digits. 0 assumed."); + } + bignum_high = bignum_low - 1; /* Start constant with 0 chars. */ + for (; (digit = hex_value[c]) < radix; c = *++input_line_pointer) { /* Multiply existing number by radix, then add digit. */ carry = digit; - for (p=bignum_low; p <= bignum_high; p++) + for (p = bignum_low; p <= bignum_high; p++) { work = (*p & MASK_CHAR) * radix + carry; *p = work & MASK_CHAR; @@ -1876,54 +2054,56 @@ void big_cons(nbytes) } if (carry) { - grow_bignum(); - * bignum_high = carry & MASK_CHAR; - know((carry & ~ MASK_CHAR) == 0); + grow_bignum (); + *bignum_high = carry & MASK_CHAR; + know ((carry & ~MASK_CHAR) == 0); } } length = bignum_high - bignum_low + 1; if (length > nbytes) { - as_warn("Most significant bits truncated in integer constant."); + as_warn ("Most significant bits truncated in integer constant."); } else { register long leading_zeroes; - for(leading_zeroes = nbytes - length; - leading_zeroes; - leading_zeroes --) + for (leading_zeroes = nbytes - length; + leading_zeroes; + leading_zeroes--) { - grow_bignum(); - * bignum_high = 0; + grow_bignum (); + *bignum_high = 0; } } - if (! need_pass_2) + if (!need_pass_2) { p = frag_more (nbytes); - bcopy (bignum_low, p, (int)nbytes); + bcopy (bignum_low, p, (int) nbytes); } /* C contains character after number. */ - SKIP_WHITESPACE(); - c = * input_line_pointer; + SKIP_WHITESPACE (); + c = *input_line_pointer; /* C contains 1st non-blank character after number. */ } - demand_empty_rest_of_line(); -} /* big_cons() */ + demand_empty_rest_of_line (); +} /* big_cons() */ - /* Extend bignum by 1 char. */ -static void grow_bignum() { +/* Extend bignum by 1 char. */ +static void +grow_bignum () +{ register long length; - bignum_high ++; + bignum_high++; if (bignum_high >= bignum_limit) { length = bignum_limit - bignum_low; - bignum_low = xrealloc(bignum_low, length + length); + bignum_low = xrealloc (bignum_low, length + length); bignum_high = bignum_low + length; bignum_limit = bignum_low + length + length; } -} /* grow_bignum(); */ +} /* grow_bignum(); */ /* * float_cons() @@ -1945,16 +2125,16 @@ static void grow_bignum() { * */ -void /* JF was static, but can't be if VAX.C is goning to use it */ -float_cons(float_type) /* Worker to do .float etc statements. */ - /* Clobbers input_line-pointer, checks end-of-line. */ +void /* JF was static, but can't be if VAX.C is goning to use it */ +float_cons (float_type) /* Worker to do .float etc statements. */ + /* Clobbers input_line-pointer, checks end-of-line. */ register int float_type; /* 'f':.ffloat ... 'F':.float ... */ { - register char * p; + register char *p; register char c; - int length; /* Number of chars in an object. */ - register char * err; /* Error from scanning floating literal. */ - char temp [MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT]; + int length; /* Number of chars in an object. */ + register char *err; /* Error from scanning floating literal. */ + char temp[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT]; /* * The following awkward logic is to parse ZERO or more strings, @@ -1962,10 +2142,10 @@ float_cons(float_type) /* Worker to do .float etc statements. */ * trailing blanks. We fake a leading ',' if there is (supposed to * be) a 1st expression, and keep demanding 1 expression for each ','. */ - if (is_it_end_of_statement()) + if (is_it_end_of_statement ()) { c = 0; /* Skip loop. */ - ++ input_line_pointer; /*->past termintor. */ + ++input_line_pointer; /*->past termintor. */ } else { @@ -1974,41 +2154,41 @@ float_cons(float_type) /* Worker to do .float etc statements. */ while (c == ',') { /* input_line_pointer->1st char of a flonum (we hope!). */ - SKIP_WHITESPACE(); + SKIP_WHITESPACE (); /* Skip any 0{letter} that may be present. Don't even check if the * letter is legal. Someone may invent a "z" format and this routine * has no use for such information. Lusers beware: you get * diagnostics if your input is ill-conditioned. */ - if (input_line_pointer[0]=='0' && isalpha(input_line_pointer[1])) - input_line_pointer+=2; + if (input_line_pointer[0] == '0' && isalpha (input_line_pointer[1])) + input_line_pointer += 2; err = md_atof (float_type, temp, &length); - know(length <= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT); - know(length > 0); - if (* err) + know (length <= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT); + know (length > 0); + if (*err) { - as_bad("Bad floating literal: %s", err); - ignore_rest_of_line(); + as_bad ("Bad floating literal: %s", err); + ignore_rest_of_line (); /* Input_line_pointer->just after end-of-line. */ c = 0; /* Break out of loop. */ } else { - if (! need_pass_2) + if (!need_pass_2) { p = frag_more (length); bcopy (temp, p, length); } - SKIP_WHITESPACE(); - c = * input_line_pointer ++; + SKIP_WHITESPACE (); + c = *input_line_pointer++; /* C contains 1st non-white character after number. */ /* input_line_pointer->just after terminator (c). */ } } - -- input_line_pointer; /*->terminator (is not ','). */ - demand_empty_rest_of_line(); + --input_line_pointer; /*->terminator (is not ','). */ + demand_empty_rest_of_line (); } /* float_cons() */ /* @@ -2020,17 +2200,18 @@ float_cons(float_type) /* Worker to do .float etc statements. */ */ -void stringer(append_zero ) /* Worker to do .ascii etc statements. */ - /* Checks end-of-line. */ +void +stringer (append_zero) /* Worker to do .ascii etc statements. */ + /* Checks end-of-line. */ register int append_zero; /* 0: don't append '\0', else 1 */ { /* register char * p; JF unused */ - /* register int length; JF unused */ /* Length of string we read, excluding */ + /* register int length; JF unused *//* Length of string we read, excluding */ /* trailing '\0' implied by closing quote. */ /* register char * where; JF unused */ /* register fragS * fragP; JF unused */ register unsigned int c; - + /* * The following awkward logic is to parse ZERO or more strings, * comma seperated. Recall a string expression includes spaces @@ -2039,182 +2220,194 @@ void stringer(append_zero ) /* Worker to do .ascii etc statements. */ * a 1st, expression. We keep demanding expressions for each * ','. */ - if (is_it_end_of_statement()) - { - c = 0; /* Skip loop. */ - ++ input_line_pointer; /* Compensate for end of loop. */ - } + if (is_it_end_of_statement ()) + { + c = 0; /* Skip loop. */ + ++input_line_pointer; /* Compensate for end of loop. */ + } else - { - c = ','; /* Do loop. */ - } - while (c == ',' || c == '<' || c == '"' ) { - SKIP_WHITESPACE(); - switch (*input_line_pointer) { - case '\"': - ++input_line_pointer; /*->1st char of string. */ - while (is_a_char(c = next_char_of_string())) { - FRAG_APPEND_1_CHAR(c); - } - if (append_zero) { - FRAG_APPEND_1_CHAR(0); - } - know(input_line_pointer [-1] == '\"'); - break; - case '<': - input_line_pointer++; - c =get_single_number(); - FRAG_APPEND_1_CHAR(c); - if(*input_line_pointer != '>') { - as_bad("Expected <nn>"); - } - input_line_pointer++; - break; - case ',': - input_line_pointer++; - break; + { + c = ','; /* Do loop. */ + } + while (c == ',' || c == '<' || c == '"') + { + SKIP_WHITESPACE (); + switch (*input_line_pointer) + { + case '\"': + ++input_line_pointer; /*->1st char of string. */ + while (is_a_char (c = next_char_of_string ())) + { + FRAG_APPEND_1_CHAR (c); + } + if (append_zero) + { + FRAG_APPEND_1_CHAR (0); + } + know (input_line_pointer[-1] == '\"'); + break; + case '<': + input_line_pointer++; + c = get_single_number (); + FRAG_APPEND_1_CHAR (c); + if (*input_line_pointer != '>') + { + as_bad ("Expected <nn>"); + } + input_line_pointer++; + break; + case ',': + input_line_pointer++; + break; + } + SKIP_WHITESPACE (); + c = *input_line_pointer; } - SKIP_WHITESPACE(); - c = *input_line_pointer; - } - demand_empty_rest_of_line(); -} /* stringer() */ + demand_empty_rest_of_line (); +} /* stringer() */ - /* FIXME-SOMEDAY: I had trouble here on characters with the +/* FIXME-SOMEDAY: I had trouble here on characters with the high bits set. We'll probably also have trouble with multibyte chars, wide chars, etc. Also be careful about returning values bigger than 1 byte. xoxorich. */ - unsigned int next_char_of_string() { - register unsigned int c; - - c = *input_line_pointer++ & CHAR_MASK; - switch (c) { - case '\"': - c = NOT_A_CHAR; - break; - - case '\\': - switch (c = *input_line_pointer++) { - case 'b': - c = '\b'; - break; - - case 'f': - c = '\f'; - break; - - case 'n': - c = '\n'; - break; - - case 'r': - c = '\r'; - break; - - case 't': - c = '\t'; - break; - +unsigned int +next_char_of_string () +{ + register unsigned int c; + + c = *input_line_pointer++ & CHAR_MASK; + switch (c) + { + case '\"': + c = NOT_A_CHAR; + break; + + case '\\': + switch (c = *input_line_pointer++) + { + case 'b': + c = '\b'; + break; + + case 'f': + c = '\f'; + break; + + case 'n': + c = '\n'; + break; + + case 'r': + c = '\r'; + break; + + case 't': + c = '\t'; + break; + #ifdef BACKSLASH_V - case 'v': - c = '\013'; - break; + case 'v': + c = '\013'; + break; #endif - - case '\\': - case '"': - break; /* As itself. */ - - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': { - long number; - - for (number = 0; isdigit(c); c = *input_line_pointer++) { - number = number * 8 + c - '0'; - } - c = number & 0xff; - } - --input_line_pointer; - break; - - case '\n': - /* To be compatible with BSD 4.2 as: give the luser a linefeed!! */ - as_warn("Unterminated string: Newline inserted."); - c = '\n'; - break; - - default: - + + case '\\': + case '"': + break; /* As itself. */ + + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + { + long number; + + for (number = 0; isdigit (c); c = *input_line_pointer++) + { + number = number * 8 + c - '0'; + } + c = number & 0xff; + } + --input_line_pointer; + break; + + case '\n': + /* To be compatible with BSD 4.2 as: give the luser a linefeed!! */ + as_warn ("Unterminated string: Newline inserted."); + c = '\n'; + break; + + default: + #ifdef ONLY_STANDARD_ESCAPES - as_bad("Bad escaped character in string, '?' assumed"); - c = '?'; + as_bad ("Bad escaped character in string, '?' assumed"); + c = '?'; #endif /* ONLY_STANDARD_ESCAPES */ - - break; - } /* switch on escaped char */ - break; - - default: - break; - } /* switch on char */ - return(c); -} /* next_char_of_string() */ + + break; + } /* switch on escaped char */ + break; + + default: + break; + } /* switch on char */ + return (c); +} /* next_char_of_string() */ static segT get_segmented_expression (expP) - register expressionS * expP; + register expressionS *expP; { - register segT retval; + register segT retval; - if ((retval = expression(expP)) == SEG_PASS1 || retval == SEG_ABSENT || retval == SEG_BIG) + if ((retval = expression (expP)) == SEG_PASS1 || retval == SEG_ABSENT || retval == SEG_BIG) { - as_bad("Expected address expression: absolute 0 assumed"); + as_bad ("Expected address expression: absolute 0 assumed"); retval = expP->X_seg = SEG_ABSOLUTE; - expP->X_add_number = 0; - expP->X_add_symbol = expP->X_subtract_symbol = 0; + expP->X_add_number = 0; + expP->X_add_symbol = expP->X_subtract_symbol = 0; } return (retval); /* SEG_ ABSOLUTE,UNKNOWN,DATA,TEXT,BSS */ } -static segT get_known_segmented_expression(expP) -register expressionS *expP; +static segT +get_known_segmented_expression (expP) + register expressionS *expP; { - register segT retval; - register char * name1; - register char * name2; + register segT retval; + register char *name1; + register char *name2; if ((retval = get_segmented_expression (expP)) == SEG_UNKNOWN) { - name1 = expP->X_add_symbol ? S_GET_NAME(expP->X_add_symbol) : ""; + name1 = expP->X_add_symbol ? S_GET_NAME (expP->X_add_symbol) : ""; name2 = expP->X_subtract_symbol ? - S_GET_NAME(expP->X_subtract_symbol) : - ""; + S_GET_NAME (expP->X_subtract_symbol) : + ""; if (name1 && name2) { - as_warn("Symbols \"%s\" \"%s\" are undefined: absolute 0 assumed.", - name1, name2); + as_warn ("Symbols \"%s\" \"%s\" are undefined: absolute 0 assumed.", + name1, name2); } else { - as_warn("Symbol \"%s\" undefined: absolute 0 assumed.", - name1 ? name1 : name2); + as_warn ("Symbol \"%s\" undefined: absolute 0 assumed.", + name1 ? name1 : name2); } retval = expP->X_seg = SEG_ABSOLUTE; - expP->X_add_number = 0; - expP->X_add_symbol = expP->X_subtract_symbol = NULL; + expP->X_add_number = 0; + expP->X_add_symbol = expP->X_subtract_symbol = NULL; } #ifndef MANY_SEGMENTS - know(retval == SEG_ABSOLUTE || retval == SEG_DATA || retval == SEG_TEXT || retval == SEG_BSS || retval == SEG_DIFFERENCE); + know (retval == SEG_ABSOLUTE || retval == SEG_DATA || retval == SEG_TEXT || retval == SEG_BSS || retval == SEG_DIFFERENCE); #endif return (retval); @@ -2222,29 +2415,29 @@ register expressionS *expP; -/* static */ long /* JF was static, but can't be if the MD pseudos are to use it */ +/* static */ long /* JF was static, but can't be if the MD pseudos are to use it */ get_absolute_expression () { - expressionS exp; + expressionS exp; register segT s; - if ((s = expression(& exp)) != SEG_ABSOLUTE) + if ((s = expression (&exp)) != SEG_ABSOLUTE) { if (s != SEG_ABSENT) { - as_bad("Bad Absolute Expression, absolute 0 assumed."); + as_bad ("Bad Absolute Expression, absolute 0 assumed."); } - exp . X_add_number = 0; + exp.X_add_number = 0; } - return (exp . X_add_number); + return (exp.X_add_number); } -char /* return terminator */ -get_absolute_expression_and_terminator(val_pointer) - long * val_pointer; /* return value of expression */ +char /* return terminator */ +get_absolute_expression_and_terminator (val_pointer) + long *val_pointer; /* return value of expression */ { - * val_pointer = get_absolute_expression (); - return (* input_line_pointer ++); + *val_pointer = get_absolute_expression (); + return (*input_line_pointer++); } /* @@ -2255,24 +2448,24 @@ get_absolute_expression_and_terminator(val_pointer) */ char * demand_copy_C_string (len_pointer) - int * len_pointer; + int *len_pointer; { - register char * s; + register char *s; - if ((s = demand_copy_string(len_pointer)) != 0) + if ((s = demand_copy_string (len_pointer)) != 0) { register int len; - for (len = * len_pointer; + for (len = *len_pointer; len > 0; len--) { - if (* s == 0) + if (*s == 0) { s = 0; len = 1; - * len_pointer = 0; - as_bad("This string may not contain \'\\0\'"); + *len_pointer = 0; + as_bad ("This string may not contain \'\\0\'"); } } } @@ -2285,34 +2478,39 @@ demand_copy_C_string (len_pointer) * Demand string, but return a safe (=private) copy of the string. * Return NULL if we can't read a string here. */ -static char *demand_copy_string(lenP) -int *lenP; +static char * +demand_copy_string (lenP) + int *lenP; { - register unsigned int c; - register int len; - char *retval; - - len = 0; - SKIP_WHITESPACE(); - if (*input_line_pointer == '\"') { - input_line_pointer++; /* Skip opening quote. */ - - while (is_a_char(c = next_char_of_string())) { - obstack_1grow(¬es, c); - len ++; - } - /* JF this next line is so demand_copy_C_string will return a null - termanated string. */ - obstack_1grow(¬es,'\0'); - retval=obstack_finish(¬es); - } else { - as_warn("Missing string"); - retval = NULL; - ignore_rest_of_line(); + register unsigned int c; + register int len; + char *retval; + + len = 0; + SKIP_WHITESPACE (); + if (*input_line_pointer == '\"') + { + input_line_pointer++; /* Skip opening quote. */ + + while (is_a_char (c = next_char_of_string ())) + { + obstack_1grow (¬es, c); + len++; } - *lenP = len; - return(retval); -} /* demand_copy_string() */ + /* JF this next line is so demand_copy_C_string will return a null + termanated string. */ + obstack_1grow (¬es, '\0'); + retval = obstack_finish (¬es); + } + else + { + as_warn ("Missing string"); + retval = NULL; + ignore_rest_of_line (); + } + *lenP = len; + return (retval); +} /* demand_copy_string() */ /* * is_it_end_of_statement() @@ -2323,50 +2521,58 @@ int *lenP; * * Out: 1 if input_line_pointer->end-of-line. */ -int is_it_end_of_statement() { - SKIP_WHITESPACE(); - return (is_end_of_line [* input_line_pointer]); -} /* is_it_end_of_statement() */ +int +is_it_end_of_statement () +{ + SKIP_WHITESPACE (); + return (is_end_of_line[*input_line_pointer]); +} /* is_it_end_of_statement() */ -void equals(sym_name) -char *sym_name; +void +equals (sym_name) + char *sym_name; { - register symbolS *symbolP; /* symbol we are working with */ + register symbolS *symbolP; /* symbol we are working with */ input_line_pointer++; - if (*input_line_pointer=='=') + if (*input_line_pointer == '=') input_line_pointer++; - while(*input_line_pointer==' ' || *input_line_pointer=='\t') + while (*input_line_pointer == ' ' || *input_line_pointer == '\t') input_line_pointer++; - if (sym_name[0]=='.' && sym_name[1]=='\0') { - /* Turn '. = mumble' into a .org mumble */ - register segT segment; - expressionS exp; - register char *p; + if (sym_name[0] == '.' && sym_name[1] == '\0') + { + /* Turn '. = mumble' into a .org mumble */ + register segT segment; + expressionS exp; + register char *p; - segment = get_known_segmented_expression(& exp); - if (! need_pass_2) { - if (segment != now_seg && segment != SEG_ABSOLUTE) - as_warn("Illegal segment \"%s\". Segment \"%s\" assumed.", - segment_name(segment), - segment_name(now_seg)); - p = frag_var(rs_org, 1, 1, (relax_substateT)0, exp.X_add_symbol, - exp.X_add_number, (char *)0); - * p = 0; - } /* if (ok to make frag) */ - } else { - symbolP=symbol_find_or_make(sym_name); - pseudo_set(symbolP); - } -} /* equals() */ + segment = get_known_segmented_expression (&exp); + if (!need_pass_2) + { + if (segment != now_seg && segment != SEG_ABSOLUTE) + as_warn ("Illegal segment \"%s\". Segment \"%s\" assumed.", + segment_name (segment), + segment_name (now_seg)); + p = frag_var (rs_org, 1, 1, (relax_substateT) 0, exp.X_add_symbol, + exp.X_add_number, (char *) 0); + *p = 0; + } /* if (ok to make frag) */ + } + else + { + symbolP = symbol_find_or_make (sym_name); + pseudo_set (symbolP); + } +} /* equals() */ /* .include -- include a file at this point. */ /* ARGSUSED */ -void s_include(arg) -int arg; +void +s_include (arg) + int arg; { char *newbuf; char *filename; @@ -2374,70 +2580,67 @@ int arg; FILE *try; char *path; - filename = demand_copy_string(&i); - demand_empty_rest_of_line(); - path = xmalloc(i + include_dir_maxlen + 5 /* slop */); - for (i = 0; i < include_dir_count; i++) { - strcpy(path, include_dirs[i]); - strcat(path, "/"); - strcat(path, filename); - if (0 != (try = fopen(path, "r"))) - { - fclose (try); - goto gotit; - } - } - free(path); + filename = demand_copy_string (&i); + demand_empty_rest_of_line (); + path = xmalloc (i + include_dir_maxlen + 5 /* slop */ ); + for (i = 0; i < include_dir_count; i++) + { + strcpy (path, include_dirs[i]); + strcat (path, "/"); + strcat (path, filename); + if (0 != (try = fopen (path, "r"))) + { + fclose (try); + goto gotit; + } + } + free (path); path = filename; gotit: /* malloc Storage leak when file is found on path. FIXME-SOMEDAY. */ newbuf = input_scrub_include_file (path, input_line_pointer); buffer_limit = input_scrub_next_buffer (&input_line_pointer); -} /* s_include() */ +} /* s_include() */ -void add_include_dir(path) -char *path; +void +add_include_dir (path) + char *path; { int i; if (include_dir_count == 0) { - include_dirs = (char **)xmalloc (2 * sizeof (*include_dirs)); + include_dirs = (char **) xmalloc (2 * sizeof (*include_dirs)); include_dirs[0] = "."; /* Current dir */ include_dir_count = 2; } else { include_dir_count++; - include_dirs = (char **) realloc(include_dirs, - include_dir_count*sizeof (*include_dirs)); + include_dirs = (char **) realloc (include_dirs, + include_dir_count * sizeof (*include_dirs)); } - include_dirs[include_dir_count-1] = path; /* New one */ + include_dirs[include_dir_count - 1] = path; /* New one */ - i = strlen (path); - if (i > include_dir_maxlen) - include_dir_maxlen = i; -} /* add_include_dir() */ + i = strlen (path); + if (i > include_dir_maxlen) + include_dir_maxlen = i; +} /* add_include_dir() */ -void s_ignore(arg) -int arg; +void +s_ignore (arg) + int arg; { - extern char is_end_of_line[]; - - while (!is_end_of_line[*input_line_pointer]) { - ++input_line_pointer; - } - ++input_line_pointer; + extern char is_end_of_line[]; - return; -} /* s_ignore() */ + while (!is_end_of_line[*input_line_pointer]) + { + ++input_line_pointer; + } + ++input_line_pointer; -/* - * Local Variables: - * comment-column: 0 - * fill-column: 131 - * End: - */ + return; +} /* s_ignore() */ /* end of read.c */ @@ -1,23 +1,24 @@ /* read.h - of read.c - Copyright (C) 1986, 1990 Free Software Foundation, Inc. - + + Copyright (C) 1986, 1990, 1992 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. */ -extern char *input_line_pointer; /* -> char we are parsing now. */ +extern char *input_line_pointer;/* -> char we are parsing now. */ #define PERMIT_WHITESPACE /* Define to make whitespace be allowed in */ /* many syntactically unnecessary places. */ @@ -32,8 +33,8 @@ extern char *input_line_pointer; /* -> char we are parsing now. */ #endif -#define LEX_NAME (1) /* may continue a name */ -#define LEX_BEGIN_NAME (2) /* may begin a name */ +#define LEX_NAME (1) /* may continue a name */ +#define LEX_BEGIN_NAME (2) /* may begin a name */ #define is_name_beginner(c) ( lex_type[c] & LEX_BEGIN_NAME ) #define is_part_of_name(c) ( lex_type[c] & LEX_NAME ) @@ -47,83 +48,90 @@ extern char *input_line_pointer; /* -> char we are parsing now. */ extern const char lex_type[]; extern char is_end_of_line[]; -#ifdef __STDC__ - -char *demand_copy_C_string(int *len_pointer); -char get_absolute_expression_and_terminator(long *val_pointer); -long get_absolute_expression(void); -void add_include_dir(char *path); -void big_cons(int nbytes); -void cons(unsigned int nbytes); -void demand_empty_rest_of_line(void); -void equals(char *sym_name); -void float_cons(int float_type); -void ignore_rest_of_line(void); -void pseudo_set(symbolS *symbolP); -void read_a_source_file(char *name); -void read_begin(void); -void s_abort(void); -void s_align_bytes(int arg); -void s_align_ptwo(void); -void s_app_file(void); -void s_comm(void); -void s_data(void); -void s_else(int arg); -void s_end(int arg); -void s_endif(int arg); -void s_fill(void); -void s_globl(void); -void s_if(int arg); -void s_ifdef(int arg); -void s_ifeqs(int arg); -void s_ignore(int arg); -void s_include(int arg); -void s_lcomm(int needs_align); -void s_lsym(void); -void s_org(void); -void s_set(void); -void s_space(void); -void s_text(void); - -#else /* __STDC__ */ - -char *demand_copy_C_string(); -char get_absolute_expression_and_terminator(); -long get_absolute_expression(); -void add_include_dir(); -void big_cons(); -void cons(); -void demand_empty_rest_of_line(); -void equals(); -void float_cons(); -void ignore_rest_of_line(); -void pseudo_set(); -void read_a_source_file(); -void read_begin(); -void s_abort(); -void s_align_bytes(); -void s_align_ptwo(); -void s_app_file(); -void s_comm(); -void s_data(); -void s_else(); -void s_end(); -void s_endif(); -void s_fill(); -void s_globl(); -void s_if(); -void s_ifdef(); -void s_ifeqs(); -void s_ignore(); -void s_include(); -void s_lcomm(); -void s_lsym(); -void s_org(); -void s_set(); -void s_space(); -void s_text(); - -#endif /* __STDC__ */ +/* These are initialized by the CPU specific target files (tc-*.c). */ +extern const char comment_chars[]; +extern const char line_comment_chars[]; +extern const char line_separator_chars[]; + +#if __STDC__ == 1 + +char *demand_copy_C_string (int *len_pointer); +char get_absolute_expression_and_terminator (long *val_pointer); +long get_absolute_expression (void); +void add_include_dir (char *path); +void big_cons (int nbytes); +void cons (unsigned int nbytes); +void demand_empty_rest_of_line (void); +void equals (char *sym_name); +void float_cons (int float_type); +void ignore_rest_of_line (void); +void pseudo_set (symbolS * symbolP); +void read_a_source_file (char *name); +void read_begin (void); +void s_abort (void); +void s_align_bytes (int arg); +void s_align_ptwo (void); +void s_app_file (void); +/* void s_bss(void); -- unneeded; always static when used */ +void s_comm (void); +void s_data (void); +void s_else (int arg); +void s_end (int arg); +void s_endif (int arg); +void s_fill (void); +void s_globl (void); +void s_if (int arg); +void s_ifdef (int arg); +void s_ifeqs (int arg); +void s_ignore (int arg); +void s_include (int arg); +void s_lcomm (int needs_align); +void s_lsym (void); +void s_org (void); +void s_set (void); +void s_space (int mult); +void s_text (void); + +#else /* not __STDC__ */ + +char *demand_copy_C_string (); +char get_absolute_expression_and_terminator (); +long get_absolute_expression (); +void add_include_dir (); +void big_cons (); +void cons (); +void demand_empty_rest_of_line (); +void equals (); +void float_cons (); +void ignore_rest_of_line (); +void pseudo_set (); +void read_a_source_file (); +void read_begin (); +void s_abort (); +void s_align_bytes (); +void s_align_ptwo (); +void s_app_file (); +/* void s_bss(); -- unneeded; always static when used */ +void s_comm (); +void s_data (); +void s_else (); +void s_end (); +void s_endif (); +void s_fill (); +void s_globl (); +void s_if (); +void s_ifdef (); +void s_ifeqs (); +void s_ignore (); +void s_include (); +void s_lcomm (); +void s_lsym (); +void s_org (); +void s_set (); +void s_space (); +void s_text (); + +#endif /* not __STDC__ */ /* * Local Variables: diff --git a/gas/strerror.c b/gas/strerror.c index dbc403b..0e3d7f9 100644 --- a/gas/strerror.c +++ b/gas/strerror.c @@ -49,13 +49,13 @@ extern char *sys_errlist[]; char * strerror (code) - int code; + int code; { - return (((code < 0) || (code >= sys_nerr)) + return (((code < 0) || (code >= sys_nerr)) ? "(unknown error)" - : sys_errlist [code]); + : sys_errlist[code]); } #endif /* HAVE_STRERROR */ - /* end of strerror.c */ +/* end of strerror.c */ diff --git a/gas/strstr.c b/gas/strstr.c index 7c7074a..2bb8890 100644 --- a/gas/strstr.c +++ b/gas/strstr.c @@ -1,19 +1,19 @@ /* strstr - find first occurrence of wanted in s Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation. - + 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. */ @@ -29,26 +29,26 @@ #include <string.h> char * /* found string, or NULL if none */ - strstr(s, wanted) -char *s; -char *wanted; +strstr (s, wanted) + char *s; + char *wanted; { - register char *scan; - register SIZET len; - register char firstc; - - /* + register char *scan; + register SIZET len; + register char firstc; + + /* * The odd placement of the two tests is so "" is findable. * Also, we inline the first char for speed. * The ++ on scan has been moved down for optimization. */ - firstc = *wanted; - len = strlen(wanted); - for (scan = s; *scan != firstc || strncmp(scan, wanted, len) != 0; ) - if (*scan++ == '\0') - return(NULL); - return(scan); -} /* strstr() */ + firstc = *wanted; + len = strlen (wanted); + for (scan = s; *scan != firstc || strncmp (scan, wanted, len) != 0;) + if (*scan++ == '\0') + return (NULL); + return (scan); +} /* strstr() */ #endif /* not __STDC__ */ diff --git a/gas/struc-symbol.h b/gas/struc-symbol.h index 541f65c..1db476f 100644 --- a/gas/struc-symbol.h +++ b/gas/struc-symbol.h @@ -1,39 +1,42 @@ /* struct_symbol.h - Internal symbol structure Copyright (C) 1987, 1992 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. - + oYou 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. */ +#ifndef __struc_symbol_h__ +#define __struc_symbol_h__ + struct symbol /* our version of an nlist node */ { - obj_symbol_type sy_symbol; /* what we write in .o file (if permitted) */ - unsigned long sy_name_offset; /* 4-origin position of sy_name in symbols */ - /* part of object file. */ - /* 0 for (nameless) .stabd symbols. */ - /* Not used until write_object_file() time. */ - long sy_number; /* 24 bit symbol number. */ - /* Symbol numbers start at 0 and are */ - /* unsigned. */ - struct symbol *sy_next; /* forward chain, or NULL */ + obj_symbol_type sy_symbol; /* what we write in .o file (if permitted) */ + unsigned long sy_name_offset; /* 4-origin position of sy_name in symbols */ + /* part of object file. */ + /* 0 for (nameless) .stabd symbols. */ + /* Not used until write_object_file() time. */ + long sy_number; /* 24 bit symbol number. */ + /* Symbol numbers start at 0 and are */ + /* unsigned. */ + struct symbol *sy_next; /* forward chain, or NULL */ #ifdef SYMBOLS_NEED_BACKPOINTERS - struct symbol *sy_previous; /* backward chain, or NULL */ + struct symbol *sy_previous; /* backward chain, or NULL */ #endif /* SYMBOLS_NEED_BACKPOINTERS */ - struct frag *sy_frag; /* NULL or -> frag this symbol attaches to. */ - struct symbol *sy_forward; /* value is really that of this other symbol */ - /* We will probably want to add a sy_segment here soon. */ + struct frag *sy_frag; /* NULL or -> frag this symbol attaches to. */ + struct symbol *sy_forward; /* value is really that of this other symbol */ + /* We will probably want to add a sy_segment here soon. */ }; typedef struct symbol symbolS; @@ -41,20 +44,21 @@ typedef struct symbol symbolS; typedef unsigned valueT; /* The type of n_value. Helps casting. */ #ifndef WORKING_DOT_WORD -struct broken_word { - struct broken_word *next_broken_word;/* One of these strucs per .word x-y */ - fragS *frag; /* Which frag its in */ - char *word_goes_here;/* Where in the frag it is */ - fragS *dispfrag; /* where to add the break */ - symbolS *add; /* symbol_x */ - symbolS *sub; /* - symbol_y */ - long addnum; /* + addnum */ - int added; /* nasty thing happend yet? */ - /* 1: added and has a long-jump */ - /* 2: added but uses someone elses long-jump */ - struct broken_word *use_jump; /* points to broken_word with a similar +struct broken_word + { + struct broken_word *next_broken_word; /* One of these strucs per .word x-y */ + fragS *frag; /* Which frag its in */ + char *word_goes_here; /* Where in the frag it is */ + fragS *dispfrag; /* where to add the break */ + symbolS *add; /* symbol_x */ + symbolS *sub; /* - symbol_y */ + long addnum; /* + addnum */ + int added; /* nasty thing happend yet? */ + /* 1: added and has a long-jump */ + /* 2: added but uses someone elses long-jump */ + struct broken_word *use_jump; /* points to broken_word with a similar long-jump */ -}; + }; extern struct broken_word *broken_words; #endif /* ndef WORKING_DOT_WORD */ @@ -63,27 +67,27 @@ extern struct broken_word *broken_words; * This will change for infinite-segments support (e.g. COFF). */ /* #define SYMBOL_TYPE_TO_SEGMENT(symP) ( N_TYPE_seg [(int) (symP)->sy_type & N_TYPE] ) */ -extern segT N_TYPE_seg[]; /* subseg.c */ +extern segT N_TYPE_seg[]; /* subseg.c */ #define SEGMENT_TO_SYMBOL_TYPE(seg) ( seg_N_TYPE [(int) (seg)] ) -extern const short seg_N_TYPE[]; /* subseg.c */ +extern const short seg_N_TYPE[];/* subseg.c */ #define N_REGISTER 30 /* Fake N_TYPE value for SEG_REGISTER */ #ifdef SYMBOLS_NEED_BACKPOINTERS #if __STDC__ == 1 -void symbol_clear_list_pointers(symbolS *symbolP); -void symbol_insert(symbolS *addme, symbolS *target, symbolS **rootP, symbolS **lastP); -void symbol_remove(symbolS *symbolP, symbolS **rootP, symbolS **lastP); -void verify_symbol_chain(symbolS *rootP, symbolS *lastP); +void symbol_clear_list_pointers (symbolS * symbolP); +void symbol_insert (symbolS * addme, symbolS * target, symbolS ** rootP, symbolS ** lastP); +void symbol_remove (symbolS * symbolP, symbolS ** rootP, symbolS ** lastP); +void verify_symbol_chain (symbolS * rootP, symbolS * lastP); #else /* not __STDC__ */ -void symbol_clear_list_pointers(); -void symbol_insert(); -void symbol_remove(); -void verify_symbol_chain(); +void symbol_clear_list_pointers (); +void symbol_insert (); +void symbol_remove (); +void verify_symbol_chain (); #endif /* not __STDC__ */ @@ -96,13 +100,15 @@ void verify_symbol_chain(); #endif /* SYMBOLS_NEED_BACKPOINTERS */ #if __STDC__ == 1 -void symbol_append(symbolS *addme, symbolS *target, symbolS **rootP, symbolS **lastP); +void symbol_append (symbolS * addme, symbolS * target, symbolS ** rootP, symbolS ** lastP); #else /* not __STDC__ */ -void symbol_append(); +void symbol_append (); #endif /* not __STDC__ */ #define symbol_next(s) ((s)->sy_next) +#endif /* __struc_symbol_h__ */ + /* * Local Variables: * comment-column: 0 diff --git a/gas/symbols.c b/gas/symbols.c index 7ca784d..a140046 100644 --- a/gas/symbols.c +++ b/gas/symbols.c @@ -1,22 +1,25 @@ /* symbols.c -symbol table- - Copyright (C) 1987, 1990, 1991 Free Software Foundation, Inc. - + + Copyright (C) 1987, 1990, 1991, 1992 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 <ctype.h> + #include "as.h" #include "obstack.h" /* For "symbols.h" */ @@ -30,118 +33,41 @@ extern char const_flag; #endif static - struct hash_control * - sy_hash; /* symbol-name => struct symbol pointer */ +struct hash_control * + sy_hash; /* symbol-name => struct symbol pointer */ /* Below are commented in "symbols.h". */ unsigned int local_bss_counter; -symbolS * symbol_rootP; -symbolS * symbol_lastP; -symbolS abs_symbol; +symbolS *symbol_rootP; +symbolS *symbol_lastP; +symbolS abs_symbol; -symbolS* dot_text_symbol; -symbolS* dot_data_symbol; -symbolS* dot_bss_symbol; +symbolS *dot_text_symbol; +symbolS *dot_data_symbol; +symbolS *dot_bss_symbol; -struct obstack notes; +struct obstack notes; -/* - * Un*x idea of local labels. They are made by "n:" where n - * is any decimal digit. Refer to them with - * "nb" for previous (backward) n: - * or "nf" for next (forward) n:. - * - * Like Un*x AS, we have one set of local label counters for entire assembly, - * not one set per (sub)segment like in most assemblers. This implies that - * one can refer to a label in another segment, and indeed some crufty - * compilers have done just that. - * - * I document the symbol names here to save duplicating words elsewhere. - * The mth occurence of label n: is turned into the symbol "Ln^Am" where - * n is a digit and m is a decimal number. "L" makes it a label discarded - * unless debugging and "^A"('\1') ensures no ordinary symbol SHOULD get the - * same name as a local label symbol. The first "4:" is "L4^A1" - the m - * numbers begin at 1. - */ - -typedef short unsigned int - local_label_countT; - -static local_label_countT - local_label_counter[10]; +#if __STDC__ == 1 +static void fb_label_init (void); +#else /* not __STDC__ */ +static void fb_label_init (); +#endif /* not __STDC__ */ -static /* Returned to caller, then copied. */ - char symbol_name_build[12]; /* used for created names ("4f") */ - -#ifdef LOCAL_LABELS_DOLLAR -int local_label_defined[10]; -#endif - - void - symbol_begin() +symbol_begin () { - symbol_lastP = NULL; - symbol_rootP = NULL; /* In case we have 0 symbols (!!) */ - sy_hash = hash_new(); - bzero ((char *)(& abs_symbol), sizeof(abs_symbol)); - S_SET_SEGMENT(&abs_symbol, SEG_ABSOLUTE); /* Can't initialise a union. Sigh. */ - bzero ((char *)(local_label_counter), sizeof(local_label_counter) ); - local_bss_counter = 0; + symbol_lastP = NULL; + symbol_rootP = NULL; /* In case we have 0 symbols (!!) */ + sy_hash = hash_new (); + memset ((char *) (&abs_symbol), '\0', sizeof (abs_symbol)); + S_SET_SEGMENT (&abs_symbol, SEG_ABSOLUTE); /* Can't initialise a union. Sigh. */ + local_bss_counter = 0; +#ifdef LOCAL_LABELS_FB + fb_label_init (); +#endif /* LOCAL_LABELS_FB */ } - -/* - * local_label_name() - * - * Caller must copy returned name: we re-use the area for the next name. - */ - -char * /* Return local label name. */ - local_label_name(n, augend) -register int n; /* we just saw "n:", "nf" or "nb" : n a digit */ -register int augend; /* 0 for nb, 1 for n:, nf */ -{ - register char * p; - register char * q; - char symbol_name_temporary[10]; /* build up a number, BACKWARDS */ - - know( n >= 0 ); - know( augend == 0 || augend == 1 ); - p = symbol_name_build; - * p ++ = 'L'; - * p ++ = n + '0'; /* Make into ASCII */ - * p ++ = 1; /* ^A */ - n = local_label_counter [ n ] + augend; - /* version number of this local label */ - /* - * Next code just does sprintf( {}, "%d", n); - * It is more elegant to do the next part recursively, but a procedure - * call for each digit emitted is considered too costly. - */ - q = symbol_name_temporary; - for (*q++=0; n; q++) /* emits NOTHING if n starts as 0 */ - { - know(n>0); /* We expect n > 0 always */ - *q = n % 10 + '0'; - n /= 10; - } - while (( * p ++ = * -- q ) != '\0') ;; - - /* The label, as a '\0' ended string, starts at symbol_name_build. */ - return(symbol_name_build); -} /* local_label_name() */ - -void local_colon (n) -int n; /* just saw "n:" */ -{ - local_label_counter [n] ++; -#ifdef LOCAL_LABELS_DOLLAR - local_label_defined[n]=1; -#endif - colon (local_label_name (n, 0)); -} - /* * symbol_new() * @@ -159,57 +85,58 @@ int n; /* just saw "n:" */ * from macros in struc-symbol.h). */ -symbolS *symbol_new(name, segment, value, frag) -char *name; /* It is copied, the caller can destroy/modify */ -segT segment; /* Segment identifier (SEG_<something>) */ -long value; /* Symbol value */ -fragS *frag; /* Associated fragment */ +symbolS * +symbol_new (name, segment, value, frag) + char *name; /* It is copied, the caller can destroy/modify */ + segT segment; /* Segment identifier (SEG_<something>) */ + long value; /* Symbol value */ + fragS *frag; /* Associated fragment */ { - unsigned int name_length; - char *preserved_copy_of_name; - symbolS *symbolP; - - name_length = strlen(name) + 1; /* +1 for \0 */ - obstack_grow(¬es, name, name_length); - preserved_copy_of_name = obstack_finish(¬es); - symbolP = (symbolS *)obstack_alloc(¬es, sizeof(symbolS)); - - /* symbol must be born in some fixed state. This seems as good as any. */ - memset(symbolP, 0, sizeof(symbolS)); - + unsigned int name_length; + char *preserved_copy_of_name; + symbolS *symbolP; + + name_length = strlen (name) + 1; /* +1 for \0 */ + obstack_grow (¬es, name, name_length); + preserved_copy_of_name = obstack_finish (¬es); + symbolP = (symbolS *) obstack_alloc (¬es, sizeof (symbolS)); + + /* symbol must be born in some fixed state. This seems as good as any. */ + memset (symbolP, 0, sizeof (symbolS)); + #ifdef STRIP_UNDERSCORE - S_SET_NAME(symbolP, (*preserved_copy_of_name == '_' - ? preserved_copy_of_name + 1 - : preserved_copy_of_name)); + S_SET_NAME (symbolP, (*preserved_copy_of_name == '_' + ? preserved_copy_of_name + 1 + : preserved_copy_of_name)); #else /* STRIP_UNDERSCORE */ - S_SET_NAME(symbolP, preserved_copy_of_name); + S_SET_NAME (symbolP, preserved_copy_of_name); #endif /* STRIP_UNDERSCORE */ - - S_SET_SEGMENT(symbolP, segment); - S_SET_VALUE(symbolP, value); - /* symbol_clear_list_pointers(symbolP); uneeded if symbol is born zeroed. */ - - symbolP->sy_frag = frag; - /* krm: uneeded if symbol is born zeroed. - symbolP->sy_forward = NULL; */ /* JF */ - symbolP->sy_number = ~0; - symbolP->sy_name_offset = ~0; - - /* + + S_SET_SEGMENT (symbolP, segment); + S_SET_VALUE (symbolP, value); + /* symbol_clear_list_pointers(symbolP); uneeded if symbol is born zeroed. */ + + symbolP->sy_frag = frag; + /* krm: uneeded if symbol is born zeroed. + symbolP->sy_forward = NULL; *//* JF */ + symbolP->sy_number = ~0; + symbolP->sy_name_offset = ~0; + + /* * Link to end of symbol chain. */ - symbol_append(symbolP, symbol_lastP, &symbol_rootP, &symbol_lastP); - - obj_symbol_new_hook(symbolP); - + symbol_append (symbolP, symbol_lastP, &symbol_rootP, &symbol_lastP); + + obj_symbol_new_hook (symbolP); + #ifdef DEBUG - /* verify_symbol_chain(symbol_rootP, symbol_lastP); */ + /* verify_symbol_chain(symbol_rootP, symbol_lastP); */ #endif /* DEBUG */ - - return(symbolP); -} /* symbol_new() */ + return (symbolP); +} /* symbol_new() */ + /* * colon() * @@ -219,90 +146,99 @@ fragS *frag; /* Associated fragment */ * Gripes if we are redefining a symbol incompatibly (and ignores it). * */ -void colon(sym_name) /* just seen "x:" - rattle symbols & frags */ -register char * sym_name; /* symbol name, as a cannonical string */ -/* We copy this string: OK to alter later. */ +void +colon (sym_name) /* just seen "x:" - rattle symbols & frags */ + register char *sym_name; /* symbol name, as a cannonical string */ + /* We copy this string: OK to alter later. */ { - register symbolS * symbolP; /* symbol we are working with */ - + 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') - bzero((void *) local_label_defined, sizeof(local_label_defined)); -#endif - + /* Sun local labels go out of scope whenever a non-local symbol is defined. */ + + if (*sym_name != 'L') + dollar_label_clear (); +#endif /* LOCAL_LABELS_DOLLAR */ + #ifndef WORKING_DOT_WORD - if(new_broken_words) { - struct broken_word *a; - int possible_bytes; - fragS *frag_tmp; - char *frag_opcode; - - extern md_short_jump_size; - extern md_long_jump_size; - possible_bytes=md_short_jump_size + new_broken_words * md_long_jump_size; - - frag_tmp=frag_now; - frag_opcode=frag_var(rs_broken_word, - possible_bytes, - possible_bytes, - (relax_substateT) 0, - (symbolS *) broken_words, - 0L, - NULL); - - /* We want to store the pointer to where to insert the jump table in the + if (new_broken_words) + { + struct broken_word *a; + int possible_bytes; + fragS *frag_tmp; + char *frag_opcode; + + extern md_short_jump_size; + extern md_long_jump_size; + possible_bytes = md_short_jump_size + new_broken_words * md_long_jump_size; + + frag_tmp = frag_now; + frag_opcode = frag_var (rs_broken_word, + possible_bytes, + possible_bytes, + (relax_substateT) 0, + (symbolS *) broken_words, + 0L, + NULL); + + /* We want to store the pointer to where to insert the jump table in the fr_opcode of the rs_broken_word frag. This requires a little hackery */ - while(frag_tmp && (frag_tmp->fr_type!=rs_broken_word || frag_tmp->fr_opcode)) - frag_tmp=frag_tmp->fr_next; - know(frag_tmp); - frag_tmp->fr_opcode=frag_opcode; - new_broken_words = 0; - - for(a=broken_words;a && a->dispfrag==0;a=a->next_broken_word) - a->dispfrag=frag_tmp; - } -#endif - if ((symbolP = symbol_find(sym_name)) != 0) { + while (frag_tmp && (frag_tmp->fr_type != rs_broken_word || frag_tmp->fr_opcode)) + frag_tmp = frag_tmp->fr_next; + know (frag_tmp); + frag_tmp->fr_opcode = frag_opcode; + new_broken_words = 0; + + for (a = broken_words; a && a->dispfrag == 0; a = a->next_broken_word) + a->dispfrag = frag_tmp; + } +#endif /* WORKING_DOT_WORD */ + + if ((symbolP = symbol_find (sym_name)) != 0) + { #ifdef VMS - /* + /* * If the new symbol is .comm AND it has a size of zero, * we ignore it (i.e. the old symbol overrides it) */ - if ((SEGMENT_TO_SYMBOL_TYPE((int) now_seg) == (N_UNDF | N_EXT)) && - ((obstack_next_free(& frags) - frag_now->fr_literal) == 0)) - return; - /* + if ((SEGMENT_TO_SYMBOL_TYPE ((int) now_seg) == (N_UNDF | N_EXT)) && + ((obstack_next_free (&frags) - frag_now->fr_literal) == 0)) + return; + /* * If the old symbol is .comm and it has a size of zero, * we override it with the new symbol value. */ - if ((symbolP->sy_type == (N_UNDF | N_EXT)) - && (S_GET_VALUE(symbolP) == 0)) { - symbolP->sy_frag = frag_now; - symbolP->sy_other = const_flag; - S_SET_VALUE(symbolP, obstack_next_free(& frags) - frag_now->fr_literal); - symbolP->sy_type |= SEGMENT_TO_SYMBOL_TYPE((int) now_seg); /* keep N_EXT bit */ - return; - } -#endif /* VMS */ - /* + if ((symbolP->sy_type == (N_UNDF | N_EXT)) + && (S_GET_VALUE (symbolP) == 0)) + { + symbolP->sy_frag = frag_now; + symbolP->sy_other = const_flag; + S_SET_VALUE (symbolP, obstack_next_free (&frags) - frag_now->fr_literal); + symbolP->sy_type |= SEGMENT_TO_SYMBOL_TYPE ((int) now_seg); /* keep N_EXT bit */ + return; + } +#endif /* VMS */ + /* * Now check for undefined symbols */ - if (!S_IS_DEFINED(symbolP)) { - if (S_GET_VALUE(symbolP) == 0) { - symbolP->sy_frag = frag_now; + if (!S_IS_DEFINED (symbolP)) + { + if (S_GET_VALUE (symbolP) == 0) + { + symbolP->sy_frag = frag_now; #ifdef VMS - symbolP->sy_other = const_flag; + symbolP->sy_other = const_flag; #endif - S_SET_VALUE(symbolP, obstack_next_free(&frags) - frag_now->fr_literal); - S_SET_SEGMENT(symbolP, now_seg); + S_SET_VALUE (symbolP, obstack_next_free (&frags) - frag_now->fr_literal); + S_SET_SEGMENT (symbolP, now_seg); #ifdef N_UNDF - know(N_UNDF == 0); + know (N_UNDF == 0); #endif /* if we have one, it better be zero. */ - - } else { - /* + + } + else + { + /* * There are still several cases to check: * A .comm/.lcomm symbol being redefined as * initialized data is OK @@ -312,84 +248,94 @@ register char * sym_name; /* symbol name, as a cannonical string */ * This only used to be allowed on VMS gas, but Sun cc * on the sparc also depends on it. */ - /* char New_Type = SEGMENT_TO_SYMBOL_TYPE((int) now_seg); */ + /* char New_Type = SEGMENT_TO_SYMBOL_TYPE((int) now_seg); */ #ifdef MANY_SEGMENTS #define SEG_BSS SEG_E2 #define SEG_DATA SEG_E1 #endif - - if (((!S_IS_DEBUG(symbolP) && !S_IS_DEFINED(symbolP) && S_IS_EXTERNAL(symbolP)) - || (S_GET_SEGMENT(symbolP) == SEG_BSS)) - && ((now_seg == SEG_DATA) - || (now_seg == S_GET_SEGMENT(symbolP)))) { - /* + + if (((!S_IS_DEBUG (symbolP) && !S_IS_DEFINED (symbolP) && S_IS_EXTERNAL (symbolP)) + || (S_GET_SEGMENT (symbolP) == SEG_BSS)) + && ((now_seg == SEG_DATA) + || (now_seg == S_GET_SEGMENT (symbolP)))) + { + /* * Select which of the 2 cases this is */ - if (now_seg != SEG_DATA) { - /* + if (now_seg != SEG_DATA) + { + /* * New .comm for prev .comm symbol. * If the new size is larger we just * change its value. If the new size * is smaller, we ignore this symbol */ - if (S_GET_VALUE(symbolP) - < ((unsigned) (obstack_next_free(& frags) - frag_now->fr_literal))) { - S_SET_VALUE(symbolP, - obstack_next_free(& frags) - - frag_now->fr_literal); - } - } else { - /* + if (S_GET_VALUE (symbolP) + < ((unsigned) (obstack_next_free (&frags) - frag_now->fr_literal))) + { + S_SET_VALUE (symbolP, + obstack_next_free (&frags) - + frag_now->fr_literal); + } + } + else + { + /* * It is a .comm/.lcomm being converted * to initialized data. */ - symbolP->sy_frag = frag_now; + symbolP->sy_frag = frag_now; #ifdef VMS - symbolP->sy_other = const_flag; + symbolP->sy_other = const_flag; #endif /* VMS */ - S_SET_VALUE(symbolP, obstack_next_free(& frags) - frag_now->fr_literal); - S_SET_SEGMENT(symbolP, now_seg); /* keep N_EXT bit */ - } - } else { + S_SET_VALUE (symbolP, obstack_next_free (&frags) - frag_now->fr_literal); + S_SET_SEGMENT (symbolP, now_seg); /* keep N_EXT bit */ + } + } + else + { #ifdef OBJ_COFF - as_fatal("Symbol \"%s\" is already defined as \"%s\"/%d.", - sym_name, - segment_name(S_GET_SEGMENT(symbolP)), - S_GET_VALUE(symbolP)); + as_fatal ("Symbol \"%s\" is already defined as \"%s\"/%d.", + sym_name, + segment_name (S_GET_SEGMENT (symbolP)), + S_GET_VALUE (symbolP)); #else /* OBJ_COFF */ - as_fatal("Symbol \"%s\" is already defined as \"%s\"/%d.%d.%d.", - sym_name, - segment_name(S_GET_SEGMENT(symbolP)), - S_GET_OTHER(symbolP), S_GET_DESC(symbolP), - S_GET_VALUE(symbolP)); + as_fatal ("Symbol \"%s\" is already defined as \"%s\"/%d.%d.%d.", + sym_name, + segment_name (S_GET_SEGMENT (symbolP)), + S_GET_OTHER (symbolP), S_GET_DESC (symbolP), + S_GET_VALUE (symbolP)); #endif /* OBJ_COFF */ - } - } /* if the undefined symbol has no value */ - } else - { - /* Don't blow up if the definition is the same */ - if (!(frag_now == symbolP->sy_frag - && S_GET_VALUE(symbolP) == obstack_next_free(&frags) - frag_now->fr_literal - && S_GET_SEGMENT(symbolP) == now_seg) ) - as_fatal("Symbol %s already defined.", sym_name); - } /* if this symbol is not yet defined */ - - } else { - symbolP = symbol_new(sym_name, - now_seg, - (valueT)(obstack_next_free(&frags)-frag_now->fr_literal), - frag_now); + } + } /* if the undefined symbol has no value */ + } + else + { + /* Don't blow up if the definition is the same */ + if (!(frag_now == symbolP->sy_frag + && S_GET_VALUE (symbolP) == obstack_next_free (&frags) - frag_now->fr_literal + && S_GET_SEGMENT (symbolP) == now_seg)) + as_fatal ("Symbol %s already defined.", sym_name); + } /* if this symbol is not yet defined */ + + } + else + { + symbolP = symbol_new (sym_name, + now_seg, + (valueT) (obstack_next_free (&frags) - frag_now->fr_literal), + frag_now); #ifdef VMS - S_SET_OTHER(symbolP, const_flag); + S_SET_OTHER (symbolP, const_flag); #endif /* VMS */ - - symbol_table_insert(symbolP); - } /* if we have seen this symbol before */ - - return; -} /* colon() */ + symbol_table_insert (symbolP); + } /* if we have seen this symbol before */ + + return; +} /* colon() */ + /* * symbol_table_insert() * @@ -397,19 +343,21 @@ register char * sym_name; /* symbol name, as a cannonical string */ * */ -void symbol_table_insert(symbolP) -symbolS *symbolP; +void +symbol_table_insert (symbolP) + symbolS *symbolP; { - register char *error_string; - - know(symbolP); - know(S_GET_NAME(symbolP)); - - if (*(error_string = hash_jam(sy_hash, S_GET_NAME(symbolP), (char *)symbolP))) { - as_fatal("Inserting \"%s\" into symbol table failed: %s", - S_GET_NAME(symbolP), error_string); - } /* on error */ -} /* symbol_table_insert() */ + register char *error_string; + + know (symbolP); + know (S_GET_NAME (symbolP)); + + if (*(error_string = hash_jam (sy_hash, S_GET_NAME (symbolP), (char *) symbolP))) + { + as_fatal ("Inserting \"%s\" into symbol table failed: %s", + S_GET_NAME (symbolP), error_string); + } /* on error */ +} /* symbol_table_insert() */ /* * symbol_find_or_make() @@ -417,65 +365,72 @@ symbolS *symbolP; * If a symbol name does not exist, create it as undefined, and insert * it into the symbol table. Return a pointer to it. */ -symbolS *symbol_find_or_make(name) -char *name; +symbolS * +symbol_find_or_make (name) + char *name; { - register symbolS *symbolP; - - symbolP = symbol_find(name); - - if (symbolP == NULL) { - symbolP = symbol_make(name); - - symbol_table_insert(symbolP); - } /* if symbol wasn't found */ - - return(symbolP); -} /* symbol_find_or_make() */ - -symbolS *symbol_make(name) -char *name; + register symbolS *symbolP; + + symbolP = symbol_find (name); + + if (symbolP == NULL) + { + symbolP = symbol_make (name); + + symbol_table_insert (symbolP); + } /* if symbol wasn't found */ + + return (symbolP); +} /* symbol_find_or_make() */ + +symbolS * +symbol_make (name) + char *name; { - symbolS *symbolP; - - /* Let the machine description default it, e.g. for register names. */ - symbolP = md_undefined_symbol(name); - - if (!symbolP) { - symbolP = symbol_new(name, - SEG_UNKNOWN, - 0, - &zero_address_frag); - } /* if md didn't build us a symbol */ - - return(symbolP); -} /* symbol_make() */ + symbolS *symbolP; + + /* Let the machine description default it, e.g. for register names. */ + symbolP = md_undefined_symbol (name); + + if (!symbolP) + { + symbolP = symbol_new (name, + SEG_UNKNOWN, + 0, + &zero_address_frag); + } /* if md didn't build us a symbol */ + + return (symbolP); +} /* symbol_make() */ /* * symbol_find() - * + * * Implement symbol table lookup. * In: A symbol's name as a string: '\0' can't be part of a symbol name. * Out: NULL if the name was not in the symbol table, else the address * of a struct symbol associated with that name. */ -symbolS *symbol_find(name) -char *name; +symbolS * +symbol_find (name) + char *name; { #ifdef STRIP_UNDERSCORE - return(symbol_find_base(name, 1)); + return (symbol_find_base (name, 1)); #else /* STRIP_UNDERSCORE */ - return(symbol_find_base(name, 0)); + return (symbol_find_base (name, 0)); #endif /* STRIP_UNDERSCORE */ -} /* symbol_find() */ +} /* symbol_find() */ -symbolS *symbol_find_base(name, strip_underscore) -char *name; -int strip_underscore; +symbolS * +symbol_find_base (name, strip_underscore) + char *name; + int strip_underscore; { - if(strip_underscore && *name == '_') name++; - return ( (symbolS *) hash_find( sy_hash, name )); + if (strip_underscore && *name == '_') + name++; + return ((symbolS *) hash_find (sy_hash, name)); } /* @@ -487,162 +442,540 @@ int strip_underscore; */ /* Link symbol ADDME after symbol TARGET in the chain. */ -void symbol_append(addme, target, rootPP, lastPP) -symbolS *addme; -symbolS *target; -symbolS **rootPP; -symbolS **lastPP; +void +symbol_append (addme, target, rootPP, lastPP) + symbolS *addme; + symbolS *target; + symbolS **rootPP; + symbolS **lastPP; { - if (target == NULL) { - know(*rootPP == NULL); - know(*lastPP == NULL); - *rootPP = addme; - *lastPP = addme; - return; - } /* if the list is empty */ - - if (target->sy_next != NULL) { + if (target == NULL) + { + know (*rootPP == NULL); + know (*lastPP == NULL); + *rootPP = addme; + *lastPP = addme; + return; + } /* if the list is empty */ + + if (target->sy_next != NULL) + { #ifdef SYMBOLS_NEED_BACKPOINTERS - target->sy_next->sy_previous = addme; + target->sy_next->sy_previous = addme; #endif /* SYMBOLS_NEED_BACKPOINTERS */ - } else { - know(*lastPP == target); - *lastPP = addme; - } /* if we have a next */ - - addme->sy_next = target->sy_next; - target->sy_next = addme; - + } + else + { + know (*lastPP == target); + *lastPP = addme; + } /* if we have a next */ + + addme->sy_next = target->sy_next; + target->sy_next = addme; + #ifdef SYMBOLS_NEED_BACKPOINTERS - addme->sy_previous = target; + addme->sy_previous = target; #endif /* SYMBOLS_NEED_BACKPOINTERS */ - + #ifdef DEBUG - /* verify_symbol_chain(*rootPP, *lastPP); */ + /* verify_symbol_chain(*rootPP, *lastPP); */ #endif /* DEBUG */ - - return; -} /* symbol_append() */ + + return; +} /* symbol_append() */ #ifdef SYMBOLS_NEED_BACKPOINTERS /* Remove SYMBOLP from the list. */ -void symbol_remove(symbolP, rootPP, lastPP) -symbolS *symbolP; -symbolS **rootPP; -symbolS **lastPP; +void +symbol_remove (symbolP, rootPP, lastPP) + symbolS *symbolP; + symbolS **rootPP; + symbolS **lastPP; { - if (symbolP == *rootPP) { - *rootPP = symbolP->sy_next; - } /* if it was the root */ - - if (symbolP == *lastPP) { - *lastPP = symbolP->sy_previous; - } /* if it was the tail */ - - if (symbolP->sy_next != NULL) { - symbolP->sy_next->sy_previous = symbolP->sy_previous; - } /* if not last */ - - if (symbolP->sy_previous != NULL) { - symbolP->sy_previous->sy_next = symbolP->sy_next; - } /* if not first */ - + if (symbolP == *rootPP) + { + *rootPP = symbolP->sy_next; + } /* if it was the root */ + + if (symbolP == *lastPP) + { + *lastPP = symbolP->sy_previous; + } /* if it was the tail */ + + if (symbolP->sy_next != NULL) + { + symbolP->sy_next->sy_previous = symbolP->sy_previous; + } /* if not last */ + + if (symbolP->sy_previous != NULL) + { + symbolP->sy_previous->sy_next = symbolP->sy_next; + } /* if not first */ + #ifdef DEBUG - verify_symbol_chain(*rootPP, *lastPP); + verify_symbol_chain (*rootPP, *lastPP); #endif /* DEBUG */ - - return; -} /* symbol_remove() */ + + return; +} /* symbol_remove() */ /* Set the chain pointers of SYMBOL to null. */ -void symbol_clear_list_pointers(symbolP) -symbolS *symbolP; +void +symbol_clear_list_pointers (symbolP) + symbolS *symbolP; { - symbolP->sy_next = NULL; - symbolP->sy_previous = NULL; -} /* symbol_clear_list_pointers() */ + symbolP->sy_next = NULL; + symbolP->sy_previous = NULL; +} /* symbol_clear_list_pointers() */ /* Link symbol ADDME before symbol TARGET in the chain. */ -void symbol_insert(addme, target, rootPP, lastPP) -symbolS *addme; -symbolS *target; -symbolS **rootPP; -symbolS **lastPP; +void +symbol_insert (addme, target, rootPP, lastPP) + symbolS *addme; + symbolS *target; + symbolS **rootPP; + symbolS **lastPP; { - if (target->sy_previous != NULL) { - target->sy_previous->sy_next = addme; - } else { - know(*rootPP == target); - *rootPP = addme; - } /* if not first */ - - addme->sy_previous = target->sy_previous; - target->sy_previous = addme; - addme->sy_next = target; - + if (target->sy_previous != NULL) + { + target->sy_previous->sy_next = addme; + } + else + { + know (*rootPP == target); + *rootPP = addme; + } /* if not first */ + + addme->sy_previous = target->sy_previous; + target->sy_previous = addme; + addme->sy_next = target; + #ifdef DEBUG - verify_symbol_chain(*rootPP, *lastPP); + verify_symbol_chain (*rootPP, *lastPP); #endif /* DEBUG */ - - return; -} /* symbol_insert() */ + + return; +} /* symbol_insert() */ + #endif /* SYMBOLS_NEED_BACKPOINTERS */ -void verify_symbol_chain(rootP, lastP) -symbolS *rootP; -symbolS *lastP; +void +verify_symbol_chain (rootP, lastP) + symbolS *rootP; + symbolS *lastP; { - symbolS *symbolP = rootP; - - if (symbolP == NULL) { - return; - } /* empty chain */ - - for ( ; symbol_next(symbolP) != NULL; symbolP = symbol_next(symbolP)) { + symbolS *symbolP = rootP; + + if (symbolP == NULL) + { + return; + } /* empty chain */ + + for (; symbol_next (symbolP) != NULL; symbolP = symbol_next (symbolP)) + { #ifdef SYMBOLS_NEED_BACKPOINTERS - /*$if (symbolP->sy_previous) { + /*$if (symbolP->sy_previous) { know(symbolP->sy_previous->sy_next == symbolP); } else { know(symbolP == rootP); - }$*/ /* both directions */ - know(symbolP->sy_next->sy_previous == symbolP); + }$*//* both directions */ + know (symbolP->sy_next->sy_previous == symbolP); #else /* SYMBOLS_NEED_BACKPOINTERS */ - ; + ; #endif /* SYMBOLS_NEED_BACKPOINTERS */ - } /* verify pointers */ - - know(lastP == symbolP); - - return; -} /* verify_symbol_chain() */ + } /* verify pointers */ + + know (lastP == symbolP); + + return; +} /* verify_symbol_chain() */ + + +#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 + instances of a dollar label. Therefor, we name encode each instance with + the instance number, keep a list of defined symbols separate from the real + symbol table, and we treat these buggers as a sparse array. */ + +static long *dollar_labels = NULL; +static long *dollar_label_instances = NULL; +static char *dollar_label_defines = NULL; +static long dollar_label_count = 0; +static long dollar_label_max = 0; + +int +dollar_label_defined (label) + long label; +{ + long *i; + + know ((dollar_labels != NULL) || (dollar_label_count == 0)); + + for (i = dollar_labels; i < dollar_labels + dollar_label_count; ++i) + { + if (*i == label) + { + return (dollar_label_defines[i - dollar_labels]); + } /* found it */ + } /* look for label */ + + /* if we get here, label isn't defined */ + return (0); +} /* dollar_label_defined() */ + +static int +dollar_label_instance (label) + long label; +{ + long *i; + + know ((dollar_labels != NULL) || (dollar_label_count == 0)); + + for (i = dollar_labels; i < dollar_labels + dollar_label_count; ++i) + { + if (*i == label) + { + return (dollar_label_instances[i - dollar_labels]); + } /* found it */ + } /* look for (the union :-) label */ + + /* if we get here, we haven't seen the label before, therefor it's instance + count is zero. */ + return (0); +} /* dollar_label_instance() */ + +void +dollar_label_clear () +{ + memset (dollar_label_defines, '\0', dollar_label_count); + return; +} /* clear_dollar_labels() */ + +#define DOLLAR_LABEL_BUMP_BY 10 + +void +define_dollar_label (label) + long label; +{ + long *i; + + for (i = dollar_labels; i < dollar_labels + dollar_label_count; ++i) + { + if (*i == label) + { + ++dollar_label_instances[i - dollar_labels]; + dollar_label_defines[i - dollar_labels] = 1; + return; + } /* if we find it */ + } /* for each existing label */ + + /* if we get to here, we don't have label listed yet. */ + + if (dollar_labels == NULL) + { + 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_max = DOLLAR_LABEL_BUMP_BY; + dollar_label_count = 0; + + } + else if (dollar_label_count == dollar_label_max) + { + dollar_label_max += DOLLAR_LABEL_BUMP_BY; + dollar_labels = (long *) xrealloc ((char *) dollar_labels, + 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); + } /* if we needed to grow */ + + dollar_labels[dollar_label_count] = label; + dollar_label_instances[dollar_label_count] = 1; + dollar_label_defines[dollar_label_count] = 1; + ++dollar_label_count; + return; +} /* define_dollar_label() */ + +/* + * dollar_label_name() + * + * Caller must copy returned name: we re-use the area for the next name. + * + * The mth occurence of label n: is turned into the symbol "Ln^Am" where + * n is the label number and m is the instance number. "L" makes it a label discarded + * unless debugging and "^A"('\1') ensures no ordinary symbol SHOULD get the + * same name as a local label symbol. The first "4:" is "L4^A1" - the m + * numbers begin at 1. + * + * fb labels get the same treatment, except that ^B is used in place of ^A. + */ + +char * /* Return local label name. */ +dollar_label_name (n, augend) + register long n; /* we just saw "n$:" : n a number */ + register int augend; /* 0 for current instance, 1 for new instance */ +{ + long i; + /* Returned to caller, then copied. used for created names ("4f") */ + static char symbol_name_build[24]; + register char *p; + register char *q; + char symbol_name_temporary[20]; /* build up a number, BACKWARDS */ + + know (n >= 0); + know (augend == 0 || augend == 1); + p = symbol_name_build; + *p++ = 'L'; + + /* Next code just does sprintf( {}, "%d", n); */ + /* label number */ + q = symbol_name_temporary; + for (*q++ = 0, i = n; i; ++q) + { + *q = i % 10 + '0'; + i /= 10; + } + while ((*p = *--q) != '\0') + ++p; + + *p++ = 1; /* ^A */ + + /* instance number */ + q = symbol_name_temporary; + for (*q++ = 0, i = dollar_label_instance (n) + augend; i; ++q) + { + *q = i % 10 + '0'; + i /= 10; + } + while ((*p++ = *--q) != '\0');; + + /* The label, as a '\0' ended string, starts at symbol_name_build. */ + return (symbol_name_build); +} /* dollar_label_name() */ + +#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 + * "nb" for previous (backward) n: + * or "nf" for next (forward) n:. + * + * We do a little better and let n be any number, not just a single digit, but + * since the other guy's assembler only does ten, we treat the first ten + * specially. + * + * Like someone else's assembler, we have one set of local label counters for + * entire assembly, not one set per (sub)segment like in most assemblers. This + * implies that one can refer to a label in another segment, and indeed some + * crufty compilers have done just that. + * + * Since there could be a LOT of these things, treat them as a sparse array. + */ + +#define FB_LABEL_SPECIAL (10) + +static long fb_low_counter[FB_LABEL_SPECIAL]; +static long *fb_labels; +static long *fb_label_instances; +static long fb_label_count = 0; +static long fb_label_max = 0; + +/* this must be more than FB_LABEL_SPECIAL */ +#define FB_LABEL_BUMP_BY (FB_LABEL_SPECIAL + 6) + +static void +fb_label_init () +{ + memset ((void *) fb_low_counter, '\0', sizeof (fb_low_counter)); + return; +} /* fb_label_init() */ + +/* add one to the instance number of this fb label */ +void +fb_label_instance_inc (label) + long label; +{ + long *i; + + if (label < FB_LABEL_SPECIAL) + { + ++fb_low_counter[label]; + return; + } + + for (i = fb_labels + FB_LABEL_SPECIAL; i < fb_labels + fb_label_count; ++i) + { + if (*i == label) + { + ++fb_label_instances[i - fb_labels]; + return; + } /* if we find it */ + } /* for each existing label */ + + /* if we get to here, we don't have label listed yet. */ + + if (fb_labels == NULL) + { + fb_labels = (long *) xmalloc (FB_LABEL_BUMP_BY * sizeof (long)); + fb_label_instances = (long *) xmalloc (FB_LABEL_BUMP_BY * sizeof (long)); + fb_label_max = FB_LABEL_BUMP_BY; + fb_label_count = FB_LABEL_SPECIAL; + + } + else if (fb_label_count == fb_label_max) + { + fb_label_max += FB_LABEL_BUMP_BY; + fb_labels = (long *) xrealloc ((char *) fb_labels, + fb_label_max * sizeof (long)); + fb_label_instances = (long *) xrealloc ((char *) fb_label_instances, + fb_label_max * sizeof (long)); + } /* if we needed to grow */ + + fb_labels[fb_label_count] = label; + fb_label_instances[fb_label_count] = 1; + ++fb_label_count; + return; +} /* fb_label_instance_inc() */ + +static long +fb_label_instance (label) + long label; +{ + long *i; + + if (label < FB_LABEL_SPECIAL) + { + return (fb_low_counter[label]); + } + + for (i = fb_labels + FB_LABEL_SPECIAL; i < fb_labels + fb_label_count; ++i) + { + if (*i == label) + { + return (fb_label_instances[i - fb_labels]); + } /* if we find it */ + } /* for each existing label */ + + /* NOTREACHED */ + know (0); +} /* fb_label_instance() */ + +/* + * fb_label_name() + * + * Caller must copy returned name: we re-use the area for the next name. + * + * The mth occurence of label n: is turned into the symbol "Ln^Bm" where + * n is the label number and m is the instance number. "L" makes it a label discarded + * unless debugging and "^B"('\2') ensures no ordinary symbol SHOULD get the + * same name as a local label symbol. The first "4:" is "L4^B1" - the m + * numbers begin at 1. + * + * dollar labels get the same treatment, except that ^A is used in place of ^B. + */ + +char * /* Return local label name. */ +fb_label_name (n, augend) + long n; /* we just saw "n:", "nf" or "nb" : n a number */ + long augend; /* 0 for nb, 1 for n:, nf */ +{ + long i; + /* Returned to caller, then copied. used for created names ("4f") */ + static char symbol_name_build[24]; + register char *p; + register char *q; + char symbol_name_temporary[20]; /* build up a number, BACKWARDS */ + + know (n >= 0); + know (augend == 0 || augend == 1); + p = symbol_name_build; + *p++ = 'L'; + + /* Next code just does sprintf( {}, "%d", n); */ + /* label number */ + q = symbol_name_temporary; + for (*q++ = 0, i = n; i; ++q) + { + *q = i % 10 + '0'; + i /= 10; + } + while ((*p = *--q) != '\0') + ++p; + + *p++ = 2; /* ^B */ + + /* instance number */ + q = symbol_name_temporary; + for (*q++ = 0, i = fb_label_instance (n) + augend; i; ++q) + { + *q = i % 10 + '0'; + i /= 10; + } + while ((*p++ = *--q) != '\0');; + + /* The label, as a '\0' ended string, starts at symbol_name_build. */ + return (symbol_name_build); +} /* fb_label_name() */ + +#endif /* LOCAL_LABELS_FB */ /* - * decode name that may have been generated by local_label_name() above. If - * the name wasn't generated by local_label_name(), then return it unaltered. + * 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. * This is used for error messages. */ -char *decode_local_label_name(s) -char *s; +char * +decode_local_label_name (s) + char *s; { - char *symbol_decode; - int label_number; - /* int label_version; */ - char *message_format = "\"%d\" (instance number %s of a local label)"; - - if (s[0] != 'L' - || s[2] != 1) { - return(s); - } /* not a local_label_name() generated name. */ - - label_number = s[1] - '0'; - - (void) sprintf(symbol_decode = obstack_alloc(¬es, strlen(s + 3) + strlen(message_format) + 10), - message_format, label_number, s + 3); - - return(symbol_decode); -} /* decode_local_label_name() */ + char *p; + char *symbol_decode; + int label_number; + int instance_number; + char *type; + const char *message_format = "\"%d\" (instance number %d of a %s label)"; + + if (s[0] != 'L') + return (s); + + for (label_number = 0, p = s + 1; isdigit (*p); ++p) + { + label_number = (10 * label_number) + *p - '0'; + } + + if (*p == 1) + { + type = "dollar"; + } + else if (*p == 2) + { + type = "fb"; + } + else + { + return (s); + } + + for (instance_number = 0, p = s + 1; 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); + + return (symbol_decode); +} /* decode_local_label_name() */ /* diff --git a/gas/symbols.h b/gas/symbols.h index 37db8a0..e1e7c7d 100644 --- a/gas/symbols.h +++ b/gas/symbols.h @@ -1,71 +1,92 @@ /* symbols.h - Copyright (C) 1987, 1990, 1992 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. */ -/* $Id$ */ - -extern struct obstack notes; /* eg FixS live here. */ +extern struct obstack notes; /* eg FixS live here. */ -extern struct obstack cond_obstack; /* this is where we track .ifdef/.endif +extern struct obstack cond_obstack; /* this is where we track .ifdef/.endif (if we do that at all). */ -extern unsigned int local_bss_counter; /* Zeroed before a pass. */ +extern unsigned int local_bss_counter; /* Zeroed before a pass. */ /* Only used by .lcomm directive. */ -extern symbolS * symbol_rootP; /* all the symbol nodes */ -extern symbolS * symbol_lastP; /* last struct symbol we made, or NULL */ +extern symbolS *symbol_rootP; /* all the symbol nodes */ +extern symbolS *symbol_lastP; /* last struct symbol we made, or NULL */ -extern symbolS abs_symbol; +extern symbolS abs_symbol; -extern symbolS* dot_text_symbol; -extern symbolS* dot_data_symbol; -extern symbolS* dot_bss_symbol; +extern symbolS *dot_text_symbol; +extern symbolS *dot_data_symbol; +extern symbolS *dot_bss_symbol; #if __STDC__ == 1 -char *decode_local_label_name(char *s); -char *local_label_name(int n, int augend); -symbolS *symbol_find(char *name); -symbolS *symbol_find_base(char *name, int strip_underscore); -symbolS *symbol_find_or_make(char *name); -symbolS *symbol_make(char *name); -symbolS *symbol_new(char *name, segT segment, long value, fragS *frag); -void colon(char *sym_name); -void local_colon(int n); -void symbol_begin(void); -void symbol_table_insert(symbolS *symbolP); -void verify_symbol_chain(symbolS *rootP, symbolS *lastP); +char *decode_local_label_name (char *s); +symbolS *symbol_find (char *name); +symbolS *symbol_find_base (char *name, int strip_underscore); +symbolS *symbol_find_or_make (char *name); +symbolS *symbol_make (char *name); +symbolS *symbol_new (char *name, segT segment, long value, fragS * frag); +void colon (char *sym_name); +void local_colon (int n); +void symbol_begin (void); +void symbol_table_insert (symbolS * symbolP); +void verify_symbol_chain (symbolS * rootP, symbolS * lastP); + +#ifdef LOCAL_LABELS_DOLLAR +int dollar_label_defined (long l); +void dollar_label_clear (void); +void define_dollar_label (long l); +char *dollar_label_name (long l, int augend); +#endif /* LOCAL_LABELS_DOLLAR */ + +#ifdef LOCAL_LABELS_FB +void fb_label_instance_inc (long label); +char *fb_label_name (long n, long augend); +#endif /* LOCAL_LABELS_FB */ #else /* not __STDC__ */ -char *decode_local_label_name(); -char *local_label_name(); -symbolS *symbol_find(); -symbolS *symbol_find_base(); -symbolS *symbol_find_or_make(); -symbolS *symbol_make(); -symbolS *symbol_new(); -void colon(); -void local_colon(); -void symbol_begin(); -void symbol_table_insert(); -void verify_symbol_chain(); +char *decode_local_label_name (); +char *fb_label_name (); +symbolS *symbol_find (); +symbolS *symbol_find_base (); +symbolS *symbol_find_or_make (); +symbolS *symbol_make (); +symbolS *symbol_new (); +void colon (); +void local_colon (); +void symbol_begin (); +void symbol_table_insert (); +void verify_symbol_chain (); + +#ifdef LOCAL_LABELS_DOLLAR +int dollar_label_defined (); +void dollar_label_clear (); +void define_dollar_label (); +char *dollar_label_name (); +#endif /* LOCAL_LABELS_DOLLAR */ + +#ifdef LOCAL_LABELS_FB +void fb_label_instance_inc (); +char *fb_label_name (); +#endif /* LOCAL_LABELS_FB */ #endif /* not __STDC__ */ @@ -1,19 +1,19 @@ -/* tc.h -target cpu dependent- */ +/* tc.h - target cpu dependent + + Copyright (C) 1987, 1990, 1991, 1992 Free Software Foundation, Inc. -/* Copyright (C) 1987, 1990, 1991 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. */ @@ -28,72 +28,73 @@ extern const pseudo_typeS md_pseudo_table[]; typedef struct { - long rlx_forward; /* Forward reach. Signed number. > 0. */ - long rlx_backward; /* Backward reach. Signed number. < 0. */ - unsigned char rlx_length; /* Bytes length of this address. */ - relax_substateT rlx_more; /* Next longer relax-state. */ - /* 0 means there is no 'next' relax-state. */ + long rlx_forward; /* Forward reach. Signed number. > 0. */ + long rlx_backward; /* Backward reach. Signed number. < 0. */ + unsigned char rlx_length; /* Bytes length of this address. */ + relax_substateT rlx_more; /* Next longer relax-state. */ + /* 0 means there is no 'next' relax-state. */ } + relax_typeS; -extern const relax_typeS md_relax_table[]; /* Define it in MACHINE.c */ +extern const relax_typeS md_relax_table[]; /* Define it in MACHINE.c */ -extern int md_reloc_size; /* Size of a relocation record */ +extern int md_reloc_size; /* Size of a relocation record */ -extern void (*md_emit_relocations)(); +extern void (*md_emit_relocations) (); -#ifdef __STDC__ +#if __STDC__ == 1 -char *md_atof(int what_statement_type, char *literalP, int *sizeP); -int md_estimate_size_before_relax(fragS *fragP, segT segment); -int md_parse_option(char **argP, int *cntP, char ***vecP); -long md_pcrel_from(fixS *fixP); -long md_section_align(segT seg, long align); -short tc_coff_fix2rtype(fixS *fixP); -symbolS *md_undefined_symbol(char *name); -void md_apply_fix(fixS *fixP, long val); -void md_assemble(char *str); -void md_begin(void); -void md_convert_frag(object_headers *headers, fragS *fragP); -void md_create_long_jump(char *ptr, long from_addr, long to_addr, fragS *frag, symbolS *to_symbol); -void md_create_short_jump(char *ptr, long from_addr, long to_addr, fragS *frag, symbolS *to_symbol); -void md_end(void); -void md_number_to_chars(char *buf, long val, int n); -void md_operand(expressionS *expressionP); +char *md_atof (int what_statement_type, char *literalP, int *sizeP); +int md_estimate_size_before_relax (fragS * fragP, segT segment); +int md_parse_option (char **argP, int *cntP, char ***vecP); +long md_pcrel_from (fixS * fixP); +long md_section_align (segT seg, long align); +short tc_coff_fix2rtype (fixS * fixP); +symbolS *md_undefined_symbol (char *name); +void md_apply_fix (fixS * fixP, long val); +void md_assemble (char *str); +void md_begin (void); +void md_convert_frag (object_headers * headers, fragS * fragP); +void md_create_long_jump (char *ptr, long from_addr, long to_addr, fragS * frag, symbolS * to_symbol); +void md_create_short_jump (char *ptr, long from_addr, long to_addr, fragS * frag, symbolS * to_symbol); +void md_end (void); +void md_number_to_chars (char *buf, long val, int n); +void md_operand (expressionS * expressionP); #ifndef tc_crawl_symbol_chain -void tc_crawl_symbol_chain(object_headers *headers); +void tc_crawl_symbol_chain (object_headers * headers); #endif /* tc_crawl_symbol_chain */ #ifndef tc_headers_hook -void tc_headers_hook(object_headers *headers); +void tc_headers_hook (object_headers * headers); #endif /* tc_headers_hook */ #else -char *md_atof(); -int md_estimate_size_before_relax(); -int md_parse_option(); -long md_pcrel_from(); -long md_section_align(); -short tc_coff_fix2rtype(); -symbolS *md_undefined_symbol(); -void md_apply_fix(); -void md_assemble(); -void md_begin(); -void md_convert_frag(); -void md_create_long_jump(); -void md_create_short_jump(); -void md_end(); -void md_number_to_chars(); -void md_operand(); +char *md_atof (); +int md_estimate_size_before_relax (); +int md_parse_option (); +long md_pcrel_from (); +long md_section_align (); +short tc_coff_fix2rtype (); +symbolS *md_undefined_symbol (); +void md_apply_fix (); +void md_assemble (); +void md_begin (); +void md_convert_frag (); +void md_create_long_jump (); +void md_create_short_jump (); +void md_end (); +void md_number_to_chars (); +void md_operand (); #ifndef tc_headers_hook -void tc_headers_hook(); +void tc_headers_hook (); #endif /* tc_headers_hook */ #ifndef tc_crawl_symbol_chain -void tc_crawl_symbol_chain(); +void tc_crawl_symbol_chain (); #endif /* tc_crawl_symbol_chain */ #endif /* __STDC_ */ diff --git a/gas/version.c b/gas/version.c index cc2cf98..88f0da3 100644 --- a/gas/version.c +++ b/gas/version.c @@ -1,20 +1,21 @@ /* DO NOT PUT COMMENTS ABOUT CHANGES IN THIS FILE. - + This file exists only to define `version_string'. - + Log changes in ChangeLog. The easiest way to do this is with the Emacs command `add-change-log-entry'. If you don't use Emacs, add entries of the form: - + Thu Jan 1 00:00:00 1970 Dennis Ritchie (dmr at alice) - + universe.c (temporal_reality): Began Time. */ #ifdef VMS -dummy3() +dummy3 () { } + #endif #if (__STDC__ == 1) || defined(const) diff --git a/gas/write.c b/gas/write.c index d7d876d..4a754f4 100644 --- a/gas/write.c +++ b/gas/write.c @@ -1,19 +1,19 @@ /* write.c - emit .o file Copyright (C) 1986, 1987, 1990, 1991, 1992 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. */ @@ -53,113 +53,117 @@ char *next_object_file_charP; /* Tracks object file bytes. */ int magic_number_for_object_file = DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE; -static int is_dnrange PARAMS ((struct frag *f1, struct frag *f2)); -static long fixup_segment PARAMS ((fixS *fixP, segT this_segment_type)); +static int is_dnrange PARAMS ((struct frag * f1, struct frag * f2)); +static long fixup_segment PARAMS ((fixS * fixP, segT this_segment_type)); static relax_addressT relax_align PARAMS ((relax_addressT addr, long align)); -void relax_segment PARAMS ((struct frag *seg_frag_root, segT seg_type)); +void relax_segment PARAMS ((struct frag * seg_frag_root, segT seg_type)); /* * fix_new() * * Create a fixS in obstack 'notes'. */ -fixS *fix_new(frag, where, size, add_symbol, sub_symbol, offset, pcrel, r_type) -fragS *frag; /* Which frag? */ -int where; /* Where in that frag? */ -short int size; /* 1, 2, or 4 usually. */ -symbolS *add_symbol; /* X_add_symbol. */ -symbolS *sub_symbol; /* X_subtract_symbol. */ -long offset; /* X_add_number. */ -int pcrel; /* TRUE if PC-relative relocation. */ -int r_type; /* Relocation type */ +fixS * +fix_new (frag, where, size, add_symbol, sub_symbol, offset, pcrel, r_type) + fragS *frag; /* Which frag? */ + int where; /* Where in that frag? */ + short int size; /* 1, 2, or 4 usually. */ + symbolS *add_symbol; /* X_add_symbol. */ + symbolS *sub_symbol; /* X_subtract_symbol. */ + long offset; /* X_add_number. */ + int pcrel; /* TRUE if PC-relative relocation. */ + int r_type; /* Relocation type */ { - fixS *fixP; - - fixP = (fixS *) obstack_alloc(¬es, sizeof(fixS)); - - fixP->fx_frag = frag; - fixP->fx_where = where; - fixP->fx_size = size; - fixP->fx_addsy = add_symbol; - fixP->fx_subsy = sub_symbol; - fixP->fx_offset = offset; - fixP->fx_pcrel = pcrel; + fixS *fixP; + + fixP = (fixS *) obstack_alloc (¬es, sizeof (fixS)); + + fixP->fx_frag = frag; + fixP->fx_where = where; + fixP->fx_size = size; + fixP->fx_addsy = add_symbol; + fixP->fx_subsy = sub_symbol; + fixP->fx_offset = offset; + fixP->fx_pcrel = pcrel; #if defined(TC_SPARC) || defined(TC_A29K) || defined( NEED_FX_R_TYPE) - fixP->fx_r_type = r_type; + fixP->fx_r_type = r_type; #endif - /* JF these 'cuz of the NS32K stuff */ - fixP->fx_im_disp = 0; - fixP->fx_pcrel_adjust = 0; - fixP->fx_bsr = 0; - fixP->fx_bit_fixP = 0; - - /* usually, we want relocs sorted numerically, but while + /* JF these 'cuz of the NS32K stuff */ + fixP->fx_im_disp = 0; + fixP->fx_pcrel_adjust = 0; + fixP->fx_bsr = 0; + fixP->fx_bit_fixP = 0; + + /* usually, we want relocs sorted numerically, but while comparing to older versions of gas that have relocs reverse sorted, it is convenient to have this compile time option. xoxorich. */ #ifdef REVERSE_SORT_RELOCS - - fixP->fx_next = *seg_fix_rootP; - *seg_fix_rootP = fixP; - + + fixP->fx_next = *seg_fix_rootP; + *seg_fix_rootP = fixP; + #else /* REVERSE_SORT_RELOCS */ - - fixP->fx_next = NULL; - - if (*seg_fix_tailP) - (*seg_fix_tailP)->fx_next = fixP; - else - *seg_fix_rootP = fixP; - *seg_fix_tailP = fixP; - + + fixP->fx_next = NULL; + + if (*seg_fix_tailP) + (*seg_fix_tailP)->fx_next = fixP; + else + *seg_fix_rootP = fixP; + *seg_fix_tailP = fixP; + #endif /* REVERSE_SORT_RELOCS */ - - fixP->fx_callj = 0; - return(fixP); -} /* fix_new() */ + + fixP->fx_callj = 0; + return (fixP); +} /* fix_new() */ #ifndef BFD -void remove_subsegs(head, seg, root, last) -frchainS *head; -int seg; -fragS **root; -fragS ** last; +void +remove_subsegs (head, seg, root, last) + frchainS *head; + int seg; + fragS **root; + fragS **last; { fragS dummy; - fragS * prev_frag = &dummy; + fragS *prev_frag = &dummy; *root = head->frch_root; - while (head && head->frch_seg == seg) - { - prev_frag->fr_next = head->frch_root; + while (head && head->frch_seg == seg) + { + prev_frag->fr_next = head->frch_root; - prev_frag = head->frch_last; - head = head->frch_next; - } + prev_frag = head->frch_last; + head = head->frch_next; + } *last = prev_frag; prev_frag->fr_next = 0; } -void write_object_file() + +void +write_object_file () { - register struct frchain * frchainP; /* Track along all frchains. */ - register fragS * fragP; /* Track along all frags. */ - register struct frchain * next_frchainP; - register fragS * * prev_fragPP; - unsigned int data_siz; - - long object_file_size; - + register struct frchain *frchainP; /* Track along all frchains. */ + register fragS *fragP; /* Track along all frags. */ + register struct frchain *next_frchainP; + register fragS **prev_fragPP; + unsigned int data_siz; + + long object_file_size; + #ifdef VMS - /* + /* * Under VMS we try to be compatible with VAX-11 "C". Thus, we * call a routine to check for the definition of the procedure * "_main", and if so -- fix it up so that it can be program * entry point. */ - VMS_Check_For_Main(); + VMS_Check_For_Main (); #endif /* VMS */ - /* + /* * After every sub-segment, we fake an ".align ...". This conforms to * BSD4.2 brane-damage. We then fake ".fill 0" because that is the * kind of frag that requires least thought. ".align" frags like to @@ -167,9 +171,10 @@ void write_object_file() * length trivial. */ #define SUB_SEGMENT_ALIGN (2) - for (frchainP = frchain_root; frchainP; frchainP = frchainP->frch_next) { + for (frchainP = frchain_root; frchainP; frchainP = frchainP->frch_next) + { #ifdef VMS - /* + /* * Under VAX/VMS, the linker (and PSECT specifications) * take care of correctly aligning the segments. * Doing the alignment here (on initialized data) can @@ -177,136 +182,144 @@ void write_object_file() */ #undef SUB_SEGMENT_ALIGN #define SUB_SEGMENT_ALIGN ((frchainP->frch_seg != SEG_DATA) ? 2 : 0) -#endif /* VMS */ - subseg_new (frchainP->frch_seg, frchainP->frch_subseg); - frag_align (SUB_SEGMENT_ALIGN, NOP_OPCODE); - /* frag_align will have left a new frag. */ - /* Use this last frag for an empty ".fill". */ - /* +#endif /* VMS */ + subseg_new (frchainP->frch_seg, frchainP->frch_subseg); + frag_align (SUB_SEGMENT_ALIGN, NOP_OPCODE); + /* frag_align will have left a new frag. */ + /* Use this last frag for an empty ".fill". */ + /* * For this segment ... * Create a last frag. Do not leave a "being filled in frag". */ - frag_wane (frag_now); - frag_now->fr_fix = 0; - know( frag_now->fr_next == NULL ); - /* know( frags . obstack_c_base == frags . obstack_c_next_free ); */ - /* Above shows we haven't left a half-completed object on obstack. */ - } /* walk the frag chain */ - - /* + frag_wane (frag_now); + frag_now->fr_fix = 0; + know (frag_now->fr_next == NULL); + /* know( frags . obstack_c_base == frags . obstack_c_next_free ); */ + /* Above shows we haven't left a half-completed object on obstack. */ + } /* walk the frag chain */ + + /* * From now on, we don't care about sub-segments. * Build one frag chain for each segment. Linked thru fr_next. * We know that there is at least 1 text frchain & at least 1 data * frchain. */ - remove_subsegs(frchain_root, SEG_TEXT, &text_frag_root, &text_last_frag); - remove_subsegs(data0_frchainP, SEG_DATA, &data_frag_root, &data_last_frag); - remove_subsegs(bss0_frchainP, SEG_BSS, &bss_frag_root, &bss_last_frag); - - /* + remove_subsegs (frchain_root, SEG_TEXT, &text_frag_root, &text_last_frag); + remove_subsegs (data0_frchainP, SEG_DATA, &data_frag_root, &data_last_frag); + remove_subsegs (bss0_frchainP, SEG_BSS, &bss_frag_root, &bss_last_frag); + + /* * We have two segments. If user gave -R flag, then we must put the * data frags into the text segment. Do this before relaxing so * we know to take advantage of -R and make shorter addresses. */ #ifndef OBJ_AOUT - if (flagseen[ 'R' ]) { - fixS *tmp; - - text_last_frag->fr_next = data_frag_root; - text_last_frag = data_last_frag; - data_last_frag = NULL; - data_frag_root = NULL; - if (text_fix_root) { - for (tmp = text_fix_root; tmp->fx_next; tmp = tmp->fx_next) ;; - tmp->fx_next=data_fix_root; - text_fix_tail = data_fix_tail; - } else - text_fix_root=data_fix_root; - data_fix_root=NULL; + if (flagseen['R']) + { + fixS *tmp; + + text_last_frag->fr_next = data_frag_root; + text_last_frag = data_last_frag; + data_last_frag = NULL; + data_frag_root = NULL; + if (text_fix_root) + { + for (tmp = text_fix_root; tmp->fx_next; tmp = tmp->fx_next);; + tmp->fx_next = data_fix_root; + text_fix_tail = data_fix_tail; } -#endif - relax_segment(text_frag_root, SEG_TEXT); - relax_segment(data_frag_root, SEG_DATA); - relax_segment(bss_frag_root, SEG_BSS); - /* + else + text_fix_root = data_fix_root; + data_fix_root = NULL; + } +#endif + relax_segment (text_frag_root, SEG_TEXT); + relax_segment (data_frag_root, SEG_DATA); + relax_segment (bss_frag_root, SEG_BSS); + /* * Now the addresses of frags are correct within the segment. */ - - know(text_last_frag->fr_type == rs_fill && text_last_frag->fr_offset == 0); - H_SET_TEXT_SIZE(&headers, text_last_frag->fr_address); - text_last_frag->fr_address = H_GET_TEXT_SIZE(&headers); - - /* + + know (text_last_frag->fr_type == rs_fill && text_last_frag->fr_offset == 0); + H_SET_TEXT_SIZE (&headers, text_last_frag->fr_address); + text_last_frag->fr_address = H_GET_TEXT_SIZE (&headers); + + /* * Join the 2 segments into 1 huge segment. * To do this, re-compute every rn_address in the SEG_DATA frags. * Then join the data frags after the text frags. * * Determine a_data [length of data segment]. */ - if (data_frag_root) { - register relax_addressT slide; - - know((text_last_frag->fr_type == rs_fill) && (text_last_frag->fr_offset == 0)); - - H_SET_DATA_SIZE(&headers, data_last_frag->fr_address); - data_last_frag->fr_address = H_GET_DATA_SIZE(&headers); - slide = H_GET_TEXT_SIZE(&headers); /* & in file of the data segment. */ + if (data_frag_root) + { + register relax_addressT slide; + + know ((text_last_frag->fr_type == rs_fill) && (text_last_frag->fr_offset == 0)); + + H_SET_DATA_SIZE (&headers, data_last_frag->fr_address); + data_last_frag->fr_address = H_GET_DATA_SIZE (&headers); + slide = H_GET_TEXT_SIZE (&headers); /* & in file of the data segment. */ #ifdef OBJ_BOUT #define RoundUp(N,S) (((N)+(S)-1)&-(S)) - /* For b.out: If the data section has a strict alignment + /* For b.out: If the data section has a strict alignment requirement, its load address in the .o file will be rounded up from the size of the text section. These two values are *not* the same! Similarly for the bss section.... */ - slide = RoundUp (slide, 1 << section_alignment[SEG_DATA]); + slide = RoundUp (slide, 1 << section_alignment[SEG_DATA]); #endif - for (fragP = data_frag_root; fragP; fragP = fragP->fr_next) { - fragP->fr_address += slide; - } /* for each data frag */ - - know(text_last_frag != 0); - text_last_frag->fr_next = data_frag_root; - } else { - H_SET_DATA_SIZE(&headers,0); - data_siz = 0; - } + for (fragP = data_frag_root; fragP; fragP = fragP->fr_next) + { + fragP->fr_address += slide; + } /* for each data frag */ + + know (text_last_frag != 0); + text_last_frag->fr_next = data_frag_root; + } + else + { + H_SET_DATA_SIZE (&headers, 0); + data_siz = 0; + } #ifdef OBJ_BOUT - /* See above comments on b.out data section address. */ - { - long bss_vma; - if (data_last_frag == 0) - bss_vma = H_GET_TEXT_SIZE (&headers); - else - bss_vma = data_last_frag->fr_address; - bss_vma = RoundUp (bss_vma, 1 << section_alignment[SEG_BSS]); - bss_address_frag.fr_address = bss_vma; - } + /* See above comments on b.out data section address. */ + { + long bss_vma; + if (data_last_frag == 0) + bss_vma = H_GET_TEXT_SIZE (&headers); + else + bss_vma = data_last_frag->fr_address; + bss_vma = RoundUp (bss_vma, 1 << section_alignment[SEG_BSS]); + bss_address_frag.fr_address = bss_vma; + } #else - bss_address_frag.fr_address = (H_GET_TEXT_SIZE(&headers) + - H_GET_DATA_SIZE(&headers)); + bss_address_frag.fr_address = (H_GET_TEXT_SIZE (&headers) + + H_GET_DATA_SIZE (&headers)); + + /* Slide all the frags */ + if (bss_frag_root) + { + relax_addressT slide = bss_address_frag.fr_address + local_bss_counter; - /* Slide all the frags */ - if (bss_frag_root) + for (fragP = bss_frag_root; fragP; fragP = fragP->fr_next) { - relax_addressT slide = bss_address_frag.fr_address + local_bss_counter; + fragP->fr_address += slide; + } /* for each bss frag */ + } - for (fragP = bss_frag_root; fragP; fragP = fragP->fr_next) - { - fragP->fr_address += slide; - } /* for each bss frag */ - } +#endif + if (bss_last_frag) + { + local_bss_counter += bss_last_frag->fr_address - bss_frag_root->fr_address; + } + H_SET_BSS_SIZE (&headers, local_bss_counter); -#endif -if(bss_last_frag) { -local_bss_counter += bss_last_frag->fr_address - bss_frag_root->fr_address; -} - H_SET_BSS_SIZE(&headers,local_bss_counter ); - - /* + /* * * Crawl the symbol chain. * @@ -327,310 +340,326 @@ local_bss_counter += bss_last_frag->fr_address - bss_frag_root->fr_address; * Put this info into the headers as appropriate. * */ - know(zero_address_frag.fr_address == 0); - string_byte_count = sizeof(string_byte_count); - - obj_crawl_symbol_chain(&headers); - - if (string_byte_count == sizeof(string_byte_count)) { - string_byte_count = 0; - } /* if no strings, then no count. */ - - H_SET_STRING_SIZE(&headers, string_byte_count); - - /* + know (zero_address_frag.fr_address == 0); + string_byte_count = sizeof (string_byte_count); + + obj_crawl_symbol_chain (&headers); + + if (string_byte_count == sizeof (string_byte_count)) + { + string_byte_count = 0; + } /* if no strings, then no count. */ + + H_SET_STRING_SIZE (&headers, string_byte_count); + + /* * Addresses of frags now reflect addresses we use in the object file. * Symbol values are correct. * Scan the frags, converting any ".org"s and ".align"s to ".fill"s. * Also converting any machine-dependent frags using md_convert_frag(); */ - subseg_change(SEG_TEXT, 0); - - for (fragP = text_frag_root; fragP; fragP = fragP->fr_next) { - switch (fragP->fr_type) { - case rs_align: - case rs_org: + subseg_change (SEG_TEXT, 0); + + for (fragP = text_frag_root; fragP; fragP = fragP->fr_next) + { + switch (fragP->fr_type) + { + case rs_align: + case rs_org: #ifdef HANDLE_ALIGN - HANDLE_ALIGN (fragP); + HANDLE_ALIGN (fragP); #endif - fragP->fr_type = rs_fill; - know(fragP->fr_var == 1); - know(fragP->fr_next != NULL); - - fragP->fr_offset = (fragP->fr_next->fr_address - - fragP->fr_address - - fragP->fr_fix); - break; - - case rs_fill: - break; - - case rs_machine_dependent: - md_convert_frag(&headers, fragP); - - know((fragP->fr_next == NULL) || ((fragP->fr_next->fr_address - fragP->fr_address) == fragP->fr_fix)); - - /* + fragP->fr_type = rs_fill; + know (fragP->fr_var == 1); + know (fragP->fr_next != NULL); + + fragP->fr_offset = (fragP->fr_next->fr_address + - fragP->fr_address + - fragP->fr_fix); + break; + + case rs_fill: + break; + + case rs_machine_dependent: + md_convert_frag (&headers, fragP); + + know ((fragP->fr_next == NULL) || ((fragP->fr_next->fr_address - fragP->fr_address) == fragP->fr_fix)); + + /* * After md_convert_frag, we make the frag into a ".space 0". * Md_convert_frag() should set up any fixSs and constants * required. */ - frag_wane(fragP); - break; - + frag_wane (fragP); + break; + #ifndef WORKING_DOT_WORD - case rs_broken_word: { - struct broken_word *lie; - extern md_short_jump_size; - extern md_long_jump_size; - - if (fragP->fr_subtype) { - fragP->fr_fix+=md_short_jump_size; - for (lie=(struct broken_word *)(fragP->fr_symbol);lie && lie->dispfrag==fragP;lie=lie->next_broken_word) - if (lie->added==1) - fragP->fr_fix+=md_long_jump_size; - } - frag_wane(fragP); - } - break; + case rs_broken_word: + { + struct broken_word *lie; + extern md_short_jump_size; + extern md_long_jump_size; + + if (fragP->fr_subtype) + { + fragP->fr_fix += md_short_jump_size; + for (lie = (struct broken_word *) (fragP->fr_symbol); lie && lie->dispfrag == fragP; lie = lie->next_broken_word) + if (lie->added == 1) + fragP->fr_fix += md_long_jump_size; + } + frag_wane (fragP); + } + break; #endif - - default: - BAD_CASE( fragP->fr_type ); - break; - } /* switch (fr_type) */ - if (!((fragP->fr_next == NULL) + default: + BAD_CASE (fragP->fr_type); + break; + } /* switch (fr_type) */ + + if (!((fragP->fr_next == NULL) #ifdef OBJ_BOUT - || (fragP->fr_next == data_frag_root) + || (fragP->fr_next == data_frag_root) #endif - || ((fragP->fr_next->fr_address - fragP->fr_address) - == (fragP->fr_fix + (fragP->fr_offset * fragP->fr_var))))) - { - fprintf (stderr, "assertion failed: file `%s', line %d\n", - __FILE__, __LINE__ - 4); - exit (1); - } - } /* for each frag. */ - + || ((fragP->fr_next->fr_address - fragP->fr_address) + == (fragP->fr_fix + (fragP->fr_offset * fragP->fr_var))))) + { + fprintf (stderr, "assertion failed: file `%s', line %d\n", + __FILE__, __LINE__ - 4); + exit (1); + } + } /* for each frag. */ + #ifndef WORKING_DOT_WORD + { + struct broken_word *lie; + struct broken_word **prevP; + + prevP = &broken_words; + for (lie = broken_words; lie; lie = lie->next_broken_word) + if (!lie->added) { - struct broken_word *lie; - struct broken_word **prevP; - - prevP= &broken_words; - for (lie=broken_words; lie; lie=lie->next_broken_word) - if (!lie->added) { #ifdef TC_NS32K - fix_new_ns32k(lie->frag, - lie->word_goes_here - lie->frag->fr_literal, - 2, - lie->add, - lie->sub, - lie->addnum, - 0, 0, 2, 0, 0); + fix_new_ns32k (lie->frag, + lie->word_goes_here - lie->frag->fr_literal, + 2, + lie->add, + lie->sub, + lie->addnum, + 0, 0, 2, 0, 0); #else # if defined(TC_SPARC) || defined(TC_A29K) || defined(NEED_FX_R_TYPE) - fix_new( lie->frag, lie->word_goes_here - lie->frag->fr_literal, - 2, lie->add, - lie->sub, lie->addnum, - 0, NO_RELOC); + fix_new (lie->frag, lie->word_goes_here - lie->frag->fr_literal, + 2, lie->add, + lie->sub, lie->addnum, + 0, NO_RELOC); # else - fix_new( lie->frag, lie->word_goes_here - lie->frag->fr_literal, - 2, lie->add, - lie->sub, lie->addnum, - 0, 0); + fix_new (lie->frag, lie->word_goes_here - lie->frag->fr_literal, + 2, lie->add, + lie->sub, lie->addnum, + 0, 0); -# endif /* tc_sparc|tc_a29k|need_fx_r_type */ +# endif /* tc_sparc|tc_a29k|need_fx_r_type */ #endif /* TC_NS32K */ - /* md_number_to_chars(lie->word_goes_here, + /* md_number_to_chars(lie->word_goes_here, S_GET_VALUE(lie->add) + lie->addnum - S_GET_VALUE(lie->sub), 2); */ - *prevP=lie->next_broken_word; - } else - prevP= &(lie->next_broken_word); - - for (lie=broken_words;lie;) { - struct broken_word *untruth; - char *table_ptr; - long table_addr; - long from_addr, - to_addr; - int n, - m; - - extern md_short_jump_size; - extern md_long_jump_size; - - fragP=lie->dispfrag; - - /* Find out how many broken_words go here */ - n=0; - for (untruth=lie;untruth && untruth->dispfrag==fragP;untruth=untruth->next_broken_word) - if (untruth->added==1) - n++; - - table_ptr=lie->dispfrag->fr_opcode; - table_addr=lie->dispfrag->fr_address+(table_ptr - lie->dispfrag->fr_literal); - /* Create the jump around the long jumps */ - /* This is a short jump from table_ptr+0 to table_ptr+n*long_jump_size */ - from_addr=table_addr; - to_addr = table_addr + md_short_jump_size + n * md_long_jump_size; - md_create_short_jump(table_ptr, from_addr, to_addr, lie->dispfrag, lie->add); - table_ptr+=md_short_jump_size; - table_addr+=md_short_jump_size; - - for (m=0;lie && lie->dispfrag==fragP;m++,lie=lie->next_broken_word) { - if (lie->added==2) - continue; - /* Patch the jump table */ - /* This is the offset from ??? to table_ptr+0 */ - to_addr = table_addr - - S_GET_VALUE(lie->sub); - md_number_to_chars(lie->word_goes_here,to_addr,2); - for (untruth=lie->next_broken_word;untruth && untruth->dispfrag==fragP;untruth=untruth->next_broken_word) { - if (untruth->use_jump==lie) - md_number_to_chars(untruth->word_goes_here,to_addr,2); - } - - /* Install the long jump */ - /* this is a long jump from table_ptr+0 to the final target */ - from_addr=table_addr; - to_addr=S_GET_VALUE(lie->add) + lie->addnum; - md_create_long_jump(table_ptr,from_addr,to_addr,lie->dispfrag,lie->add); - table_ptr+=md_long_jump_size; - table_addr+=md_long_jump_size; - } - } + *prevP = lie->next_broken_word; } + else + prevP = &(lie->next_broken_word); + + for (lie = broken_words; lie;) + { + struct broken_word *untruth; + char *table_ptr; + long table_addr; + long from_addr, to_addr; + int n, m; + + extern md_short_jump_size; + extern md_long_jump_size; + + fragP = lie->dispfrag; + + /* Find out how many broken_words go here */ + n = 0; + for (untruth = lie; untruth && untruth->dispfrag == fragP; untruth = untruth->next_broken_word) + if (untruth->added == 1) + n++; + + table_ptr = lie->dispfrag->fr_opcode; + table_addr = lie->dispfrag->fr_address + (table_ptr - lie->dispfrag->fr_literal); + /* Create the jump around the long jumps */ + /* This is a short jump from table_ptr+0 to table_ptr+n*long_jump_size */ + from_addr = table_addr; + to_addr = table_addr + md_short_jump_size + n * md_long_jump_size; + md_create_short_jump (table_ptr, from_addr, to_addr, lie->dispfrag, lie->add); + table_ptr += md_short_jump_size; + table_addr += md_short_jump_size; + + for (m = 0; lie && lie->dispfrag == fragP; m++, lie = lie->next_broken_word) + { + if (lie->added == 2) + continue; + /* Patch the jump table */ + /* This is the offset from ??? to table_ptr+0 */ + to_addr = table_addr + - S_GET_VALUE (lie->sub); + md_number_to_chars (lie->word_goes_here, to_addr, 2); + for (untruth = lie->next_broken_word; untruth && untruth->dispfrag == fragP; untruth = untruth->next_broken_word) + { + if (untruth->use_jump == lie) + md_number_to_chars (untruth->word_goes_here, to_addr, 2); + } + + /* Install the long jump */ + /* this is a long jump from table_ptr+0 to the final target */ + from_addr = table_addr; + to_addr = S_GET_VALUE (lie->add) + lie->addnum; + md_create_long_jump (table_ptr, from_addr, to_addr, lie->dispfrag, lie->add); + table_ptr += md_long_jump_size; + table_addr += md_long_jump_size; + } + } + } #endif /* not WORKING_DOT_WORD */ - + #ifndef VMS - { /* not vms */ - /* + { /* not vms */ + /* * Scan every FixS performing fixups. We had to wait until now to do * this because md_convert_frag() may have made some fixSs. */ - int trsize, drsize; - - subseg_change (SEG_TEXT, 0); - trsize = md_reloc_size * fixup_segment (text_fix_root, - SEG_TEXT); - subseg_change (SEG_DATA, 0); - drsize = md_reloc_size * fixup_segment (data_fix_root, - SEG_DATA); - H_SET_RELOCATION_SIZE (&headers, trsize, drsize); - - /* FIXME move this stuff into the pre-write-hook */ - H_SET_MAGIC_NUMBER(&headers, magic_number_for_object_file); - H_SET_ENTRY_POINT(&headers, 0); - - obj_pre_write_hook(&headers); /* extra coff stuff */ - if ((had_warnings() && flagseen['Z']) - || had_errors() > 0) { - if (flagseen['Z']) { - as_warn("%d error%s, %d warning%s, generating bad object file.\n", - had_errors(), had_errors() == 1 ? "" : "s", - had_warnings(), had_warnings() == 1 ? "" : "s"); - } else { - as_fatal("%d error%s, %d warning%s, no object file generated.\n", - had_errors(), had_errors() == 1 ? "" : "s", - had_warnings(), had_warnings() == 1 ? "" : "s"); - } /* on want output */ - } /* on error condition */ - - object_file_size = H_GET_FILE_SIZE(&headers); - next_object_file_charP = the_object_file = xmalloc(object_file_size); - - output_file_create(out_file_name); - - obj_header_append(&next_object_file_charP, &headers); - - know((next_object_file_charP - the_object_file) == H_GET_HEADER_SIZE(&headers)); - - /* + int trsize, drsize; + + subseg_change (SEG_TEXT, 0); + trsize = md_reloc_size * fixup_segment (text_fix_root, + SEG_TEXT); + subseg_change (SEG_DATA, 0); + drsize = md_reloc_size * fixup_segment (data_fix_root, + SEG_DATA); + H_SET_RELOCATION_SIZE (&headers, trsize, drsize); + + /* FIXME move this stuff into the pre-write-hook */ + H_SET_MAGIC_NUMBER (&headers, magic_number_for_object_file); + H_SET_ENTRY_POINT (&headers, 0); + + obj_pre_write_hook (&headers); /* extra coff stuff */ + if ((had_warnings () && flagseen['Z']) + || had_errors () > 0) + { + if (flagseen['Z']) + { + as_warn ("%d error%s, %d warning%s, generating bad object file.\n", + had_errors (), had_errors () == 1 ? "" : "s", + had_warnings (), had_warnings () == 1 ? "" : "s"); + } + else + { + as_fatal ("%d error%s, %d warning%s, no object file generated.\n", + had_errors (), had_errors () == 1 ? "" : "s", + had_warnings (), had_warnings () == 1 ? "" : "s"); + } /* on want output */ + } /* on error condition */ + + object_file_size = H_GET_FILE_SIZE (&headers); + next_object_file_charP = the_object_file = xmalloc (object_file_size); + + output_file_create (out_file_name); + + obj_header_append (&next_object_file_charP, &headers); + + know ((next_object_file_charP - the_object_file) == H_GET_HEADER_SIZE (&headers)); + + /* * Emit code. */ - for (fragP = text_frag_root; fragP; fragP = fragP->fr_next) { - register long count; - register char *fill_literal; - register long fill_size; - - know(fragP->fr_type == rs_fill); - append(&next_object_file_charP, fragP->fr_literal, (unsigned long) fragP->fr_fix); - fill_literal = fragP->fr_literal + fragP->fr_fix; - fill_size = fragP->fr_var; - know(fragP->fr_offset >= 0); - - for (count = fragP->fr_offset; count; count--) { - append(&next_object_file_charP, fill_literal, (unsigned long) fill_size); - } /* for each */ - - } /* for each code frag. */ - - know((next_object_file_charP - the_object_file) == (H_GET_HEADER_SIZE(&headers) + H_GET_TEXT_SIZE(&headers) + H_GET_DATA_SIZE(&headers))); - - /* + for (fragP = text_frag_root; fragP; fragP = fragP->fr_next) + { + register long count; + register char *fill_literal; + register long fill_size; + + know (fragP->fr_type == rs_fill); + append (&next_object_file_charP, fragP->fr_literal, (unsigned long) fragP->fr_fix); + fill_literal = fragP->fr_literal + fragP->fr_fix; + fill_size = fragP->fr_var; + know (fragP->fr_offset >= 0); + + for (count = fragP->fr_offset; count; count--) + { + append (&next_object_file_charP, fill_literal, (unsigned long) fill_size); + } /* for each */ + + } /* for each code frag. */ + + know ((next_object_file_charP - the_object_file) == (H_GET_HEADER_SIZE (&headers) + H_GET_TEXT_SIZE (&headers) + H_GET_DATA_SIZE (&headers))); + + /* * Emit relocations. */ - obj_emit_relocations(&next_object_file_charP, text_fix_root, (relax_addressT)0); - know((next_object_file_charP - the_object_file) == (H_GET_HEADER_SIZE(&headers) + H_GET_TEXT_SIZE(&headers) + H_GET_DATA_SIZE(&headers) + H_GET_TEXT_RELOCATION_SIZE(&headers))); + obj_emit_relocations (&next_object_file_charP, text_fix_root, (relax_addressT) 0); + know ((next_object_file_charP - the_object_file) == (H_GET_HEADER_SIZE (&headers) + H_GET_TEXT_SIZE (&headers) + H_GET_DATA_SIZE (&headers) + H_GET_TEXT_RELOCATION_SIZE (&headers))); #ifdef TC_I960 - /* Make addresses in data relocation directives relative to beginning of + /* Make addresses in data relocation directives relative to beginning of * first data fragment, not end of last text fragment: alignment of the * start of the data segment may place a gap between the segments. */ - obj_emit_relocations(&next_object_file_charP, data_fix_root, data0_frchainP->frch_root->fr_address); + obj_emit_relocations (&next_object_file_charP, data_fix_root, data0_frchainP->frch_root->fr_address); #else /* TC_I960 */ - obj_emit_relocations(&next_object_file_charP, data_fix_root, text_last_frag->fr_address); + obj_emit_relocations (&next_object_file_charP, data_fix_root, text_last_frag->fr_address); #endif /* TC_I960 */ - - know((next_object_file_charP - the_object_file) == (H_GET_HEADER_SIZE(&headers) + H_GET_TEXT_SIZE(&headers) + H_GET_DATA_SIZE(&headers) + H_GET_TEXT_RELOCATION_SIZE(&headers) + H_GET_DATA_RELOCATION_SIZE(&headers))); - - /* + + know ((next_object_file_charP - the_object_file) == (H_GET_HEADER_SIZE (&headers) + H_GET_TEXT_SIZE (&headers) + H_GET_DATA_SIZE (&headers) + H_GET_TEXT_RELOCATION_SIZE (&headers) + H_GET_DATA_RELOCATION_SIZE (&headers))); + + /* * Emit line number entries. */ - OBJ_EMIT_LINENO(&next_object_file_charP, lineno_rootP, the_object_file); - know((next_object_file_charP - the_object_file) == (H_GET_HEADER_SIZE(&headers) + H_GET_TEXT_SIZE(&headers) + H_GET_DATA_SIZE(&headers) + H_GET_TEXT_RELOCATION_SIZE(&headers) + H_GET_DATA_RELOCATION_SIZE(&headers) + H_GET_LINENO_SIZE(&headers))); - - /* + OBJ_EMIT_LINENO (&next_object_file_charP, lineno_rootP, the_object_file); + know ((next_object_file_charP - the_object_file) == (H_GET_HEADER_SIZE (&headers) + H_GET_TEXT_SIZE (&headers) + H_GET_DATA_SIZE (&headers) + H_GET_TEXT_RELOCATION_SIZE (&headers) + H_GET_DATA_RELOCATION_SIZE (&headers) + H_GET_LINENO_SIZE (&headers))); + + /* * Emit symbols. */ - obj_emit_symbols(&next_object_file_charP, symbol_rootP); - know((next_object_file_charP - the_object_file) == (H_GET_HEADER_SIZE(&headers) + H_GET_TEXT_SIZE(&headers) + H_GET_DATA_SIZE(&headers) + H_GET_TEXT_RELOCATION_SIZE(&headers) + H_GET_DATA_RELOCATION_SIZE(&headers) + H_GET_LINENO_SIZE(&headers) + H_GET_SYMBOL_TABLE_SIZE(&headers))); - - /* + obj_emit_symbols (&next_object_file_charP, symbol_rootP); + know ((next_object_file_charP - the_object_file) == (H_GET_HEADER_SIZE (&headers) + H_GET_TEXT_SIZE (&headers) + H_GET_DATA_SIZE (&headers) + H_GET_TEXT_RELOCATION_SIZE (&headers) + H_GET_DATA_RELOCATION_SIZE (&headers) + H_GET_LINENO_SIZE (&headers) + H_GET_SYMBOL_TABLE_SIZE (&headers))); + + /* * Emit strings. */ - - if (string_byte_count > 0) { - obj_emit_strings(&next_object_file_charP); - } /* only if we have a string table */ - - /* know((next_object_file_charP - the_object_file) == (H_GET_HEADER_SIZE(&headers) + H_GET_TEXT_SIZE(&headers) + H_GET_DATA_SIZE(&headers) + H_GET_TEXT_RELOCATION_SIZE(&headers) + H_GET_DATA_RELOCATION_SIZE(&headers) + H_GET_LINENO_SIZE(&headers) + H_GET_SYMBOL_TABLE_SIZE(&headers) + H_GET_STRING_SIZE(&headers))); + + if (string_byte_count > 0) + { + obj_emit_strings (&next_object_file_charP); + } /* only if we have a string table */ + + /* know((next_object_file_charP - the_object_file) == (H_GET_HEADER_SIZE(&headers) + H_GET_TEXT_SIZE(&headers) + H_GET_DATA_SIZE(&headers) + H_GET_TEXT_RELOCATION_SIZE(&headers) + H_GET_DATA_RELOCATION_SIZE(&headers) + H_GET_LINENO_SIZE(&headers) + H_GET_SYMBOL_TABLE_SIZE(&headers) + H_GET_STRING_SIZE(&headers))); */ - /* know(next_object_file_charP == the_object_file + object_file_size);*/ - + /* know(next_object_file_charP == the_object_file + object_file_size);*/ + #ifdef BFD_HEADERS - bfd_seek(stdoutput, 0, 0); - bfd_write(the_object_file, 1, object_file_size, stdoutput); + bfd_seek (stdoutput, 0, 0); + bfd_write (the_object_file, 1, object_file_size, stdoutput); #else - - /* Write the data to the file */ - output_file_append(the_object_file,object_file_size,out_file_name); + + /* Write the data to the file */ + output_file_append (the_object_file, object_file_size, out_file_name); #endif - - output_file_close(out_file_name); - } /* non vms output */ -#else /* VMS */ - /* + + output_file_close (out_file_name); + } /* non vms output */ +#else /* VMS */ + /* * Now do the VMS-dependent part of writing the object file */ - VMS_write_object_file(text_siz, data_siz, text_frag_root, data_frag_root); -#endif /* VMS */ -} /* write_object_file() */ + VMS_write_object_file (text_siz, data_siz, text_frag_root, data_frag_root); +#endif /* VMS */ +} /* write_object_file() */ + #else #endif @@ -649,203 +678,217 @@ local_bss_counter += bss_last_frag->fr_address - bss_frag_root->fr_address; -void relax_segment(segment_frag_root, segment) -struct frag * segment_frag_root; -segT segment; /* SEG_DATA or SEG_TEXT */ +void +relax_segment (segment_frag_root, segment) + struct frag *segment_frag_root; + segT segment; /* SEG_DATA or SEG_TEXT */ { - register struct frag * fragP; - register relax_addressT address; -#ifndef MANY_SEGMENTS - know(segment == SEG_DATA || segment == SEG_TEXT || segment == SEG_BSS); + register struct frag *fragP; + register relax_addressT address; +#ifndef MANY_SEGMENTS + know (segment == SEG_DATA || segment == SEG_TEXT || segment == SEG_BSS); #endif - /* In case md_estimate_size_before_relax() wants to make fixSs. */ - subseg_change(segment, 0); - - /* + /* In case md_estimate_size_before_relax() wants to make fixSs. */ + subseg_change (segment, 0); + + /* * For each frag in segment: count and store (a 1st guess of) * fr_address. */ - address = 0; - for (fragP = segment_frag_root; fragP; fragP = fragP->fr_next) { - fragP->fr_address = address; - address += fragP->fr_fix; - - switch (fragP->fr_type) { - case rs_fill: - address += fragP->fr_offset * fragP->fr_var ; - break; - - case rs_align: - address += relax_align(address, fragP->fr_offset); - break; - - case rs_org: - /* + address = 0; + for (fragP = segment_frag_root; fragP; fragP = fragP->fr_next) + { + fragP->fr_address = address; + address += fragP->fr_fix; + + switch (fragP->fr_type) + { + case rs_fill: + address += fragP->fr_offset * fragP->fr_var; + break; + + case rs_align: + address += relax_align (address, fragP->fr_offset); + break; + + case rs_org: + /* * Assume .org is nugatory. It will grow with 1st * relax. */ - break; - - case rs_machine_dependent: - address += md_estimate_size_before_relax(fragP, segment); - break; - + break; + + case rs_machine_dependent: + address += md_estimate_size_before_relax (fragP, segment); + break; + #ifndef WORKING_DOT_WORD - /* Broken words don't concern us yet */ - case rs_broken_word: - break; + /* Broken words don't concern us yet */ + case rs_broken_word: + break; #endif - - default: - BAD_CASE(fragP->fr_type); - break; - } /* switch(fr_type) */ - } /* for each frag in the segment */ - - /* + + default: + BAD_CASE (fragP->fr_type); + break; + } /* switch(fr_type) */ + } /* for each frag in the segment */ + + /* * Do relax(). */ - { - register long stretch; /* May be any size, 0 or negative. */ - /* Cumulative number of addresses we have */ - /* relaxed this pass. */ - /* We may have relaxed more than one address. */ - register long stretched; /* Have we stretched on this pass? */ - /* This is 'cuz stretch may be zero, when, + { + register long stretch; /* May be any size, 0 or negative. */ + /* Cumulative number of addresses we have */ + /* relaxed this pass. */ + /* We may have relaxed more than one address. */ + register long stretched; /* Have we stretched on this pass? */ + /* This is 'cuz stretch may be zero, when, in fact some piece of code grew, and another shrank. If a branch instruction doesn't fit anymore, we could be scrod */ - - do { - stretch = stretched = 0; - for (fragP = segment_frag_root; fragP; fragP = fragP->fr_next) { - register long growth = 0; - register unsigned long was_address; - /* register long var; */ - register long offset; - register symbolS *symbolP; - register long target; - register long after; - register long aim; - - was_address = fragP->fr_address; - address = fragP->fr_address += stretch; - symbolP = fragP->fr_symbol; - offset = fragP->fr_offset; - /* var = fragP->fr_var; */ - - switch (fragP->fr_type) { - case rs_fill: /* .fill never relaxes. */ - growth = 0; - break; - + + do + { + stretch = stretched = 0; + for (fragP = segment_frag_root; fragP; fragP = fragP->fr_next) + { + register long growth = 0; + register unsigned long was_address; + /* register long var; */ + register long offset; + register symbolS *symbolP; + register long target; + register long after; + register long aim; + + was_address = fragP->fr_address; + address = fragP->fr_address += stretch; + symbolP = fragP->fr_symbol; + offset = fragP->fr_offset; + /* var = fragP->fr_var; */ + + switch (fragP->fr_type) + { + case rs_fill: /* .fill never relaxes. */ + growth = 0; + break; + #ifndef WORKING_DOT_WORD - /* JF: This is RMS's idea. I do *NOT* want to be blamed + /* JF: This is RMS's idea. I do *NOT* want to be blamed for it I do not want to write it. I do not want to have anything to do with it. This is not the proper way to implement this misfeature. */ - case rs_broken_word: { - struct broken_word *lie; - struct broken_word *untruth; - extern int md_short_jump_size; - extern int md_long_jump_size; - - /* Yes this is ugly (storing the broken_word pointer + case rs_broken_word: + { + struct broken_word *lie; + struct broken_word *untruth; + extern int md_short_jump_size; + extern int md_long_jump_size; + + /* Yes this is ugly (storing the broken_word pointer in the symbol slot). Still, this whole chunk of code is ugly, and I don't feel like doing anything about it. Think of it as stubbornness in action */ - growth=0; - for (lie=(struct broken_word *)(fragP->fr_symbol); - lie && lie->dispfrag==fragP; - lie=lie->next_broken_word) { - - if (lie->added) - continue; - - offset= lie->add->sy_frag->fr_address+ S_GET_VALUE(lie->add) + lie->addnum - - (lie->sub->sy_frag->fr_address+ S_GET_VALUE(lie->sub)); - if (offset<=-32768 || offset>=32767) { - if (flagseen['K']) - as_warn(".word %s-%s+%ld didn't fit", - S_GET_NAME(lie->add), - S_GET_NAME(lie->sub), - lie->addnum); - lie->added=1; - if (fragP->fr_subtype==0) { - fragP->fr_subtype++; - growth+=md_short_jump_size; - } - for (untruth=lie->next_broken_word;untruth && untruth->dispfrag==lie->dispfrag;untruth=untruth->next_broken_word) - if ((untruth->add->sy_frag == lie->add->sy_frag) - && S_GET_VALUE(untruth->add) == S_GET_VALUE(lie->add)) { - untruth->added=2; - untruth->use_jump=lie; - } - growth+=md_long_jump_size; - } - } - - break; - } /* case rs_broken_word */ + growth = 0; + for (lie = (struct broken_word *) (fragP->fr_symbol); + lie && lie->dispfrag == fragP; + lie = lie->next_broken_word) + { + + if (lie->added) + continue; + + offset = lie->add->sy_frag->fr_address + S_GET_VALUE (lie->add) + lie->addnum - + (lie->sub->sy_frag->fr_address + S_GET_VALUE (lie->sub)); + if (offset <= -32768 || offset >= 32767) + { + if (flagseen['K']) + as_warn (".word %s-%s+%ld didn't fit", + S_GET_NAME (lie->add), + S_GET_NAME (lie->sub), + lie->addnum); + lie->added = 1; + if (fragP->fr_subtype == 0) + { + fragP->fr_subtype++; + growth += md_short_jump_size; + } + for (untruth = lie->next_broken_word; untruth && untruth->dispfrag == lie->dispfrag; untruth = untruth->next_broken_word) + if ((untruth->add->sy_frag == lie->add->sy_frag) + && S_GET_VALUE (untruth->add) == S_GET_VALUE (lie->add)) + { + untruth->added = 2; + untruth->use_jump = lie; + } + growth += md_long_jump_size; + } + } + + break; + } /* case rs_broken_word */ #endif - case rs_align: - growth = relax_align((relax_addressT) (address + fragP->fr_fix), offset) - - relax_align((relax_addressT) (was_address + fragP->fr_fix), offset); - break; - - case rs_org: - target = offset; - - if (symbolP) { + case rs_align: + growth = relax_align ((relax_addressT) (address + fragP->fr_fix), offset) + - relax_align ((relax_addressT) (was_address + fragP->fr_fix), offset); + break; + + case rs_org: + target = offset; + + if (symbolP) + { #ifdef MANY_SEGMENTS #else - know((S_GET_SEGMENT(symbolP) == SEG_ABSOLUTE) || (S_GET_SEGMENT(symbolP) == SEG_DATA) || (S_GET_SEGMENT(symbolP) == SEG_TEXT) || S_GET_SEGMENT(symbolP) == SEG_BSS); - know(symbolP->sy_frag); - know(!(S_GET_SEGMENT(symbolP) == SEG_ABSOLUTE) || (symbolP->sy_frag == &zero_address_frag)); + know ((S_GET_SEGMENT (symbolP) == SEG_ABSOLUTE) || (S_GET_SEGMENT (symbolP) == SEG_DATA) || (S_GET_SEGMENT (symbolP) == SEG_TEXT) || S_GET_SEGMENT (symbolP) == SEG_BSS); + know (symbolP->sy_frag); + know (!(S_GET_SEGMENT (symbolP) == SEG_ABSOLUTE) || (symbolP->sy_frag == &zero_address_frag)); #endif - target += S_GET_VALUE(symbolP) - + symbolP->sy_frag->fr_address; - } /* if we have a symbol */ - - know(fragP->fr_next); - after = fragP->fr_next->fr_address; - growth = ((target - after ) > 0) ? (target - after) : 0; - /* Growth may be -ve, but variable part */ - /* of frag cannot have < 0 chars. */ - /* That is, we can't .org backwards. */ - - growth -= stretch; /* This is an absolute growth factor */ - break; - - case rs_machine_dependent: { - register const relax_typeS * this_type; - register const relax_typeS * start_type; - register relax_substateT next_state; - register relax_substateT this_state; - - start_type = this_type = md_relax_table + (this_state = fragP->fr_subtype); - target = offset; - - if (symbolP) { + target += S_GET_VALUE (symbolP) + + symbolP->sy_frag->fr_address; + } /* if we have a symbol */ + + know (fragP->fr_next); + after = fragP->fr_next->fr_address; + growth = ((target - after) > 0) ? (target - after) : 0; + /* Growth may be -ve, but variable part */ + /* of frag cannot have < 0 chars. */ + /* That is, we can't .org backwards. */ + + growth -= stretch; /* This is an absolute growth factor */ + break; + + case rs_machine_dependent: + { + register const relax_typeS *this_type; + register const relax_typeS *start_type; + register relax_substateT next_state; + register relax_substateT this_state; + + start_type = this_type = md_relax_table + (this_state = fragP->fr_subtype); + target = offset; + + if (symbolP) + { #ifndef MANY_SEGMENTS - know((S_GET_SEGMENT(symbolP) == SEG_ABSOLUTE) || (S_GET_SEGMENT(symbolP) == SEG_DATA)|| (S_GET_SEGMENT(symbolP) == SEG_BSS) || (S_GET_SEGMENT(symbolP) == SEG_TEXT)); + know ((S_GET_SEGMENT (symbolP) == SEG_ABSOLUTE) || (S_GET_SEGMENT (symbolP) == SEG_DATA) || (S_GET_SEGMENT (symbolP) == SEG_BSS) || (S_GET_SEGMENT (symbolP) == SEG_TEXT)); #endif - know(symbolP->sy_frag); - know(!(S_GET_SEGMENT(symbolP) == SEG_ABSOLUTE) || symbolP->sy_frag==&zero_address_frag ); - target += - S_GET_VALUE(symbolP) - + symbolP->sy_frag->fr_address; - - /* If frag has yet to be reached on this pass, + know (symbolP->sy_frag); + know (!(S_GET_SEGMENT (symbolP) == SEG_ABSOLUTE) || symbolP->sy_frag == &zero_address_frag); + target += + S_GET_VALUE (symbolP) + + symbolP->sy_frag->fr_address; + + /* If frag has yet to be reached on this pass, assume it will move by STRETCH just as we did. If this is not so, it will be because some frag between grows, and that will force another pass. */ - - /* JF was just address */ - /* JF also added is_dnrange hack */ - /* There's gotta be a better/faster/etc way + + /* JF was just address */ + /* JF also added is_dnrange hack */ + /* There's gotta be a better/faster/etc way to do this. . . */ - /* gnu@cygnus.com: I changed this from > to >= + /* gnu@cygnus.com: I changed this from > to >= because I ran into a zero-length frag (fr_fix=0) which was created when the obstack needed a new chunk JUST AFTER the opcode of a branch. Since @@ -862,85 +905,100 @@ segT segment; /* SEG_DATA or SEG_TEXT */ assembled on other machines, which is how I found it. You might want to think about what other places have trouble with zero length frags... */ - - if (symbolP->sy_frag->fr_address >= was_address - && is_dnrange(fragP,symbolP->sy_frag)) { - target += stretch; - } /* */ - - } /* if there's a symbol attached */ - - aim = target - address - fragP->fr_fix; - /* The displacement is affected by the instruction size + + if (symbolP->sy_frag->fr_address >= was_address + && is_dnrange (fragP, symbolP->sy_frag)) + { + target += stretch; + } /* */ + + } /* if there's a symbol attached */ + + aim = target - address - fragP->fr_fix; + /* The displacement is affected by the instruction size * for the 32k architecture. I think we ought to be able * to add fragP->fr_pcrel_adjust in all cases (it should be * zero if not used), but just in case it breaks something * else we'll put this inside #ifdef NS32K ... #endif */ #ifdef TC_NS32K - aim += fragP->fr_pcrel_adjust; + aim += fragP->fr_pcrel_adjust; #endif /* TC_NS32K */ - - if (aim < 0) { - /* Look backwards. */ - for (next_state = this_type->rlx_more; next_state; ) { - if (aim >= this_type->rlx_backward) { - next_state = 0; - } else { /* Grow to next state. */ - this_type = md_relax_table + (this_state = next_state); - next_state = this_type->rlx_more; - } - } - } else { + + if (aim < 0) + { + /* Look backwards. */ + for (next_state = this_type->rlx_more; next_state;) + { + if (aim >= this_type->rlx_backward) + { + next_state = 0; + } + else + { /* Grow to next state. */ + this_type = md_relax_table + (this_state = next_state); + next_state = this_type->rlx_more; + } + } + } + else + { #ifdef DONTDEF - /* JF these next few lines of code are for the mc68020 which can't handle short + /* JF these next few lines of code are for the mc68020 which can't handle short offsets of zero in branch instructions. What a kludge! */ - if (aim==0 && this_state==(1<<2+0)) { /* FOO hard encoded from m.c */ - aim=this_type->rlx_forward+1; /* Force relaxation into word mode */ - } + if (aim == 0 && this_state == (1 << 2 + 0)) + { /* FOO hard encoded from m.c */ + aim = this_type->rlx_forward + 1; /* Force relaxation into word mode */ + } #endif #ifdef M68K_AIM_KLUDGE - M68K_AIM_KLUDGE(aim, this_state, this_type); + M68K_AIM_KLUDGE (aim, this_state, this_type); #endif - /* JF end of 68020 code */ - /* Look forwards. */ - for (next_state = this_type->rlx_more; next_state; ) { - if (aim <= this_type->rlx_forward) { - next_state = 0; - } else { /* Grow to next state. */ - this_type = md_relax_table + (this_state = next_state); - next_state = this_type->rlx_more; - } - } - } - - if ((growth = this_type->rlx_length - start_type->rlx_length) != 0) - fragP->fr_subtype = this_state; - - break; - } /* case rs_machine_dependent */ - - default: - BAD_CASE( fragP->fr_type ); - break; - } - if (growth) { - stretch += growth; - stretched++; - } - } /* For each frag in the segment. */ - } while (stretched); /* Until nothing further to relax. */ - } /* do_relax */ - - /* + /* JF end of 68020 code */ + /* Look forwards. */ + for (next_state = this_type->rlx_more; next_state;) + { + if (aim <= this_type->rlx_forward) + { + next_state = 0; + } + else + { /* Grow to next state. */ + this_type = md_relax_table + (this_state = next_state); + next_state = this_type->rlx_more; + } + } + } + + if ((growth = this_type->rlx_length - start_type->rlx_length) != 0) + fragP->fr_subtype = this_state; + + break; + } /* case rs_machine_dependent */ + + default: + BAD_CASE (fragP->fr_type); + break; + } + if (growth) + { + stretch += growth; + stretched++; + } + } /* For each frag in the segment. */ + } + while (stretched); /* Until nothing further to relax. */ + } /* do_relax */ + + /* * We now have valid fr_address'es for each frag. */ - - /* + + /* * All fr_address's are correct, relative to their own segment. * We have made all the fixS we will ever make. */ -} /* relax_segment() */ +} /* relax_segment() */ /* * Relax_align. Advance location counter to next address that has 'alignment' @@ -949,260 +1007,304 @@ segT segment; /* SEG_DATA or SEG_TEXT */ /* How many addresses does the .align take? */ static relax_addressT -relax_align(address, alignment) - register relax_addressT address; /* Address now. */ - register long alignment; /* Alignment (binary). */ +relax_align (address, alignment) + register relax_addressT address; /* Address now. */ + register long alignment; /* Alignment (binary). */ { relax_addressT mask; relax_addressT new_address; - mask = ~ ( (~0) << alignment ); - new_address = (address + mask) & (~ mask); + mask = ~((~0) << alignment); + new_address = (address + mask) & (~mask); if (linkrelax) /* We must provide lots of padding, so the linker can discard it when needed. The linker will not add extra space, ever. */ new_address += (1 << alignment); return (new_address - address); -} /* relax_align() */ +} /* relax_align() */ /* fixup_segment() - + Go through all the fixS's in a segment and see which ones can be handled now. (These consist of fixS where we have since discovered the value of a symbol, or the address of the frag involved.) For each one, call md_apply_fix to put the fix into the frag data. - + Result is a count of how many relocation structs will be needed to handle the remaining fixS's that we couldn't completely handle here. These will be output later by emit_relocations(). */ static long -fixup_segment(fixP, this_segment_type) +fixup_segment (fixP, this_segment_type) register fixS *fixP; - segT this_segment_type; /* N_TYPE bits for segment. */ + segT this_segment_type; /* N_TYPE bits for segment. */ { - register long seg_reloc_count; - register symbolS *add_symbolP; - register symbolS *sub_symbolP; - register long add_number; - register int size; - register char *place; - register long where; - register char pcrel; - register fragS *fragP; - register segT add_symbol_segment = SEG_ABSOLUTE; - - /* FIXME: remove this line */ /* fixS *orig = fixP; */ - seg_reloc_count = 0; + register long seg_reloc_count; + register symbolS *add_symbolP; + register symbolS *sub_symbolP; + register long add_number; + register int size; + register char *place; + register long where; + register char pcrel; + register fragS *fragP; + register segT add_symbol_segment = SEG_ABSOLUTE; + + /* FIXME: remove this line *//* fixS *orig = fixP; */ + seg_reloc_count = 0; #ifdef TC_I960 - /* If the linker is doing the relaxing, we must not do any fixups */ - if (linkrelax) { - for ( ; fixP ; fixP = fixP->fx_next) { - seg_reloc_count++; - } + /* If the linker is doing the relaxing, we must not do any fixups */ + if (linkrelax) + { + for (; fixP; fixP = fixP->fx_next) + { + seg_reloc_count++; } - else + } + else #endif - for ( ; fixP; fixP = fixP->fx_next) { - fragP = fixP->fx_frag; - know(fragP); - where = fixP->fx_where; - place = fragP->fr_literal + where; - size = fixP->fx_size; - add_symbolP = fixP->fx_addsy; + for (; fixP; fixP = fixP->fx_next) + { + fragP = fixP->fx_frag; + know (fragP); + where = fixP->fx_where; + place = fragP->fr_literal + where; + size = fixP->fx_size; + add_symbolP = fixP->fx_addsy; #ifdef TC_I960 - if (fixP->fx_callj && TC_S_IS_CALLNAME(add_symbolP)) { - /* Relocation should be done via the + if (fixP->fx_callj && TC_S_IS_CALLNAME (add_symbolP)) + { + /* Relocation should be done via the associated 'bal' entry point symbol. */ - - if (!TC_S_IS_BALNAME(tc_get_bal_of_call(add_symbolP))) { - as_bad("No 'bal' entry point for leafproc %s", - S_GET_NAME(add_symbolP)); - continue; - } - fixP->fx_addsy = add_symbolP = tc_get_bal_of_call(add_symbolP); - } /* callj relocation */ + + if (!TC_S_IS_BALNAME (tc_get_bal_of_call (add_symbolP))) + { + as_bad ("No 'bal' entry point for leafproc %s", + S_GET_NAME (add_symbolP)); + continue; + } + fixP->fx_addsy = add_symbolP = tc_get_bal_of_call (add_symbolP); + } /* callj relocation */ #endif - sub_symbolP = fixP->fx_subsy; - add_number = fixP->fx_offset; - pcrel = fixP->fx_pcrel; - - if (add_symbolP) { - add_symbol_segment = S_GET_SEGMENT(add_symbolP); - } /* if there is an addend */ - - if (sub_symbolP) { - if (!add_symbolP) { - /* Its just -sym */ - if (S_GET_SEGMENT(sub_symbolP) != SEG_ABSOLUTE) { - as_bad("Negative of non-absolute symbol %s", S_GET_NAME(sub_symbolP)); - } /* not absolute */ - - add_number -= S_GET_VALUE(sub_symbolP); - - /* if sub_symbol is in the same segment that add_symbol + sub_symbolP = fixP->fx_subsy; + add_number = fixP->fx_offset; + pcrel = fixP->fx_pcrel; + + if (add_symbolP) + { + add_symbol_segment = S_GET_SEGMENT (add_symbolP); + } /* if there is an addend */ + + if (sub_symbolP) + { + if (!add_symbolP) + { + /* Its just -sym */ + if (S_GET_SEGMENT (sub_symbolP) != SEG_ABSOLUTE) + { + as_bad ("Negative of non-absolute symbol %s", S_GET_NAME (sub_symbolP)); + } /* not absolute */ + + add_number -= S_GET_VALUE (sub_symbolP); + + /* if sub_symbol is in the same segment that add_symbol and add_symbol is either in DATA, TEXT, BSS or ABSOLUTE */ - } else if ((S_GET_SEGMENT(sub_symbolP) == add_symbol_segment) - && (SEG_NORMAL(add_symbol_segment) - || (add_symbol_segment == SEG_ABSOLUTE))) { - /* Difference of 2 symbols from same segment. */ - /* Can't make difference of 2 undefineds: 'value' means */ - /* something different for N_UNDF. */ + } + else if ((S_GET_SEGMENT (sub_symbolP) == add_symbol_segment) + && (SEG_NORMAL (add_symbol_segment) + || (add_symbol_segment == SEG_ABSOLUTE))) + { + /* Difference of 2 symbols from same segment. */ + /* Can't make difference of 2 undefineds: 'value' means */ + /* something different for N_UNDF. */ #ifdef TC_I960 - /* Makes no sense to use the difference of 2 arbitrary symbols + /* Makes no sense to use the difference of 2 arbitrary symbols * as the target of a call instruction. */ - if (fixP->fx_callj) { - as_bad("callj to difference of 2 symbols"); - } -#endif /* TC_I960 */ - add_number += S_GET_VALUE(add_symbolP) - - S_GET_VALUE(sub_symbolP); - - add_symbolP = NULL; - fixP->fx_addsy = NULL; - } else { - /* Different segments in subtraction. */ - know(!(S_IS_EXTERNAL(sub_symbolP) && (S_GET_SEGMENT(sub_symbolP) == SEG_ABSOLUTE))); - - if ((S_GET_SEGMENT(sub_symbolP) == SEG_ABSOLUTE)) { - add_number -= S_GET_VALUE(sub_symbolP); - } else { - as_bad("Can't emit reloc {- %s-seg symbol \"%s\"} @ file address %d.", - segment_name(S_GET_SEGMENT(sub_symbolP)), - S_GET_NAME(sub_symbolP), fragP->fr_address + where); - } /* if absolute */ - } - } /* if sub_symbolP */ - - if (add_symbolP) { - if (add_symbol_segment == this_segment_type && pcrel) { - /* + if (fixP->fx_callj) + { + as_bad ("callj to difference of 2 symbols"); + } +#endif /* TC_I960 */ + add_number += S_GET_VALUE (add_symbolP) - + S_GET_VALUE (sub_symbolP); + + add_symbolP = NULL; + fixP->fx_addsy = NULL; + } + else + { + /* Different segments in subtraction. */ + know (!(S_IS_EXTERNAL (sub_symbolP) && (S_GET_SEGMENT (sub_symbolP) == SEG_ABSOLUTE))); + + if ((S_GET_SEGMENT (sub_symbolP) == SEG_ABSOLUTE)) + { + add_number -= S_GET_VALUE (sub_symbolP); + } + else + { + as_bad ("Can't emit reloc {- %s-seg symbol \"%s\"} @ file address %d.", + segment_name (S_GET_SEGMENT (sub_symbolP)), + S_GET_NAME (sub_symbolP), fragP->fr_address + where); + } /* if absolute */ + } + } /* if sub_symbolP */ + + if (add_symbolP) + { + if (add_symbol_segment == this_segment_type && pcrel) + { + /* * This fixup was made when the symbol's segment was * SEG_UNKNOWN, but it is now in the local segment. * So we know how to do the address without relocation. */ #ifdef TC_I960 - /* reloc_callj() may replace a 'call' with a 'calls' or a 'bal', + /* reloc_callj() may replace a 'call' with a 'calls' or a 'bal', * in which cases it modifies *fixP as appropriate. In the case * of a 'calls', no further work is required, and *fixP has been * set up to make the rest of the code below a no-op. */ - reloc_callj(fixP); + reloc_callj (fixP); #endif /* TC_I960 */ - - add_number += S_GET_VALUE(add_symbolP); - add_number -= md_pcrel_from (fixP); - pcrel = 0; /* Lie. Don't want further pcrel processing. */ - fixP->fx_addsy = NULL; /* No relocations please. */ - } else { - switch (add_symbol_segment) { - case SEG_ABSOLUTE: + + add_number += S_GET_VALUE (add_symbolP); + add_number -= md_pcrel_from (fixP); + pcrel = 0; /* Lie. Don't want further pcrel processing. */ + fixP->fx_addsy = NULL; /* No relocations please. */ + } + else + { + switch (add_symbol_segment) + { + case SEG_ABSOLUTE: #ifdef TC_I960 - reloc_callj(fixP); /* See comment about reloc_callj() above*/ + reloc_callj (fixP); /* See comment about reloc_callj() above*/ #endif /* TC_I960 */ - add_number += S_GET_VALUE(add_symbolP); - fixP->fx_addsy = NULL; - add_symbolP = NULL; - break; - default: - seg_reloc_count ++; - add_number += S_GET_VALUE(add_symbolP); - break; - - case SEG_UNKNOWN: + add_number += S_GET_VALUE (add_symbolP); + fixP->fx_addsy = NULL; + add_symbolP = NULL; + break; + default: + seg_reloc_count++; + add_number += S_GET_VALUE (add_symbolP); + break; + + case SEG_UNKNOWN: #ifdef TC_I960 - if ((int)fixP->fx_bit_fixP == 13) { - /* This is a COBR instruction. They have only a + if ((int) fixP->fx_bit_fixP == 13) + { + /* This is a COBR instruction. They have only a * 13-bit displacement and are only to be used * for local branches: flag as error, don't generate * relocation. */ - as_bad("can't use COBR format with external label"); - fixP->fx_addsy = NULL; /* No relocations please. */ - continue; - } /* COBR */ + as_bad ("can't use COBR format with external label"); + fixP->fx_addsy = NULL; /* No relocations please. */ + continue; + } /* COBR */ #endif /* TC_I960 */ #ifdef OBJ_COFF #ifdef TE_I386AIX - if (S_IS_COMMON(add_symbolP)) - add_number += S_GET_VALUE(add_symbolP); + if (S_IS_COMMON (add_symbolP)) + add_number += S_GET_VALUE (add_symbolP); #endif /* TE_I386AIX */ #endif /* OBJ_COFF */ - ++seg_reloc_count; - - break; - - - } /* switch on symbol seg */ - } /* if not in local seg */ - } /* if there was a + symbol */ - - if (pcrel) { - add_number -= md_pcrel_from(fixP); - if (add_symbolP == 0) { - fixP->fx_addsy = & abs_symbol; - ++seg_reloc_count; - } /* if there's an add_symbol */ - } /* if pcrel */ - - if (!fixP->fx_bit_fixP) { - if ((size==1 && - (add_number& ~0xFF) && ((add_number&~0xFF)!=(-1&~0xFF))) || - (size==2 && - (add_number& ~0xFFFF) && ((add_number&~0xFFFF)!=(-1&~0xFFFF)))) { - as_bad("Value of %d too large for field of %d bytes at 0x%x", - add_number, size, fragP->fr_address + where); - } /* generic error checking */ - } /* not a bit fix */ - - md_apply_fix(fixP, add_number); - } /* For each fixS in this segment. */ - + ++seg_reloc_count; + + break; + + + } /* switch on symbol seg */ + } /* if not in local seg */ + } /* if there was a + symbol */ + + if (pcrel) + { + add_number -= md_pcrel_from (fixP); + if (add_symbolP == 0) + { + fixP->fx_addsy = &abs_symbol; + ++seg_reloc_count; + } /* if there's an add_symbol */ + } /* if pcrel */ + + if (!fixP->fx_bit_fixP) + { + if ((size == 1 && + (add_number & ~0xFF) && ((add_number & ~0xFF) != (-1 & ~0xFF))) || + (size == 2 && + (add_number & ~0xFFFF) && ((add_number & ~0xFFFF) != (-1 & ~0xFFFF)))) + { + as_bad ("Value of %d too large for field of %d bytes at 0x%x", + add_number, size, fragP->fr_address + where); + } /* generic error checking */ +#ifdef WARN_SIGNED_OVERFLOW_WORD + /* 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'] + && size == 2 + && add_number > 0x7fff) + as_bad ("Signed .word overflow; switch may be too large; %d at 0x%x", + add_number, fragP->fr_address + where); +#endif + } /* not a bit fix */ + + md_apply_fix (fixP, add_number); + } /* For each fixS in this segment. */ + #ifdef OBJ_COFF #ifdef TC_I960 - { - fixS *topP = fixP; - - /* two relocs per callj under coff. */ - for (fixP = topP; fixP; fixP = fixP->fx_next) { - if (fixP->fx_callj && fixP->fx_addsy != 0) { - ++seg_reloc_count; - } /* if callj and not already fixed. */ - } /* for each fix */ - } + { + fixS *topP = fixP; + + /* two relocs per callj under coff. */ + for (fixP = topP; fixP; fixP = fixP->fx_next) + { + if (fixP->fx_callj && fixP->fx_addsy != 0) + { + ++seg_reloc_count; + } /* if callj and not already fixed. */ + } /* for each fix */ + } #endif /* TC_I960 */ - + #endif /* OBJ_COFF */ - return(seg_reloc_count); -} /* fixup_segment() */ + return (seg_reloc_count); +} /* fixup_segment() */ -static int is_dnrange(f1,f2) -struct frag *f1; -struct frag *f2; +static int +is_dnrange (f1, f2) + struct frag *f1; + struct frag *f2; { - while (f1) { - if (f1->fr_next==f2) - return 1; - f1=f1->fr_next; - } - return 0; -} /* is_dnrange() */ + while (f1) + { + if (f1->fr_next == f2) + return 1; + f1 = f1->fr_next; + } + return 0; +} /* is_dnrange() */ /* Append a string onto another string, bumping the pointer along. */ void - append (charPP, fromP, length) -char **charPP; -char *fromP; -unsigned long length; +append (charPP, fromP, length) + char **charPP; + char *fromP; + unsigned long length; { - if (length) { /* Don't trust memcpy() of 0 chars. */ - memcpy(*charPP, fromP, (int) length); - *charPP += length; - } + if (length) + { /* Don't trust memcpy() of 0 chars. */ + memcpy (*charPP, fromP, (int) length); + *charPP += length; + } } int section_alignment[SEG_MAXIMUM_ORDINAL]; @@ -1213,19 +1315,21 @@ int section_alignment[SEG_MAXIMUM_ORDINAL]; * boundary, all of the other alignments within it will work. At * least one object format really uses this info. */ -void record_alignment(seg, align) -segT seg; /* Segment to which alignment pertains */ -int align; /* Alignment, as a power of 2 +void +record_alignment (seg, align) + segT seg; /* Segment to which alignment pertains */ + int align; /* Alignment, as a power of 2 * (e.g., 1 => 2-byte boundary, 2 => 4-byte boundary, etc.) */ { - - if ( align > section_alignment[(int) seg] ){ - section_alignment[(int) seg] = align; - } /* if highest yet */ - - return; -} /* record_alignment() */ + + if (align > section_alignment[(int) seg]) + { + section_alignment[(int) seg] = align; + } /* if highest yet */ + + return; +} /* record_alignment() */ /* * Local Variables: diff --git a/gas/write.h b/gas/write.h index 0b47dcb..b14a25e 100644 --- a/gas/write.h +++ b/gas/write.h @@ -1,19 +1,19 @@ /* write.h Copyright (C) 1987, 1992 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. */ @@ -28,7 +28,7 @@ #ifdef DOT_LABEL_PREFIX #define LOCAL_LABEL(name) (name[0] =='.' \ && ( name [1] == 'L' || name [1] == '.' )) -#else /* not defined DOT_LABEL_PREFIX */ +#else /* not defined DOT_LABEL_PREFIX */ #define LOCAL_LABEL(name) (name [0] == 'L' ) #endif /* not defined DOT_LABEL_PREFIX */ #endif /* LOCAL_LABEL */ @@ -41,28 +41,29 @@ * FixSs may be built up in any order. */ -struct fix { - fragS *fx_frag; /* Which frag? */ - long fx_where; /* Where is the 1st byte to fix up? */ - symbolS *fx_addsy; /* NULL or Symbol whose value we add in. */ - symbolS *fx_subsy; /* NULL or Symbol whose value we subtract. */ - long fx_offset; /* Absolute number we add in. */ - struct fix *fx_next; /* NULL or -> next fixS. */ - short int fx_size; /* How many bytes are involved? */ - char fx_pcrel; /* TRUE: pc-relative. */ - char fx_pcrel_adjust; /* pc-relative offset adjust */ - char fx_im_disp; /* TRUE: value is a displacement */ - bit_fixS *fx_bit_fixP; /* IF NULL no bitfix's to do */ - char fx_bsr; /* sequent-hack */ +struct fix + { + fragS *fx_frag; /* Which frag? */ + long fx_where; /* Where is the 1st byte to fix up? */ + symbolS *fx_addsy; /* NULL or Symbol whose value we add in. */ + symbolS *fx_subsy; /* NULL or Symbol whose value we subtract. */ + long fx_offset; /* Absolute number we add in. */ + struct fix *fx_next; /* NULL or -> next fixS. */ + short int fx_size; /* How many bytes are involved? */ + char fx_pcrel; /* TRUE: pc-relative. */ + char fx_pcrel_adjust; /* pc-relative offset adjust */ + char fx_im_disp; /* TRUE: value is a displacement */ + bit_fixS *fx_bit_fixP; /* IF NULL no bitfix's to do */ + char fx_bsr; /* sequent-hack */ #if defined(TC_SPARC) || defined(TC_A29K) || defined(NEED_FX_R_TYPE) - /* Hacks for machines where the type of reloc can't be + /* Hacks for machines where the type of reloc can't be worked out by looking at how big it is */ - int fx_r_type; + int fx_r_type; #endif - char fx_callj; /* TRUE if target is a 'callj' (used by i960) */ - long fx_addnumber; -}; + char fx_callj; /* TRUE if target is a 'callj' (used by i960) */ + long fx_addnumber; + }; typedef struct fix fixS; @@ -71,7 +72,7 @@ COMMON char *next_object_file_charP; #ifndef MANY_SEGMENTS COMMON fixS *text_fix_root, *text_fix_tail; /* Chains fixSs. */ COMMON fixS *data_fix_root, *data_fix_tail; /* Chains fixSs. */ -COMMON fixS *bss_fix_root, *bss_fix_tail; /* Chains fixSs. */ +COMMON fixS *bss_fix_root, *bss_fix_tail; /* Chains fixSs. */ #endif COMMON fixS **seg_fix_rootP, **seg_fix_tailP; /* -> one of above. */ extern long string_byte_count; @@ -79,30 +80,27 @@ extern int section_alignment[]; #if __STDC__ == 1 -bit_fixS *bit_fix_new(int size, int offset, long base_type, long base_adj, long min, long max, long add); -void append(char **charPP, char *fromP, unsigned long length); -void record_alignment(segT seg, int align); -void write_object_file(void); - -fixS *fix_new(fragS *frag, - int where, - int size, - symbolS *add_symbol, - symbolS *sub_symbol, - long offset, - int pcrel -#if defined(TC_SPARC) || defined(TC_A29K) || defined(NEED_FX_R_TYPE) - , int r_type -#endif -); +bit_fixS *bit_fix_new (int size, int offset, long base_type, long base_adj, long min, long max, long add); +void append (char **charPP, char *fromP, unsigned long length); +void record_alignment (segT seg, int align); +void write_object_file (void); + +fixS *fix_new (fragS * frag, + int where, + int size, + symbolS * add_symbol, + symbolS * sub_symbol, + long offset, + int pcrel, + int r_type); #else /* not __STDC__ */ -bit_fixS *bit_fix_new(); -fixS *fix_new(); -void append(); -void record_alignment(); -void write_object_file(); +bit_fixS *bit_fix_new (); +fixS *fix_new (); +void append (); +void record_alignment (); +void write_object_file (); #endif /* not __STDC__ */ diff --git a/gas/xmalloc.c b/gas/xmalloc.c index 99b2fa2..d5378d5 100644 --- a/gas/xmalloc.c +++ b/gas/xmalloc.c @@ -1,19 +1,19 @@ /* xmalloc.c - get memory or bust Copyright (C) 1987, 1990, 1991, 1992 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. */ @@ -23,22 +23,22 @@ xmalloc() - get memory or bust INDEX xmalloc() uses malloc() - + SYNOPSIS char * my_memory; - + my_memory = xmalloc(42); / * my_memory gets address of 42 chars * / - + DESCRIPTION - + Use xmalloc() as an "error-free" malloc(). It does almost the same job. When it cannot honour your request for memory it BOMBS your program with a "virtual memory exceeded" message. Malloc() returns NULL and does not bomb your program. - + SEE ALSO malloc() - + */ #include <stdio.h> @@ -48,23 +48,24 @@ #ifdef USG #include <malloc.h> #else -char * malloc(); +char *malloc (); #endif /* USG */ #endif /* not __STDC__ */ #define error as_fatal -char * xmalloc(n) -long n; +char * +xmalloc (n) + long n; { - char * retval; - void error(); - - if ((retval = malloc ((unsigned)n)) == NULL) - { - error("virtual memory exceeded"); - } - return (retval); + char *retval; + void error (); + + if ((retval = malloc ((unsigned) n)) == NULL) + { + error ("virtual memory exceeded"); + } + return (retval); } /* end of xmalloc.c */ diff --git a/gas/xrealloc.c b/gas/xrealloc.c index 6c7f460..a7da9f2 100644 --- a/gas/xrealloc.c +++ b/gas/xrealloc.c @@ -1,43 +1,43 @@ /* xrealloc.c - new memory or bust Copyright (C) 1987, 1990, 1991, 1992 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. */ -/* - +/* + NAME xrealloc () - get more memory or bust INDEX xrealloc () uses realloc () SYNOPSIS char *my_memory; - + my_memory = xrealloc (my_memory, 42); / * my_memory gets (perhaps new) address of 42 chars * / - + DESCRIPTION - + Use xrealloc () as an "error-free" realloc ().It does almost the same job. When it cannot honour your request for memory it BOMBS your program with a "virtual memory exceeded" message. Realloc() returns NULL and does not bomb your program. - + SEE ALSO realloc () */ @@ -48,22 +48,22 @@ #ifdef USG #include <malloc.h> #else -char *realloc (); +char *realloc (); #endif /* USG */ #endif /* not __STDC__ */ #define error as_fatal -char * - xrealloc (ptr, n) -register char *ptr; -long n; +char * +xrealloc (ptr, n) + register char *ptr; + long n; { - void error(); - - if ((ptr = realloc (ptr, (unsigned)n)) == 0) - error ("virtual memory exceeded"); - return (ptr); + void error (); + + if ((ptr = realloc (ptr, (unsigned) n)) == 0) + error ("virtual memory exceeded"); + return (ptr); } /* end of xrealloc.c */ |