fighting bitrot in a major way

This commit is contained in:
K. Richard Pixley 1992-02-17 15:54:49 +00:00
parent af21362450
commit 542e1629fd
27 changed files with 6024 additions and 6662 deletions

View File

@ -37,6 +37,10 @@ README
README-quirks
README-vms-dbg
README.coff
obstack.h
obstack.c
bit_fix.h
strerror.c
README.rich
a.out.gnu.h
app.c
@ -101,7 +105,10 @@ echo Done in `pwd`.
#
#
# $Log$
# Revision 1.8 1992/02/14 00:21:34 pesch
# Revision 1.9 1992/02/17 15:52:52 rich
# fighting bitrot in a major way
#
# Revision 1.8 1992/02/14 00:21:34 pesch
# It's OK to keep the doc subdirectory, really.
#
# Revision 1.7 1992/02/13 10:13:19 rich

File diff suppressed because it is too large Load Diff

View File

@ -17,8 +17,6 @@
#along with GNU GAS; see the file COPYING. If not, write to
#the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
# $Id$
# The targets for external use include:
# all, doc, proto, install, uninstall, includes, TAGS,
# clean, cleanconfig, realclean, stage1, stage2, stage3, stage4.
@ -59,57 +57,6 @@ BISON = bison
MAKEINFO = makeinfo
RANLIB = ranlib
# Version of ar to use when compiling gnulib.
OLDAR = ar
# Additional system libraries to link with.
CLIB=
# Specify the rule for actually making gnulib.
GNULIB = gnulib.portable
# Specify the rule for actually making gnulib2.
GNULIB2 = gnulib2.portable
# List of extra C and assembler files to add to gnulib.
# Assembler files should have names ending in `.asm'.
LIBFUNCS_EXTRA =
# Program to convert libraries.
LIBCONVERT =
# Control whether header files are installed.
INSTALL_HEADERS=install-headers
# Change this to empty to prevent installing limits.h
LIMITS_H = limits.h
# Directory to link to, when using the target `maketest'.
DIR = ../gcc
# For better debugging under COFF, define SEPARATE_AUX_OUTPUT in config.h
# and define the following variable as `aux-output2.c' in make-...
AUX_OUTPUT2 =
# Flags to use when cross-building GCC.
# Prefix to apply to names of object files when using them
# to run on the machine we are compiling on.
HOST_PREFIX=
# Prefix to apply to names of object files when compiling them
# to run on the machine we are compiling on.
# The default for this variable is chosen to keep these rules
# out of the way of the other rules for compiling the same source files.
HOST_PREFIX_1=loser-
HOST_CC=$(CC)
HOST_CFLAGS=$(ALL_CFLAGS)
HOST_LDFLAGS=$(LDFLAGS)
HOST_CPPFLAGS=$(CPPFLAGS)
# Choose the real default target.
ALL=as.new
# End of variables for you to override.
# Lists of files for various purposes.
REAL_SOURCES = \
@ -128,8 +75,10 @@ REAL_SOURCES = \
$(srcdir)/input-file.c \
$(srcdir)/input-scrub.c \
$(srcdir)/messages.c \
$(srcdir)/obstack.c \
$(srcdir)/output-file.c \
$(srcdir)/read.c \
$(srcdir)/strerror.c \
$(srcdir)/strstr.c \
$(srcdir)/subsegs.c \
$(srcdir)/symbols.c \
@ -155,8 +104,10 @@ REAL_HEADERS = \
$(srcdir)/frags.h \
$(srcdir)/hash.h \
$(srcdir)/input-file.h \
$(srcdir)/listing.h \
$(srcdir)/tc.h \
$(srcdir)/obj.h \
$(srcdir)/obstack.h \
$(srcdir)/read.h \
$(srcdir)/struc-symbol.h \
$(srcdir)/subsegs.h \
@ -194,8 +145,10 @@ OBJS = \
input-file.o \
input-scrub.o \
messages.o \
obstack.o \
output-file.o \
read.o \
strerror.o \
strstr.o \
subsegs.o \
symbols.o \
@ -207,41 +160,19 @@ OBJS = \
#### host, target, and site specific Makefile frags come in here.
# Definition of `all' is here so that new rules inserted by sed
# do not specify the default target.
# The real definition is under `all.internal'.
all: $(ALL)
all: as.new
info:
install-info:
fake-as: force
- rm -f ./as.new
cp /bin/as ./fake-as
cp ./fake-as ./as.new
# Now figure out from those variables how to compile and link.
# This is the variable actually used when we compile.
ALL_CFLAGS = -g $(INTERNAL_CFLAGS) $(CFLAGS) $(HDEFINES) $(TDEFINES)
# Even if ALLOCA is set, don't use it if compiling with GCC.
USE_ALLOCA= `if [ x"${CC}" = x"${OLDCC}" ] ; then echo ${ALLOCA}; else true; fi`
USE_HOST_ALLOCA= `if [ x"${CC}" = x"${OLDCC}" ] ; then echo ${HOST_PREFIX}${ALLOCA}; else true; fi`
# Likewise, for use in the tools that must run on this machine
# even if we are cross-building GCC.
# We don't use USE_ALLOCA because backquote expansion doesn't work in deps.
HOST_LIBDEPS= $(HOST_PREFIX)$(OBSTACK) $(HOST_PREFIX)$(ALLOCA) $(HOST_PREFIX)$(MALLOC)
# How to link with both our special library facilities
# and the system's installed libraries.
LIBS = $(LOCAL_LOADLIBES) $(CLIB) $(unsubdir)/../libiberty$(subdir)/libiberty.a
# Likewise, for use in the tools that must run on this machine
# even if we are cross-building GCC.
HOST_LIBS = $(HOST_PREFIX)$(OBSTACK) $(USE_HOST_ALLOCA) $(HOST_PREFIX)$(MALLOC) $(CLIB)
LIBS = $(LOCAL_LOADLIBES) $(CLIB) # ../libiberty/libiberty.a
# Specify the directories to be searched for header files.
# Both . and srcdir are used, in that order,
@ -257,36 +188,18 @@ SUBDIR_INCLUDES = -I.. -I$(srcdir) -I$(srcdir)/config
# This tells GNU make version 3 not to export all the variables
# defined in this file into the environment.
.NOEXPORT:
# Files to be copied away after each stage in building.
STAGE_GCC=gcc
STAGESTUFF = *.o as.new
# The files that "belong" in CONFIG_H are deliberately omitted
# because having them there would not be useful in actual practice.
# All they would do is cause complete recompilation every time
# one of the machine description files is edited.
# That may or may not be what one wants to do.
# If it is, rm *.o is an easy way to do it.
# CONFIG_H = config.h tm.h
CONFIG_H =
as.new: $(OBJS) $(LIBDEPS)
-mv -f as.new as.old
$(CC) $(ALL_CFLAGS) $(LDFLAGS) -o as.new $(OBJS) $(LIBS) $(LOADLIBES)
objdump:
all.internal: native
# This is what is made with the host's compiler if making a cross assembler.
native: config.status as
config.status:
@echo You must configure gas. Look at the INSTALL file for details.
@false
compilations: ${OBJS}
# Compiling object files from source files.
app.o : app.c as.h host.h targ-env.h obj-format.h \
@ -380,26 +293,6 @@ targ-cpu.o : targ-cpu.c targ-env.h obj-format.h \
write.h flonum.h bignum.h expr.h frags.h hash.h read.h \
symbols.h tc.h obj.h $(TARG_CPU_DEPENDENTS)
# Compile the libraries to be used by gen*.
# If we are not cross-building, gen* use the same .o's that cc1 will use,
# and HOST_PREFIX_1 is `foobar', just to ensure these rules don't conflict
# with the rules for rtl.o, alloca.o, etc.
$(HOST_PREFIX_1)alloca.o: alloca.c
rm -f $(HOST_PREFIX)alloca.c
cp $(srcdir)/alloca.c $(HOST_PREFIX)alloca.c
$(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(HOST_PREFIX)alloca.c
$(HOST_PREFIX_1)obstack.o: obstack.c
rm -f $(HOST_PREFIX)obstack.c
cp $(srcdir)/obstack.c $(HOST_PREFIX)obstack.c
$(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(HOST_PREFIX)obstack.c
$(HOST_PREFIX_1)malloc.o: malloc.c
rm -f $(HOST_PREFIX)malloc.c
cp $(srcdir)/malloc.c $(HOST_PREFIX)malloc.c
$(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(HOST_PREFIX)malloc.c
# Remake the info files.
doc: $(srcdir)/as.info
@ -407,37 +300,26 @@ doc: $(srcdir)/as.info
$(srcdir)/as.info: $(srcdir)/doc/as.texinfo
(cd doc; make as.info; mv as.info $srcdir)
# Deletion of files made during compilation.
# There are three levels of this: `clean', `cleanconfig' and `realclean'.
# `clean' deletes what you want to delete ordinarily to save space.
# This is most, but not all, of the files made by compilation.
# `cleanconfig' also deletes everything depending
# on the choice of config files.
# `realclean' also deletes everything that could be regenerated automatically.
clean:
-rm -f $(STAGESTUFF) $(HOST_PREFIX_1)alloca.c $(HOST_PREFIX_1)malloc.c $(HOST_PREFIX_1)obstack.c core
-rm -f $(STAGESTUFF) core
# Like clean but also delete the links made to configure gas.
cleanconfig: clean
-rm -f config.status Makefile host.h targ-env.h
-rm -f targ-cpu.h targ-cpu.c
-rm -f obj-format.h obj-format.c
-rm -f atof-targ.c
distclean: clean
-rm -f config.status Makefile host.h targ-env.h targ-cpu.h \
targ-cpu.c obj-format.h obj-format.c atof-targ.c \
gas.aux gas.cps gas.fns gas.info gas.kys gas.pgs
gas.tps gas.vrs TAGS gas.info* gas.?? gas.??s gas.log \
gas.toc gas.*aux *.dvi
# Get rid of every file that's generated from some other file (except INSTALL).
realclean: cleanconfig
-rm -f gas.aux gas.cps gas.fns gas.info gas.kys gas.pgs gas.tps gas.vrs
-rm -f TAGS
-rm -f gas.info* gas.?? gas.??s gas.log gas.toc gas.*aux
-rm -f *.dvi
# Entry points `install', `includes' and `uninstall'.
# Copy the files into directories where they will be run.
install: $(ALL)
$(INSTALL_PROGRAM) $(ALL) $(bindir)/as
install:
if [ "$(host_alias)" = "$(target_alias)" ] ; then \
$(INSTALL_PROGRAM) as.new $(bindir)/as ; \
else \
$(INSTALL_PROGRAM) as.new $(bindir)/as-$(target_alias) ; \
fi
# Create the installation directory.
install-dir:
@ -446,50 +328,33 @@ install-dir:
-mkdir $(libdir)/gcc/$(target)
-mkdir $(libdir)/gcc/$(target)/$(version)
# Install the compiler executables built during cross compilation.
install-cross: native install-dir
-if [ -f cc1 ] ; then $(INSTALL_PROGRAM) cc1 $(libsubdir)/cc1; else true; fi
-if [ -f cc1plus ] ; then $(INSTALL_PROGRAM) cc1plus $(libsubdir)/cc1plus; else true; fi
$(INSTALL_PROGRAM) cpp $(libsubdir)/cpp
./gcc -dumpspecs > $(libsubdir)/specs
$(INSTALL_PROGRAM) gcc $(bindir)/gcc
# Install the man pages.
install-man: install-dir $(srcdir)/gcc.1 protoize.1 unprotoize.1
$(INSTALL_FILE) $(srcdir)/gcc.1 $(mandir)/gcc.$(manext)
chmod a-x $(mandir)/gcc.$(manext)
$(INSTALL_FILE) $(srcdir)/protoize.1 $(mandir)/protoize.$(manext)
chmod a-x $(mandir)/protoize.$(manext)
$(INSTALL_FILE) $(srcdir)/unprotoize.1 $(mandir)/unprotoize.$(manext)
chmod a-x $(mandir)/unprotoize.$(manext)
# Cancel installation by deleting the installed files.
uninstall:
-rm -rf $(libsubdir)
-rm -rf $(bindir)/as
-rm -rf $(mandir)/gas.$(manext)
# These exist for maintenance purposes.
tags TAGS: force
etags $(REAL_SOURCES) $(REAL_HEADERS) $(srcdir)/README $(srcdir)/Makefile $(srcdir)/config/*.[hc]
bootstrap: $(ALL) force
bootstrap: as.new force
$(MAKE) stage1
$(MAKE) CC="$(CC)" CFLAGS="-O -Bstage1/ $(CFLAGS)" libdir=$(libdir) ALLOCA= $(ALL)
$(MAKE) CC="$(CC)" CFLAGS="-O -Bstage1/ $(CFLAGS)" libdir=$(libdir) ALLOCA= as.new
$(MAKE) stage2
$(MAKE) CC="$(CC)" CFLAGS="-O -Bstage2/ $(CFLAGS)" libdir=$(libdir) ALLOCA= $(ALL)
$(MAKE) CC="$(CC)" CFLAGS="-O -Bstage2/ $(CFLAGS)" libdir=$(libdir) ALLOCA= as.new
$(MAKE) comparison against=stage2
bootstrap2: force
$(MAKE) CC="$(CC)" CFLAGS="-O -Bstage1/ $(CFLAGS)" libdir=$(libdir) ALLOCA= $(ALL)
$(MAKE) CC="$(CC)" CFLAGS="-O -Bstage1/ $(CFLAGS)" libdir=$(libdir) ALLOCA= as.new
$(MAKE) stage2
$(MAKE) CC="$(CC)" CFLAGS="-O -Bstage2/ $(CFLAGS)" libdir=$(libdir) ALLOCA= $(ALL)
$(MAKE) CC="$(CC)" CFLAGS="-O -Bstage2/ $(CFLAGS)" libdir=$(libdir) ALLOCA= as.new
$(MAKE) comparison against=stage2
bootstrap3: force
$(MAKE) CC="$(CC)" CFLAGS="-O -Bstage2/ $(CFLAGS)" libdir=$(libdir) ALLOCA= $(ALL)
$(MAKE) CC="$(CC)" CFLAGS="-O -Bstage2/ $(CFLAGS)" libdir=$(libdir) ALLOCA= as.new
$(MAKE) comparison against=stage2
# Copy the object files from a particular stage into a subdirectory.
@ -525,40 +390,8 @@ de-stage3: force
- (cd stage3 ; rm as ; mv -f * ..)
- rmdir stage3
# Copy just the executable files from a particular stage into a subdirectory,
# and delete the object files. Use this if you're just verifying a version
# that is pretty sure to work, and you are short of disk space.
risky-stage1: force
-mkdir stage1
-mv cc1 cpp cccp gcc stage1
-rm -f stage1/gnulib
-cp gnulib stage1 && $(RANLIB) stage1/gnulib
-make clean
risky-stage2: force
-mkdir stage2
-mv cc1 cpp cccp gcc stage2
-rm -f stage2/gnulib
-cp gnulib stage2 && $(RANLIB) stage2/gnulib
-make clean
risky-stage3: force
-mkdir stage3
-mv cc1 cpp cccp gcc stage3
-rm -f stage3/gnulib
-cp gnulib stage3 && $(RANLIB) stage3/gnulib
-make clean
risky-stage4: force
-mkdir stage4
-mv cc1 cpp cccp gcc stage4
-rm -f stage4/gnulib
-cp gnulib stage4 && $(RANLIB) stage4/gnulib
-make clean
#In GNU Make, ignore whether `stage*' exists.
.PHONY: stage1 stage2 stage3 stage4 clean realclean TAGS bootstrap
.PHONY: risky-stage1 risky-stage2 risky-stage3 risky-stage4
force:

View File

@ -1,19 +1,20 @@
to do:
remove DONTDEF
fucked up on a.out.gnu.h, etc.
fucked up on foo-opcode.h.
remove the ifdef's from fx_callj tests?
what are callj tests?
search for (), build prototypes.
space tighten sparc alignment.
convert md_ri_to_chars to not pass structs.
convert md_ri_to_chars to emit fixP's.
fix number_to_chars, & family to have no side effects.
prototype.
md_ => tp_
use CROSS_ASSEMBLE
multiple segments.
share b.out with a.out.
regress:
+-inf
stack:

View File

@ -19,11 +19,6 @@
#include "as.h"
#ifdef USG
#define bzero(s,n) memset(s,0,n)
#define bcopy(from,to,n) memcpy(to,from,n)
#endif
/*
* bignum_copy ()
*
@ -31,7 +26,7 @@
* If the output is shorter than the input, copy lower-order littlenums.
* Return 0 or the number of significant littlenums dropped.
* Assumes littlenum arrays are densely packed: no unused chars between
* the littlenums. Uses bcopy() to move littlenums, and wants to
* the littlenums. Uses memcpy() to move littlenums, and wants to
* know length (in chars) of the input bignum.
*/
@ -49,7 +44,7 @@ register int out_length; /* in sizeof(littlenum)s */
LITTLENUM_TYPE *p; /* -> most significant (non-zero) input
littlenum. */
bcopy((char *) in, (char *) out,
memcpy((void *) out, (void *) in,
out_length << LITTLENUM_SHIFT);
for (p = in + in_length - 1; p >= in; --p) {
if (* p) break;
@ -60,12 +55,12 @@ register int out_length; /* in sizeof(littlenum)s */
significant_littlenums_dropped = 0;
}
} else {
bcopy((char *) in, (char *) out,
memcpy((char *) out, (char *) in,
in_length << LITTLENUM_SHIFT);
if (out_length > in_length) {
bzero((char *) (out + out_length),
(out_length - in_length) << LITTLENUM_SHIFT);
memset((char *) (out + out_length),
'\0', (out_length - in_length) << LITTLENUM_SHIFT);
}
significant_littlenums_dropped = 0;

50
gas/bit_fix.h Normal file
View File

@ -0,0 +1,50 @@
/* 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. */
/* The bit_fix was implemented to support machines that need variables
to be inserted in bitfields other than 1, 2 and 4 bytes.
Furthermore it gives us a possibillity to mask in bits in the symbol
when it's fixed in the objectcode and check the symbols limits.
The or-mask is used to set the huffman bits in displacements for the
ns32k port.
The acbi, addqi, movqi, cmpqi instruction requires an assembler that
can handle bitfields. Ie handle an expression, evaluate it and insert
the result in an some bitfield. ( ex: 5 bits in a short field of a opcode)
*/
#ifndef __bit_fix_h__
#define __bit_fix_h__
struct bit_fix {
int fx_bit_size; /* Length of bitfield */
int fx_bit_offset; /* Bit offset to bitfield */
long fx_bit_base; /* Where do we apply the bitfix.
If this is zero, default is assumed. */
long fx_bit_base_adj; /* Adjustment of base */
long fx_bit_max; /* Signextended max for bitfield */
long fx_bit_min; /* Signextended min for bitfield */
long fx_bit_add; /* Or mask, used for huffman prefix */
};
typedef struct bit_fix bit_fixS;
#endif /* __bit_fix_h__ */
/* end of bit_fix.h */

View File

@ -32,9 +32,7 @@ atof-ieee.c
atof-vax.c
coff.gnu.h
cplus-dem.c
ho-a29k.h
ho-ansi.h
ho-cygnus.h
ho-decstation.h
ho-generic.h
ho-hpux.h
@ -46,8 +44,6 @@ ho-sun4.h
ho-sunos.h
ho-sysv.h
ho-vax.h
mh-a29k
mh-cygnus
mh-i386
mt-ebmon29k
mt-h8300
@ -128,7 +124,10 @@ echo Done in `pwd`.
#
#
# $Log$
# Revision 1.14 1992/02/13 10:13:24 rich
# Revision 1.15 1992/02/17 15:53:46 rich
# fighting bitrot in a major way
#
# Revision 1.14 1992/02/13 10:13:24 rich
# clean up Sanitize for gas
#
# Revision 1.13 1992/02/11 00:51:52 sac

View File

@ -25,6 +25,5 @@
#define sys_nerr _sys_nerr
#define sys_errlist _sys_errlist
#define bzero(b,l) (memset((b),0,(l)))
/* end of ho-ansi.h */

View File

@ -23,6 +23,8 @@
#define M_GENERIC 1
#define HAVE_STRERROR
extern int free();
/* end of ho-generic.h */

View File

@ -43,9 +43,6 @@ extern char *strchr();
extern char *strrchr();
extern int _filbuf();
extern int _flsbuf();
extern int bcopy();
extern int bzero();
extern int bzero();
extern int fclose();
extern int fgetc();
extern int fprintf();

View File

@ -19,8 +19,6 @@
#define HO_USG
#define bcopy(from,to,n) memcpy((to),(from),(n))
#define bzero(s,n) memset((s),0,(n))
#define setbuffer(stream, buf, size) setvbuf((stream), (buf), _IOLBF, (size))
extern int free();

View File

@ -597,7 +597,7 @@ symbolS *symbolP;
/* Additional information */
symbolP->sy_symbol.ost_flags = 0;
/* Auxiliary entries */
bzero((char*)&symbolP->sy_symbol.ost_auxent[0], AUXESZ);
memset((char*) &symbolP->sy_symbol.ost_auxent[0], '\0', AUXESZ);
#ifdef STRIP_UNDERSCORE
/* Remove leading underscore at the beginning of the symbol.
@ -749,7 +749,7 @@ static void
SKIP_WHITESPACES();
def_symbol_in_progress = (symbolS *) obstack_alloc(&notes, sizeof(*def_symbol_in_progress));
bzero(def_symbol_in_progress, sizeof(*def_symbol_in_progress));
memset(def_symbol_in_progress, '\0', sizeof(*def_symbol_in_progress));
symbol_name = input_line_pointer;
name_end = get_symbol_end();
@ -1269,8 +1269,8 @@ static unsigned int DEFUN_VOID(yank_symbols)
} /* make it at least 1 */
/* Clobber possible stale .dim information. */
bzero(symbolP->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_ary.x_dimen,
sizeof(symbolP->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_ary.x_dimen));
memset(symbolP->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_ary.x_dimen,
'\0', sizeof(symbolP->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_ary.x_dimen));
}
/* The C_FCN doesn't need any additional information.
I don't even know if this is needed for sdb. But the
@ -1947,7 +1947,7 @@ static void
S_SET_OFFSET(symbolP, symbolP->sy_name_offset);
S_SET_ZEROES(symbolP, 0);
} else {
bzero(symbolP->sy_symbol.ost_entry.n_name, SYMNMLEN);
memset(symbolP->sy_symbol.ost_entry.n_name, '\0', SYMNMLEN);
strncpy(symbolP->sy_symbol.ost_entry.n_name, temp, SYMNMLEN);
}
where = symbol_to_chars(abfd, where, symbolP);

View File

@ -437,7 +437,7 @@ char *str;
}
argsStart = s;
opcode = insn->opcode;
bzero(&the_insn, sizeof(the_insn));
memset(&the_insn, '\0', sizeof(the_insn));
the_insn.reloc = NO_RELOC;
/*
@ -900,20 +900,21 @@ register fragS *fragP;
/* should never be called for 29k */
void md_create_long_jump(ptr, from_addr, to_addr, frag, to_symbol)
char *ptr;
long from_addr,
to_addr;
long from_addr;
long to_addr;
fragS *frag;
symbolS *to_symbol;
{
as_fatal("sparc_create_long_jump\n");
}
/* should never be called for sparc */
/* should never be called for a29k */
int md_estimate_size_before_relax(fragP, segtype)
register fragS *fragP;
segT segtype;
{
as_fatal("sparc_estimate_size_before_relax\n");
return(0);
}
#if 0
@ -986,24 +987,22 @@ char *where;
fixS *fixP;
relax_addressT segment_address_in_file;
{
long r_index;
long r_symbolnum;
know(fixP->fx_r_type < NO_RELOC);
know(fixP->fx_addsy != NULL);
r_index = (S_IS_DEFINED(fixP->fx_addsy)
? S_GET_TYPE(fixP->fx_addsy)
: fixP->fx_addsy->sy_number);
/* this is easy */
md_number_to_chars(where,
fixP->fx_frag->fr_address + fixP->fx_where - segment_address_in_file,
4);
/* now the fun stuff */
where[4] = (r_index >> 16) & 0x0ff;
where[5] = (r_index >> 8) & 0x0ff;
where[6] = r_index & 0x0ff;
r_symbolnum = (S_IS_DEFINED(fixP->fx_addsy)
? S_GET_TYPE(fixP->fx_addsy)
: fixP->fx_addsy->sy_number);
where[4] = (r_symbolnum >> 16) & 0x0ff;
where[5] = (r_symbolnum >> 8) & 0x0ff;
where[6] = r_symbolnum & 0x0ff;
where[7] = (((!S_IS_DEFINED(fixP->fx_addsy)) << 7) & 0x80) | (0 & 0x60) | (fixP->fx_r_type & 0x1F);
/* Also easy */
md_number_to_chars(&where[8], fixP->fx_addnumber, 4);

View File

@ -19,15 +19,17 @@
#define TC_A29K
#define tc_headers_hook(a) ; /* not used */
#define tc_headers_hook(a) ; /* not used */
#define tc_crawl_symbol_chain(a) ; /* not used */
#define tc_coff_symbol_emit_hook(a) ; /* not used */
#define tc_aout_pre_write_hook(x) {;} /* not used */
#define tc_coff_symbol_emit_hook(a) {;} /* not used */
#define tc_crawl_symbol_chain(a) {;} /* not used */
#define tc_headers_hook(a) {;} /* not used */
#define tc_headers_hook(a) {;} /* not used */
#define AOUT_MACHTYPE 101
#define TC_COFF_FIX2RTYPE(fix_ptr) tc_coff_fix2rtype(fix_ptr)
#define BFD_ARCH bfd_arch_a29k
#define COFF_MAGIC SIPFBOMAGIC
/* Should the reloc be output ?
on the 29k, this is true only if there is a symbol attatched.
on the h8, this is allways true, since no fixup is done

View File

@ -34,46 +34,47 @@
typedef struct {
/* TM holds the template for the insn were currently assembling. */
template tm;
template tm;
/* SUFFIX holds the opcode suffix (e.g. 'l' for 'movl') if given. */
char suffix;
char suffix;
/* Operands are coded with OPERANDS, TYPES, DISPS, IMMS, and REGS. */
/* OPERANDS gives the number of given operands. */
unsigned int operands;
unsigned int operands;
/* REG_OPERANDS, DISP_OPERANDS, MEM_OPERANDS, IMM_OPERANDS give the number of
given register, displacement, memory operands and immediate operands. */
unsigned int reg_operands, disp_operands, mem_operands, imm_operands;
unsigned int reg_operands, disp_operands, mem_operands, imm_operands;
/* TYPES [i] is the type (see above #defines) which tells us how to
search through DISPS [i] & IMMS [i] & REGS [i] for the required
operand. */
unsigned int types [MAX_OPERANDS];
unsigned int types[MAX_OPERANDS];
/* Displacements (if given) for each operand. */
expressionS * disps [MAX_OPERANDS];
expressionS *disps[MAX_OPERANDS];
/* Immediate operands (if given) for each operand. */
expressionS * imms [MAX_OPERANDS];
expressionS *imms[MAX_OPERANDS];
/* Register operands (if given) for each operand. */
reg_entry * regs [MAX_OPERANDS];
reg_entry *regs[MAX_OPERANDS];
/* BASE_REG, INDEX_REG, and LOG2_SCALE_FACTOR are used to encode
the base index byte below. */
reg_entry * base_reg;
reg_entry * index_reg;
unsigned int log2_scale_factor;
reg_entry *base_reg;
reg_entry *index_reg;
unsigned int log2_scale_factor;
/* SEG gives the seg_entry of this insn. It is equal to zero unless
an explicit segment override is given. */
seg_entry * seg; /* segment for memory operands (if given) */
const seg_entry *seg; /* segment for memory operands (if given) */
/* PREFIX holds all the given prefix opcodes (usually null).
PREFIXES is the size of PREFIX. */
char prefix [MAX_PREFIXES];
unsigned int prefixes;
/* richfix: really unsigned? */
unsigned char prefix[MAX_PREFIXES];
unsigned int prefixes;
/* RM and IB are the modrm byte and the base index byte where the addressing
modes of this insn are encoded. */
@ -203,14 +204,28 @@ const relax_typeS md_relax_table[] = {
#if __STDC__ == 1
static char *output_invalid(int c);
static int fits_in_signed_byte(long num);
static int fits_in_signed_word(long num);
static int fits_in_unsigned_byte(long num);
static int fits_in_unsigned_word(long num);
static int i386_operand(char *operand_string);
static int smallest_imm_type(long num);
static reg_entry *parse_register(char *reg_string);
static unsigned long mode_from_disp_size(unsigned long t);
static unsigned long opcode_suffix_to_type(unsigned long s);
#else /* not __STDC__ */
static char *output_invalid();
static int fits_in_signed_byte();
static int fits_in_signed_word();
static int fits_in_unsigned_byte();
static int fits_in_unsigned_word();
static int i386_operand();
static int smallest_imm_type();
static reg_entry *parse_register();
static unsigned long mode_from_disp_size();
static unsigned long opcode_suffix_to_type();
#endif /* not __STDC__ */
@ -317,11 +332,11 @@ void md_begin ()
{
register unsigned int c;
bzero (opcode_chars, sizeof(opcode_chars));
bzero (operand_chars, sizeof(operand_chars));
bzero (space_chars, sizeof(space_chars));
bzero (identifier_chars, sizeof(identifier_chars));
bzero (digit_chars, sizeof(digit_chars));
memset(opcode_chars, '\0', sizeof(opcode_chars));
memset(operand_chars, '\0', sizeof(operand_chars));
memset(space_chars, '\0', sizeof(space_chars));
memset(identifier_chars, '\0', sizeof(identifier_chars));
memset(digit_chars, '\0', sizeof(digit_chars));
for (c = 0; c < 256; c++) {
if (islower(c) || isdigit(c)) {
@ -473,15 +488,15 @@ void md_assemble (line)
char *line;
{
/* Holds temlate once we've found it. */
register template * t;
register template *t;
/* Possible templates for current insn */
templates *current_templates = (templates *) 0;
/* Initialize globals. */
bzero (&i, sizeof(i));
bzero (disp_expressions, sizeof(disp_expressions));
bzero (im_expressions, sizeof(im_expressions));
memset(&i, '\0', sizeof(i));
memset(disp_expressions, '\0', sizeof(disp_expressions));
memset(im_expressions, '\0', sizeof(im_expressions));
save_stack_p = save_stack; /* reset stack pointer */
/* Fist parse an opcode & call i386_operand for the operands.
@ -638,12 +653,12 @@ char *line;
/* now *l must be either ',' or END_OF_INSN */
if (*l == ',') {
if (*++l == END_OF_INSN) { /* just skip it, if it's \n complain */
if (*++l == END_OF_INSN) { /* just skip it, if it's \n complain */
goto expecting_operand_after_comma;
}
expecting_operand = 1;
}
} while (*l != END_OF_INSN); /* until we get end of insn */
} while (*l != END_OF_INSN); /* until we get end of insn */
}
}
@ -676,7 +691,7 @@ char *line;
( ((t0 & t1 & (Reg)) == 0 && (m0 & m1 & (Reg)) == 0) || \
((t0 & t1) & (m0 & m1) & (Reg)) \
) : 1)
{
{
register unsigned int overlap0, overlap1;
expressionS * exp;
unsigned int overlap2;
@ -746,7 +761,7 @@ char *line;
}
/* Copy the template we found (we may change it!). */
bcopy (t, &i.tm, sizeof (template));
memcpy(&i.tm, t, sizeof(template));
t = &i.tm; /* alter new copy of template */
/* If there's no opcode suffix we try to invent one based on register
@ -917,7 +932,7 @@ char *line;
if (i.base_reg == esp && ! i.index_reg) {
/* <disp>(%esp) becomes two byte modrm with no index register. */
i.rm.regmem = ESCAPE_TO_TWO_BYTE_ADDRESSING;
i.rm.mode = MODE_FROM_DISP_SIZE (i.types[o]);
i.rm.mode = mode_from_disp_size(i.types[o]);
i.bi.base = ESP_REG_NUM;
i.bi.index = NO_INDEX_REGISTER;
i.bi.scale = 0; /* Must be zero! */
@ -929,7 +944,7 @@ char *line;
/* fake_zero_displacement code does not set this. */
i.types[o] |= Disp8;
}
i.rm.mode = MODE_FROM_DISP_SIZE (i.types[o]);
i.rm.mode = mode_from_disp_size(i.types[o]);
i.rm.regmem = EBP_REG_NUM;
} else if (! i.base_reg && (i.types[o] & BaseIndex)) {
/* There are three cases here.
@ -961,7 +976,7 @@ char *line;
} else {
/* It's not a special case; rev'em up. */
i.rm.regmem = i.base_reg->reg_num;
i.rm.mode = MODE_FROM_DISP_SIZE (i.types[o]);
i.rm.mode = mode_from_disp_size(i.types[o]);
if (i.index_reg) {
i.rm.regmem = ESCAPE_TO_TWO_BYTE_ADDRESSING;
i.bi.base = i.base_reg->reg_num;
@ -970,7 +985,7 @@ char *line;
if (i.base_reg == ebp && i.disp_operands == 0) { /* pace */
fake_zero_displacement = 1;
i.types[o] |= Disp8;
i.rm.mode = MODE_FROM_DISP_SIZE (i.types[o]);
i.rm.mode = mode_from_disp_size(i.types[o]);
}
}
}
@ -987,15 +1002,15 @@ char *line;
/* Select the correct segment for the memory operand. */
if (i.seg) {
const unsigned int seg_index;
const seg_entry * default_seg;
unsigned int seg_index;
const seg_entry *default_seg;
if (i.rm.regmem == ESCAPE_TO_TWO_BYTE_ADDRESSING) {
seg_index = (i.rm.mode<<3) | i.bi.base;
default_seg = two_byte_segment_defaults [seg_index];
default_seg = two_byte_segment_defaults[seg_index];
} else {
seg_index = (i.rm.mode<<3) | i.rm.regmem;
default_seg = one_byte_segment_defaults [seg_index];
default_seg = one_byte_segment_defaults[seg_index];
}
/* If the specified segment is not the default, use an
opcode prefix to select it */
@ -1054,12 +1069,12 @@ char *line;
switch (i.disps[0]->X_seg) {
case SEG_ABSOLUTE:
if (FITS_IN_SIGNED_BYTE (n)) {
if (fits_in_signed_byte(n)) {
p = frag_more (2);
p[0] = t->base_opcode;
p[1] = n;
#if 0 /* leave out 16 bit jumps - pace */
} else if (FITS_IN_SIGNED_WORD (n)) {
} else if (fits_in_signed_word(n)) {
p = frag_more (4);
p[0] = WORD_PREFIX_OPCODE;
p[1] = t->base_opcode;
@ -1106,7 +1121,7 @@ char *line;
int size = (t->opcode_modifier & JumpByte) ? 1 : 4;
int n = i.disps[0]->X_add_number;
if (FITS_IN_UNSIGNED_BYTE(t->base_opcode)) {
if (fits_in_unsigned_byte(t->base_opcode)) {
FRAG_APPEND_1_CHAR (t->base_opcode);
} else {
p = frag_more (2); /* opcode can be at most two bytes */
@ -1119,7 +1134,7 @@ char *line;
switch (i.disps[0]->X_seg) {
case SEG_ABSOLUTE:
md_number_to_chars (p, n, size);
if (size == 1 && ! FITS_IN_SIGNED_BYTE (n)) {
if (size == 1 && ! fits_in_signed_byte(n)) {
as_bad("loop/jecx only takes byte displacement; %d shortened to %d",
n, *p);
}
@ -1145,7 +1160,7 @@ char *line;
md_number_to_chars (p + 5, i.imms[0]->X_add_number, 2);
} else {
/* Output normal instructions here. */
register char *q;
unsigned char *q;
/* First the prefix bytes. */
for (q = i.prefix; q < i.prefix + i.prefixes; q++) {
@ -1154,9 +1169,9 @@ char *line;
}
/* Now the opcode; be careful about word order here! */
if (FITS_IN_UNSIGNED_BYTE(t->base_opcode)) {
if (fits_in_unsigned_byte(t->base_opcode)) {
FRAG_APPEND_1_CHAR (t->base_opcode);
} else if (FITS_IN_UNSIGNED_WORD(t->base_opcode)) {
} else if (fits_in_unsigned_word(t->base_opcode)) {
p = frag_more (2);
/* put out high byte first: can't use md_number_to_chars! */
*p++ = (t->base_opcode >> 8) & 0xff;
@ -1271,8 +1286,8 @@ char *operand_string;
char * end_of_operand_string = operand_string + strlen(operand_string);
/* Start and end of displacement string expression (if found). */
char * displacement_string_start = 0;
char * displacement_string_end;
char *displacement_string_start = NULL;
char *displacement_string_end = NULL;
/* We check for an absolute prefix (differentiating,
for example, 'jmp pc_relative_label' from 'jmp *absolute_label'. */
@ -1283,8 +1298,8 @@ char *operand_string;
/* Check if operand is a register. */
if (*op_string == REGISTER_PREFIX) {
register reg_entry * r;
if (! (r = parse_register (op_string))) {
register reg_entry *r;
if (!(r = parse_register (op_string))) {
as_bad("bad register name ('%s')", op_string);
return 0;
}
@ -1323,19 +1338,22 @@ char *operand_string;
i.regs[this_operand] = r;
i.reg_operands++;
} else if (*op_string == IMMEDIATE_PREFIX) { /* ... or an immediate */
char * save_input_line_pointer;
register expressionS *exp;
segT exp_seg;
char *save_input_line_pointer;
segT exp_seg = SEG_GOOF;
expressionS *exp;
if (i.imm_operands == MAX_IMMEDIATE_OPERANDS) {
as_bad("only 1 or 2 immediate operands are allowed");
return 0;
}
exp = &im_expressions[i.imm_operands++];
i.imms [this_operand] = exp;
i.imms[this_operand] = exp;
save_input_line_pointer = input_line_pointer;
input_line_pointer = ++op_string; /* must advance op_string! */
exp_seg = expression (exp);
exp_seg = expression(exp);
input_line_pointer = save_input_line_pointer;
switch (exp_seg) {
case SEG_ABSENT: /* missing or bad expr becomes absolute 0 */
as_bad("missing or invalid immediate expression '%s' taken as 0",
@ -1347,7 +1365,7 @@ char *operand_string;
i.types[this_operand] |= Imm;
break;
case SEG_ABSOLUTE:
i.types[this_operand] |= SMALLEST_IMM_TYPE (exp->X_add_number);
i.types[this_operand] |= smallest_imm_type(exp->X_add_number);
break;
case SEG_TEXT: case SEG_DATA: case SEG_BSS: case SEG_UNKNOWN:
i.types[this_operand] |= Imm32; /* this is an address ==> 32bit */
@ -1511,16 +1529,16 @@ char *operand_string;
assuming displacement_string_start and displacement_string_end
are meaningful. */
if (displacement_string_start) {
register expressionS * exp;
segT exp_seg;
char * save_input_line_pointer;
register expressionS *exp;
segT exp_seg = SEG_GOOF;
char *save_input_line_pointer;
exp = &disp_expressions[i.disp_operands];
i.disps [this_operand] = exp;
i.disp_operands++;
save_input_line_pointer = input_line_pointer;
input_line_pointer = displacement_string_start;
END_STRING_AND_SAVE (displacement_string_end);
exp_seg = expression (exp);
exp_seg = expression(exp);
if(*input_line_pointer)
as_bad("Ignoring junk '%s' after expression",input_line_pointer);
RESTORE_END_STRING (displacement_string_end);
@ -1641,10 +1659,11 @@ void
object_headers *headers;
register fragS * fragP;
{
register unsigned char * opcode;
unsigned char * where_to_put_displacement;
unsigned int target_address, opcode_address;
unsigned int extension;
register unsigned char *opcode;
unsigned char *where_to_put_displacement = NULL;
unsigned int target_address;
unsigned int opcode_address;
unsigned int extension = 0;
int displacement_from_opcode_start;
opcode = (unsigned char *) fragP -> fr_opcode;
@ -1860,26 +1879,24 @@ relax_addressT segment_address_in_file;
*/
static unsigned char nbytes_r_length [] = { 42, 0, 1, 42, 2 };
long r_index;
long r_symbolnum;
know(fixP->fx_addsy != NULL);
r_index = (S_IS_DEFINED(fixP->fx_addsy)
? S_GET_TYPE(fixP->fx_addsy)
: fixP->fx_addsy->sy_number);
/* this is easy */
md_number_to_chars(where,
fixP->fx_frag->fr_address + fixP->fx_where - segment_address_in_file,
4);
/* now the fun stuff */
where[4] = r_index & 0x0ff;
where[5] = (r_index >> 8) & 0x0ff;
where[6] = (r_index >> 16) & 0x0ff;
r_symbolnum = (S_IS_DEFINED(fixP->fx_addsy)
? S_GET_TYPE(fixP->fx_addsy)
: fixP->fx_addsy->sy_number);
where[6] = (r_symbolnum >> 16) & 0x0ff;
where[5] = (r_symbolnum >> 8) & 0x0ff;
where[4] = r_symbolnum & 0x0ff;
where[7] = ((((!S_IS_DEFINED(fixP->fx_addsy)) << 3) & 0x08)
| ((nbytes_r_length[fixP->fx_size] << 1) & 0x06)
| ((fixP->fx_pcrel << 0) & 0x01) & 0x0f);
| (((fixP->fx_pcrel << 0) & 0x01) & 0x0f));
return;
} /* tc_aout_fix_to_chars() */
@ -2006,6 +2023,66 @@ fixS *fixP;
return fixP->fx_size + fixP->fx_where + fixP->fx_frag->fr_address;
}
/* these were macros, but I don't trust macros that eval their
arguments more than once. Besides, gcc can static inline them.
xoxorich. */
static unsigned long mode_from_disp_size(t)
unsigned long t;
{
return((t & (Disp8))
? 1
: ((t & (Disp32)) ? 2 : 0));
} /* mode_from_disp_size() */
/* convert opcode suffix ('b' 'w' 'l' typically) into type specifyer */
static unsigned long opcode_suffix_to_type(s)
unsigned long s;
{
return(s == BYTE_OPCODE_SUFFIX
? Byte : (s == WORD_OPCODE_SUFFIX
? Word : DWord));
} /* opcode_suffix_to_type() */
static int fits_in_signed_byte(num)
long num;
{
return((num >= -128) && (num <= 127));
} /* fits_in_signed_byte() */
static int fits_in_unsigned_byte(num)
long num;
{
return((num & 0xff) == num);
} /* fits_in_unsigned_byte() */
static int fits_in_unsigned_word(num)
long num;
{
return((num & 0xffff) == num);
} /* fits_in_unsigned_word() */
static int fits_in_signed_word(num)
long num;
{
return((-32768 <= num) && (num <= 32767));
} /* fits_in_signed_word() */
static int smallest_imm_type(num)
long num;
{
return((num == 1)
? (Imm1|Imm8|Imm8S|Imm16|Imm32)
: (fits_in_signed_byte(num)
? (Imm8S|Imm8|Imm16|Imm32)
: (fits_in_unsigned_byte(num)
? (Imm8|Imm16|Imm32)
: ((fits_in_signed_word(num) || fits_in_unsigned_word(num))
? (Imm16|Imm32)
: (Imm32)))));
} /* smallest_imm_type() */
/*
* Local Variables:
* comment-column: 0

View File

@ -1,5 +1,5 @@
/* i386.h -- Header file for i386.c
Copyright (C) 1989, Free Software Foundation.
/* tc-i386.h -- Header file for tc-i386.c
Copyright (C) 1989, 1992 Free Software Foundation.
This file is part of GAS, the GNU Assembler.
@ -22,16 +22,19 @@
#define AOUT_MACHTYPE 100
#define REVERSE_SORT_RELOCS
#define tc_crawl_symbol_chain(a) ; /* not used */
#define tc_headers_hook(a) ; /* not used */
#define NO_LISTING
#define tc_aout_pre_write_hook(x) {;} /* not used */
#define tc_crawl_symbol_chain(a) {;} /* not used */
#define tc_headers_hook(a) {;} /* not used */
#define MAX_OPERANDS 3 /* max operands per insn */
#define MAX_PREFIXES 4 /* max prefixes per opcode */
#define MAX_IMMEDIATE_OPERANDS 2 /* max immediates per insn */
#define MAX_MEMORY_OPERANDS 2 /* max memory ref per insn
* lcall uses 2
*/
/* we define the syntax here (modulo base,index,scale syntax) */
/* we define the syntax here (modulo base,index,scale syntax) */
#define REGISTER_PREFIX '%'
#define IMMEDIATE_PREFIX '$'
#define ABSOLUTE_PREFIX '*'
@ -39,18 +42,18 @@
#define TWO_BYTE_OPCODE_ESCAPE 0x0f
/* register numbers */
/* register numbers */
#define EBP_REG_NUM 5
#define ESP_REG_NUM 4
/* modrm_byte.regmem for twobyte escape */
/* modrm_byte.regmem for twobyte escape */
#define ESCAPE_TO_TWO_BYTE_ADDRESSING ESP_REG_NUM
/* index_base_byte.index for no index register addressing */
/* index_base_byte.index for no index register addressing */
#define NO_INDEX_REGISTER ESP_REG_NUM
/* index_base_byte.base for no base register addressing */
/* index_base_byte.base for no base register addressing */
#define NO_BASE_REGISTER EBP_REG_NUM
/* these are the att as opcode suffixes, making movl --> mov, for example */
/* these are the att as opcode suffixes, making movl --> mov, for example */
#define DWORD_OPCODE_SUFFIX 'l'
#define WORD_OPCODE_SUFFIX 'w'
#define BYTE_OPCODE_SUFFIX 'b'
@ -115,53 +118,32 @@
#define Abs32 0x20000000
#define Abs (Abs8|Abs16|Abs32)
#define MODE_FROM_DISP_SIZE(t) \
((t&(Disp8)) ? 1 : \
((t&(Disp32)) ? 2 : 0))
#define Byte (Reg8|Imm8|Imm8S)
#define Word (Reg16|Imm16)
#define DWord (Reg32|Imm32)
/* convert opcode suffix ('b' 'w' 'l' typically) into type specifyer */
#define OPCODE_SUFFIX_TO_TYPE(s) \
(s == BYTE_OPCODE_SUFFIX ? Byte : \
(s == WORD_OPCODE_SUFFIX ? Word : DWord))
#define FITS_IN_SIGNED_BYTE(num) ((num) >= -128 && (num) <= 127)
#define FITS_IN_UNSIGNED_BYTE(num) ((num) >= 0 && (num) <= 255)
#define FITS_IN_UNSIGNED_WORD(num) ((num) >= 0 && (num) <= 65535)
#define FITS_IN_SIGNED_WORD(num) ((num) >= -32768 && (num) <= 32767)
#define SMALLEST_DISP_TYPE(num) \
FITS_IN_SIGNED_BYTE(num) ? (Disp8|Disp32|Abs8|Abs32) : (Disp32|Abs32)
#define SMALLEST_IMM_TYPE(num) \
(num == 1) ? (Imm1|Imm8|Imm8S|Imm16|Imm32): \
FITS_IN_SIGNED_BYTE(num) ? (Imm8S|Imm8|Imm16|Imm32) : \
FITS_IN_UNSIGNED_BYTE(num) ? (Imm8|Imm16|Imm32): \
(FITS_IN_SIGNED_WORD(num)||FITS_IN_UNSIGNED_WORD(num)) ? (Imm16|Imm32) : \
(Imm32)
fits_in_signed_byte(num) ? (Disp8|Disp32|Abs8|Abs32) : (Disp32|Abs32)
typedef struct {
/* instruction name sans width suffix ("mov" for movl insns) */
char *name;
char *name;
/* how many operands */
unsigned int operands;
unsigned int operands;
/* base_opcode is the fundamental opcode byte with a optional prefix(es). */
unsigned int base_opcode;
unsigned int base_opcode;
/* extension_opcode is the 3 bit extension for group <n> insns.
If this template has no extension opcode (the usual case) use None */
unsigned char extension_opcode;
#define None 0xff /* If no extension_opcode is possible. */
unsigned char extension_opcode;
#define None 0xff /* If no extension_opcode is possible. */
/* the bits in opcode_modifier are used to generate the final opcode from
the base_opcode. These bits also are used to detect alternate forms of
the same instruction */
unsigned int opcode_modifier;
unsigned int opcode_modifier;
/* opcode_modifier bits: */
#define W 0x1 /* set if operands are words or dwords */
@ -211,26 +193,26 @@ typedef struct {
END.
*/
typedef struct {
template *start;
template *end;
template *start;
template *end;
} templates;
/* these are for register name --> number & type hash lookup */
typedef struct {
char * reg_name;
unsigned int reg_type;
unsigned int reg_num;
char *reg_name;
unsigned int reg_type;
unsigned int reg_num;
} reg_entry;
typedef struct {
char * seg_name;
unsigned int seg_prefix;
char *seg_name;
unsigned int seg_prefix;
} seg_entry;
/* these are for prefix name --> prefix code hash lookup */
typedef struct {
char * prefix_name;
unsigned char prefix_code;
char *prefix_name;
unsigned char prefix_code;
} prefix_entry;
/* 386 operand encoding bytes: see 386 book for details of this. */

View File

@ -464,7 +464,7 @@ char *str;
argsStart = s;
for (;;) {
opcode = insn->match;
bzero(&the_insn, sizeof(the_insn));
memset(&the_insn, '\0', sizeof(the_insn));
the_insn.reloc = NO_RELOC;
/*
@ -630,13 +630,13 @@ char *str;
break;
case '5': /* 5 bit immediate in src1 */
bzero(&the_insn, sizeof(the_insn));
memset(&the_insn, '\0', sizeof(the_insn));
if ( !getExpression(s)) {
s = expr_end;
if (the_insn.exp.X_add_number & ~0x1f)
as_bad("5-bit immediate too large");
opcode |= (the_insn.exp.X_add_number & 0x1f) << 11;
bzero(&the_insn, sizeof(the_insn));
memset(&the_insn, '\0', sizeof(the_insn));
the_insn.reloc = NO_RELOC;
continue;
}
@ -1019,7 +1019,7 @@ struct relocation_info *ri_p, ri;
/* Also easy */
md_number_to_chars(&the_bytes[8], ri.r_addend, sizeof(ri.r_addend));
/* now put it back where you found it, Junior... */
bcopy (the_bytes, (char *)ri_p, sizeof(*ri_p));
memcpy((char *) ri_p, the_bytes, sizeof(*ri_p));
#endif
}
@ -1122,7 +1122,7 @@ relax_addressT segment_address_in_file;
extern char *next_object_file_charP;
long add_number;
bzero((char *) &ri, sizeof(ri));
memset((char *) &ri, '\0', sizeof(ri));
for (; fixP; fixP = fixP->fx_next) {
if (fixP->fx_r_type & ~0x3f) {

View File

@ -1,5 +1,5 @@
/* i960.c - All the i80960-specific stuff
Copyright (C) 1989, 1990, 1991 Free Software Foundation, Inc.
/* tc-i960.c - All the i80960-specific stuff
Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
This file is part of GAS.
@ -496,7 +496,7 @@ char *textP; /* Source text of instruction */
/* Parse instruction into opcode and operands */
bzero(args, sizeof(args));
memset(args, '\0', sizeof(args));
n_ops = i_scan(textP, args);
if (n_ops == -1){
return; /* Error message already issued */
@ -1471,7 +1471,7 @@ struct i960_opcode *oP; /* Pointer to description of instruction */
expressionS expr; /* Parsed expression */
fixS *fixP; /*->description of deferred address fixup */
bzero(&instr, sizeof(memS));
memset(&instr, '\0', sizeof(memS));
instr.opcode = oP->opcode;
/* Process operands. */
@ -2551,7 +2551,7 @@ relax_addressT segment_address_in_file;
symbolS *symbolP;
/* JF this is for paranoia */
bzero((char *)&ri, sizeof(ri));
memset((char *)&ri, '\0', sizeof(ri));
know((symbolP = fixP->fx_addsy) != 0);

File diff suppressed because it is too large Load Diff

View File

@ -45,7 +45,7 @@
#define LISTING_LHS_WIDTH 3 /* 3 word on the first line */
#define LISTING_LHS_WIDTH_SECOND 3 /* One word on the second line */
#define LISTING_LHS_CONT_LINES 4 /* And 4 lines max */
#define LISTING_HEADER "TANDEM ST-2000 68K GAS "
#define LISTING_HEADER "68K GAS "
/* Copied from write.c */
#define M68K_AIM_KLUDGE(aim, this_state,this_type) \

File diff suppressed because it is too large Load Diff

View File

@ -516,7 +516,7 @@ static void sparc_ip(str)
argsStart = s;
for (;;) {
opcode = insn->match;
bzero(&the_insn, sizeof(the_insn));
memset(&the_insn, '\0', sizeof(the_insn));
the_insn.reloc = NO_RELOC;
/*
@ -1645,7 +1645,7 @@ void emit_sparc_reloc(fixP, segment_address_in_file)
extern char *next_object_file_charP;
/* long add_number; */
bzero((char *) &ri, sizeof(ri));
memset((char *) &ri, '\0', sizeof(ri));
for (; fixP; fixP = fixP->fx_next) {
if (fixP->fx_r_type >= NO_RELOC) {

370
gas/obstack.c Normal file
View File

@ -0,0 +1,370 @@
/* obstack.c - subroutines used implicitly by object stack macros
Copyright (C) 1988 Free Software Foundation, Inc.
This program 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.
This program 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 this program; if not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "obstack.h"
#ifdef __STDC__
#define POINTER void *
#else
#define POINTER char *
#endif
/* Determine default alignment. */
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;};
#define DEFAULT_ROUNDING (sizeof (union fooround))
/* When we copy a long block of data, this is the unit to do it with.
On some machines, copying successive ints does not work;
in such a case, redefine COPYING_UNIT to `long' (if that works)
or `char' as a last resort. */
#ifndef COPYING_UNIT
#define COPYING_UNIT int
#endif
/* The non-GNU-C macros copy the obstack into this global variable
to avoid multiple evaluation. */
struct obstack *_obstack;
/* Initialize an obstack H for use. Specify chunk size SIZE (0 means default).
Objects start on multiples of ALIGNMENT (0 means use default).
CHUNKFUN is the function to use to allocate chunks,
and FREEFUN the function to free them. */
void
_obstack_begin (h, size, alignment, chunkfun, freefun)
struct obstack *h;
int size;
int alignment;
POINTER (*chunkfun) ();
void (*freefun) ();
{
register struct _obstack_chunk* chunk; /* points to new chunk */
if (alignment == 0)
alignment = DEFAULT_ALIGNMENT;
if (size == 0)
/* Default size is what GNU malloc can fit in a 4096-byte block. */
{
/* 12 is sizeof (mhead) and 4 is EXTRA from GNU malloc.
Use the values for range checking, because if range checking is off,
the extra bytes won't be missed terribly, but if range checking is on
and we used a larger request, a whole extra 4096 bytes would be
allocated.
These number are irrelevant to the new GNU malloc. I suspect it is
less sensitive to the size of the request. */
int extra = ((((12 + DEFAULT_ROUNDING - 1) & ~(DEFAULT_ROUNDING - 1))
+ 4 + DEFAULT_ROUNDING - 1)
& ~(DEFAULT_ROUNDING - 1));
size = 4096 - extra;
}
h->chunkfun = (struct _obstack_chunk * (*)()) chunkfun;
h->freefun = freefun;
h->chunk_size = size;
h->alignment_mask = alignment - 1;
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;
chunk->prev = 0;
/* The initial chunk now contains no empty object. */
h->maybe_empty_object = 0;
}
/* Allocate a new current chunk for the obstack *H
on the assumption that LENGTH bytes need to be added
to the current object, or a new object of length LENGTH allocated.
Copies any partial object from the end of the old chunk
to the beginning of the new one. */
void
_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 int obj_size = h->next_free - h->object_base;
register int i;
int already;
/* Compute size for new chunk. */
new_size = (obj_size + length) + (obj_size >> 3) + 100;
if (new_size < h->chunk_size)
new_size = h->chunk_size;
/* Allocate and initialize the new chunk. */
new_chunk = h->chunk = (*h->chunkfun) (new_size);
new_chunk->prev = old_chunk;
new_chunk->limit = h->chunk_limit = (char *) new_chunk + new_size;
/* Move the existing object to the new chunk.
Word at a time is fast and is safe if the object
is sufficiently aligned. */
if (h->alignment_mask + 1 >= DEFAULT_ALIGNMENT)
{
for (i = obj_size / sizeof (COPYING_UNIT) - 1;
i >= 0; 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. */
already = obj_size / sizeof (COPYING_UNIT) * sizeof (COPYING_UNIT);
}
else
already = 0;
/* Copy remaining bytes one by one. */
for (i = already; i < obj_size; i++)
new_chunk->contents[i] = h->object_base[i];
/* 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)
{
new_chunk->prev = old_chunk->prev;
(*h->freefun) (old_chunk);
}
h->object_base = new_chunk->contents;
h->next_free = h->object_base + obj_size;
/* The new chunk certainly contains no empty object yet. */
h->maybe_empty_object = 0;
}
/* Return nonzero if object OBJ has been allocated from obstack H.
This is here for debugging.
If you use it in a program, you are probably losing. */
int
_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 */
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))
{
plp = lp->prev;
lp = plp;
}
return lp != 0;
}
/* Free objects in obstack H, including OBJ and everything allocate
more recently than OBJ. If OBJ is zero, free everything in H. */
#undef obstack_free
/* This function has two names with identical definitions.
This is the first one, called from non-ANSI code. */
void
_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 */
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))
{
plp = lp->prev;
(*h->freefun) (lp);
lp = plp;
/* If we switch chunks, we can't tell whether the new current
chunk contains an empty object, so assume that it may. */
h->maybe_empty_object = 1;
}
if (lp)
{
h->object_base = h->next_free = (char *)(obj);
h->chunk_limit = lp->limit;
h->chunk = lp;
}
else if (obj != 0)
/* obj is not in any of the chunks! */
abort ();
}
/* This function is used from ANSI code. */
void
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 */
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))
{
plp = lp->prev;
(*h->freefun) (lp);
lp = plp;
/* If we switch chunks, we can't tell whether the new current
chunk contains an empty object, so assume that it may. */
h->maybe_empty_object = 1;
}
if (lp)
{
h->object_base = h->next_free = (char *)(obj);
h->chunk_limit = lp->limit;
h->chunk = lp;
}
else if (obj != 0)
/* obj is not in any of the chunks! */
abort ();
}
#if 0
/* These are now turned off because the applications do not use it
and it uses bcopy via obstack_grow, which causes trouble on sysV. */
/* Now define the functional versions of the obstack macros.
Define them to simply use the corresponding macros to do the job. */
#ifdef __STDC__
/* These function definitions do not work with non-ANSI preprocessors;
they won't pass through the macro names in parentheses. */
/* The function names appear in parentheses in order to prevent
the macro-definitions of the names from being expanded there. */
POINTER (obstack_base) (obstack)
struct obstack *obstack;
{
return obstack_base (obstack);
}
POINTER (obstack_next_free) (obstack)
struct obstack *obstack;
{
return obstack_next_free (obstack);
}
int (obstack_object_size) (obstack)
struct obstack *obstack;
{
return obstack_object_size (obstack);
}
int (obstack_room) (obstack)
struct obstack *obstack;
{
return obstack_room (obstack);
}
void (obstack_grow) (obstack, pointer, length)
struct obstack *obstack;
POINTER pointer;
int length;
{
obstack_grow (obstack, pointer, length);
}
void (obstack_grow0) (obstack, pointer, length)
struct obstack *obstack;
POINTER pointer;
int length;
{
obstack_grow0 (obstack, pointer, length);
}
void (obstack_1grow) (obstack, character)
struct obstack *obstack;
int character;
{
obstack_1grow (obstack, character);
}
void (obstack_blank) (obstack, length)
struct obstack *obstack;
int length;
{
obstack_blank (obstack, length);
}
void (obstack_1grow_fast) (obstack, character)
struct obstack *obstack;
int character;
{
obstack_1grow_fast (obstack, character);
}
void (obstack_blank_fast) (obstack, length)
struct obstack *obstack;
int length;
{
obstack_blank_fast (obstack, length);
}
POINTER (obstack_finish) (obstack)
struct obstack *obstack;
{
return obstack_finish (obstack);
}
POINTER (obstack_alloc) (obstack, length)
struct obstack *obstack;
int length;
{
return obstack_alloc (obstack, length);
}
POINTER (obstack_copy) (obstack, pointer, length)
struct obstack *obstack;
POINTER pointer;
int length;
{
return obstack_copy (obstack, pointer, length);
}
POINTER (obstack_copy0) (obstack, pointer, length)
struct obstack *obstack;
POINTER pointer;
int length;
{
return obstack_copy0 (obstack, pointer, length);
}
#endif /* __STDC__ */
#endif /* 0 */

444
gas/obstack.h Normal file
View File

@ -0,0 +1,444 @@
/* obstack.h - object stack macros
Copyright (C) 1988 Free Software Foundation, Inc.
This program 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.
This program 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 this program; if not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
/* Summary:
All the apparent functions defined here are macros. The idea
is that you would use these pre-tested macros to solve a
very specific set of problems, and they would run fast.
Caution: no side-effects in arguments please!! They may be
evaluated MANY times!!
These macros operate a stack of objects. Each object starts life
small, and may grow to maturity. (Consider building a word syllable
by syllable.) An object can move while it is growing. Once it has
been "finished" it never changes address again. So the "top of the
stack" is typically an immature growing object, while the rest of the
stack is of mature, fixed size and fixed address objects.
These routines grab large chunks of memory, using a function you
supply, called `obstack_chunk_alloc'. On occasion, they free chunks,
by calling `obstack_chunk_free'. You must define them and declare
them before using any obstack macros.
Each independent stack is represented by a `struct obstack'.
Each of the obstack macros expects a pointer to such a structure
as the first argument.
One motivation for this package is the problem of growing char strings
in symbol tables. Unless you are "fascist pig with a read-only mind"
[Gosper's immortal quote from HAKMEM item 154, out of context] you
would not like to put any arbitrary upper limit on the length of your
symbols.
In practice this often means you will build many short symbols and a
few long symbols. At the time you are reading a symbol you don't know
how long it is. One traditional method is to read a symbol into a
buffer, realloc()ating the buffer every time you try to read a symbol
that is longer than the buffer. This is beaut, but you still will
want to copy the symbol from the buffer to a more permanent
symbol-table entry say about half the time.
With obstacks, you can work differently. Use one obstack for all symbol
names. As you read a symbol, grow the name in the obstack gradually.
When the name is complete, finalize it. Then, if the symbol exists already,
free the newly read name.
The way we do this is to take a large chunk, allocating memory from
low addresses. When you want to build a symbol in the chunk you just
add chars above the current "high water mark" in the chunk. When you
have finished adding chars, because you got to the end of the symbol,
you know how long the chars are, and you can create a new object.
Mostly the chars will not burst over the highest address of the chunk,
because you would typically expect a chunk to be (say) 100 times as
long as an average object.
In case that isn't clear, when we have enough chars to make up
the object, THEY ARE ALREADY CONTIGUOUS IN THE CHUNK (guaranteed)
so we just point to it where it lies. No moving of chars is
needed and this is the second win: potentially long strings need
never be explicitly shuffled. Once an object is formed, it does not
change its address during its lifetime.
When the chars burst over a chunk boundary, we allocate a larger
chunk, and then copy the partly formed object from the end of the old
chunk to the beginning of the new larger chunk. We then carry on
accreting characters to the end of the object as we normally would.
A special macro is provided to add a single char at a time to a
growing object. This allows the use of register variables, which
break the ordinary 'growth' macro.
Summary:
We allocate large chunks.
We carve out one object at a time from the current chunk.
Once carved, an object never moves.
We are free to append data of any size to the currently
growing object.
Exactly one object is growing in an obstack at any one time.
You can run one obstack per control block.
You may have as many control blocks as you dare.
Because of the way we do it, you can `unwind' a obstack
back to a previous state. (You may remove objects much
as you would with a stack.)
*/
/* Don't do the contents of this file more than once. */
#ifndef __OBSTACKS__
#define __OBSTACKS__
/* We use subtraction of (char *)0 instead of casting to int
because on word-addressable machines a simple cast to int
may ignore the byte-within-word field of the pointer. */
#ifndef __PTR_TO_INT
#define __PTR_TO_INT(P) ((P) - (char *)0)
#endif
#ifndef __INT_TO_PTR
#define __INT_TO_PTR(P) ((P) + (char *)0)
#endif
struct _obstack_chunk /* Lives at front of each 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 */
};
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. */
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;
};
/* 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 (*) ());
#else
extern void _obstack_newchunk ();
extern void _obstack_free ();
extern void _obstack_begin ();
#endif
#ifdef __STDC__
/* Do the function-declarations after the structs
but before defining the macros. */
void obstack_init (struct obstack *obstack);
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_free (struct obstack *obstack, void *block);
void obstack_blank (struct obstack *obstack, int size);
void obstack_grow (struct obstack *obstack, void *data, int size);
void obstack_grow0 (struct obstack *obstack, void *data, int size);
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);
int obstack_object_size (struct obstack *obstack);
int obstack_room (struct obstack *obstack);
void obstack_1grow_fast (struct obstack *obstack, int data_char);
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);
int obstack_alignment_mask (struct obstack *obstack);
int obstack_chunk_size (struct obstack *obstack);
#endif /* __STDC__ */
/* Non-ANSI C cannot really support alternative functions for these macros,
so we do not declare them. */
/* Pointer to beginning of object being allocated or to be allocated next.
Note that this might not be the final address of the object
because a new chunk might be needed to hold the final size. */
#define obstack_base(h) ((h)->object_base)
/* Size for allocating ordinary chunks. */
#define obstack_chunk_size(h) ((h)->chunk_size)
/* Pointer to next byte not yet allocated in current chunk. */
#define obstack_next_free(h) ((h)->next_free)
/* Mask specifying low bits that should be clear in address of an object. */
#define obstack_alignment_mask(h) ((h)->alignment_mask)
#define obstack_init(h) \
_obstack_begin ((h), 0, 0, \
(void *(*) ()) obstack_chunk_alloc, (void (*) ())obstack_chunk_free)
#define obstack_begin(h, size) \
_obstack_begin ((h), (size), 0, \
(void *(*) ()) obstack_chunk_alloc, (void (*) ())obstack_chunk_free)
#define obstack_1grow_fast(h,achar) (*((h)->next_free)++ = achar)
#define obstack_blank_fast(h,n) ((h)->next_free += (n))
#if defined (__GNUC__) && defined (__STDC__)
#if __GNUC__ < 2
#define __extension__
#endif
/* For GNU C, if not -traditional,
we can define these macros to compute all args only once
without using a global variable.
Also, we can avoid using the `temp' slot, to make faster code. */
#define obstack_object_size(OBSTACK) \
__extension__ \
({ struct obstack *__o = (OBSTACK); \
(unsigned) (__o->next_free - __o->object_base); })
#define obstack_room(OBSTACK) \
__extension__ \
({ struct obstack *__o = (OBSTACK); \
(unsigned) (__o->chunk_limit - __o->next_free); })
/* Note that the call to _obstack_newchunk is enclosed in (..., 0)
so that we can avoid having void expressions
in the arms of the conditional expression.
Casting the third operand to void was tried before,
but some compilers won't accept it. */
#define obstack_grow(OBSTACK,where,length) \
__extension__ \
({ struct obstack *__o = (OBSTACK); \
int __len = (length); \
((__o->next_free + __len > __o->chunk_limit) \
? (_obstack_newchunk (__o, __len), 0) : 0); \
memcpy (__o->next_free, where, __len); \
__o->next_free += __len; \
(void) 0; })
#define obstack_grow0(OBSTACK,where,length) \
__extension__ \
({ struct obstack *__o = (OBSTACK); \
int __len = (length); \
((__o->next_free + __len + 1 > __o->chunk_limit) \
? (_obstack_newchunk (__o, __len + 1), 0) : 0), \
memcpy (__o->next_free, where, __len), \
__o->next_free += __len, \
*(__o->next_free)++ = 0; \
(void) 0; })
#define obstack_1grow(OBSTACK,datum) \
__extension__ \
({ struct obstack *__o = (OBSTACK); \
((__o->next_free + 1 > __o->chunk_limit) \
? (_obstack_newchunk (__o, 1), 0) : 0), \
*(__o->next_free)++ = (datum); \
(void) 0; })
/* 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); \
((__o->next_free + sizeof (void *) > __o->chunk_limit) \
? (_obstack_newchunk (__o, sizeof (void *)), 0) : 0), \
*(*(void ***)&__o->next_free)++ = ((void *)datum); \
(void) 0; })
#define obstack_int_grow(OBSTACK,datum) \
__extension__ \
({ struct obstack *__o = (OBSTACK); \
((__o->next_free + sizeof (int) > __o->chunk_limit) \
? (_obstack_newchunk (__o, sizeof (int)), 0) : 0), \
*(*(int **)&__o->next_free)++ = ((int)datum); \
(void) 0; })
#define obstack_ptr_grow_fast(h,aptr) (*(*(void ***)&(h)->next_free)++ = (void *)aptr)
#define obstack_int_grow_fast(h,aint) (*(*(int **)&(h)->next_free)++ = (int)aint)
#define obstack_blank(OBSTACK,length) \
__extension__ \
({ struct obstack *__o = (OBSTACK); \
int __len = (length); \
((__o->chunk_limit - __o->next_free < __len) \
? (_obstack_newchunk (__o, __len), 0) : 0); \
__o->next_free += __len; \
(void) 0; })
#define obstack_alloc(OBSTACK,length) \
__extension__ \
({ struct obstack *__h = (OBSTACK); \
obstack_blank (__h, (length)); \
obstack_finish (__h); })
#define obstack_copy(OBSTACK,where,length) \
__extension__ \
({ struct obstack *__h = (OBSTACK); \
obstack_grow (__h, (where), (length)); \
obstack_finish (__h); })
#define obstack_copy0(OBSTACK,where,length) \
__extension__ \
({ struct obstack *__h = (OBSTACK); \
obstack_grow0 (__h, (where), (length)); \
obstack_finish (__h); })
/* The local variable is named __o1 to avoid a name conflict
when obstack_blank is called. */
#define obstack_finish(OBSTACK) \
__extension__ \
({ struct obstack *__o1 = (OBSTACK); \
void *value = (void *) __o1->object_base; \
if (__o1->next_free == value) \
__o1->maybe_empty_object = 1; \
__o1->next_free \
= __INT_TO_PTR ((__PTR_TO_INT (__o1->next_free)+__o1->alignment_mask)\
& ~ (__o1->alignment_mask)); \
((__o1->next_free - (char *)__o1->chunk \
> __o1->chunk_limit - (char *)__o1->chunk) \
? (__o1->next_free = __o1->chunk_limit) : 0); \
__o1->object_base = __o1->next_free; \
value; })
#define obstack_free(OBSTACK, OBJ) \
__extension__ \
({ struct obstack *__o = (OBSTACK); \
void *__obj = (OBJ); \
if (__obj > (void *)__o->chunk && __obj < (void *)__o->chunk_limit) \
__o->next_free = __o->object_base = __obj; \
else (obstack_free) (__o, __obj); })
#else /* not __GNUC__ or not __STDC__ */
#define obstack_object_size(h) \
(unsigned) ((h)->next_free - (h)->object_base)
#define obstack_room(h) \
(unsigned) ((h)->chunk_limit - (h)->next_free)
#define obstack_grow(h,where,length) \
( (h)->temp = (length), \
(((h)->next_free + (h)->temp > (h)->chunk_limit) \
? (_obstack_newchunk ((h), (h)->temp), 0) : 0), \
memcpy ((h)->next_free, where, (h)->temp), \
(h)->next_free += (h)->temp)
#define obstack_grow0(h,where,length) \
( (h)->temp = (length), \
(((h)->next_free + (h)->temp + 1 > (h)->chunk_limit) \
? (_obstack_newchunk ((h), (h)->temp + 1), 0) : 0), \
memcpy ((h)->next_free, where, (h)->temp), \
(h)->next_free += (h)->temp, \
*((h)->next_free)++ = 0)
#define obstack_1grow(h,datum) \
( (((h)->next_free + 1 > (h)->chunk_limit) \
? (_obstack_newchunk ((h), 1), 0) : 0), \
*((h)->next_free)++ = (datum))
#define obstack_ptr_grow(h,datum) \
( (((h)->next_free + sizeof (char *) > (h)->chunk_limit) \
? (_obstack_newchunk ((h), sizeof (char *)), 0) : 0), \
*(*(char ***)&(h)->next_free)++ = ((char *)datum))
#define obstack_int_grow(h,datum) \
( (((h)->next_free + sizeof (int) > (h)->chunk_limit) \
? (_obstack_newchunk ((h), sizeof (int)), 0) : 0), \
*(*(int **)&(h)->next_free)++ = ((int)datum))
#define obstack_ptr_grow_fast(h,aptr) (*(*(char ***)&(h)->next_free)++ = (char *)aptr)
#define obstack_int_grow_fast(h,aint) (*(*(int **)&(h)->next_free)++ = (int)aint)
#define obstack_blank(h,length) \
( (h)->temp = (length), \
(((h)->chunk_limit - (h)->next_free < (h)->temp) \
? (_obstack_newchunk ((h), (h)->temp), 0) : 0), \
(h)->next_free += (h)->temp)
#define obstack_alloc(h,length) \
(obstack_blank ((h), (length)), obstack_finish ((h)))
#define obstack_copy(h,where,length) \
(obstack_grow ((h), (where), (length)), obstack_finish ((h)))
#define obstack_copy0(h,where,length) \
(obstack_grow0 ((h), (where), (length)), obstack_finish ((h)))
#define obstack_finish(h) \
( ((h)->next_free == (h)->object_base \
? (((h)->maybe_empty_object = 1), 0) \
: 0), \
(h)->temp = __PTR_TO_INT ((h)->object_base), \
(h)->next_free \
= __INT_TO_PTR ((__PTR_TO_INT ((h)->next_free)+(h)->alignment_mask) \
& ~ ((h)->alignment_mask)), \
(((h)->next_free - (char *)(h)->chunk \
> (h)->chunk_limit - (char *)(h)->chunk) \
? ((h)->next_free = (h)->chunk_limit) : 0), \
(h)->object_base = (h)->next_free, \
__INT_TO_PTR ((h)->temp))
#ifdef __STDC__
#define obstack_free(h,obj) \
( (h)->temp = (char *)(obj) - (char *) (h)->chunk, \
(((h)->temp > 0 && (h)->temp < (h)->chunk_limit - (char *) (h)->chunk)\
? (int) ((h)->next_free = (h)->object_base \
= (h)->temp + (char *) (h)->chunk) \
: (((obstack_free) ((h), (h)->temp + (char *) (h)->chunk), 0), 0)))
#else
#define obstack_free(h,obj) \
( (h)->temp = (char *)(obj) - (char *) (h)->chunk, \
(((h)->temp > 0 && (h)->temp < (h)->chunk_limit - (char *) (h)->chunk)\
? (int) ((h)->next_free = (h)->object_base \
= (h)->temp + (char *) (h)->chunk) \
: (_obstack_free ((h), (h)->temp + (char *) (h)->chunk), 0)))
#endif
#endif /* not __GNUC__ or not __STDC__ */
#endif /* not __OBSTACKS__ */

View File

@ -36,7 +36,7 @@
#include "as.h"
#include "obstack.h"
#include "listing.h"
char *input_line_pointer; /*->next char of source file to parse. */
@ -171,11 +171,6 @@ void
struct hash_control *
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();
#endif
static const pseudo_typeS
potable[] =
{
@ -190,7 +185,11 @@ static const pseudo_typeS
/* dim */
{ "double", float_cons, 'd' },
/* dsect */
#ifdef NO_LISTING
{ "eject", s_ignore, 0 }, /* Formfeed listing */
#else
{ "eject", listing_eject, 0 }, /* Formfeed listing */
#endif /* NO_LISTING */
{ "else", s_else, 0 },
{ "end", s_end, 0 },
{ "endif", s_endif, 0 },
@ -203,14 +202,6 @@ static const pseudo_typeS
{ "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 },
#endif
{ "global", s_globl, 0 },
{ "globl", s_globl, 0 },
{ "hword", cons, 2 },
@ -223,17 +214,34 @@ static const pseudo_typeS
{ "include", s_include, 0 },
{ "int", cons, 4 },
{ "lcomm", s_lcomm, 0 },
#ifdef NO_LISTING
{ "lflags", s_ignore, 0 }, /* Listing flags */
{ "list", s_ignore, 1 }, /* Turn listing on */
#else
{ "lflags", listing_flags, 0 }, /* Listing flags */
{ "list", listing_list, 1 }, /* Turn listing on */
#endif /* NO_LISTING */
{ "long", cons, 4 },
{ "lsym", s_lsym, 0 },
#ifdef NO_LISTING
{ "nolist", s_ignore, 0 }, /* Turn listing off */
#else
{ "nolist", listing_list, 0 }, /* Turn listing off */
#endif /* NO_LISTING */
{ "octa", big_cons, 16 },
{ "org", s_org, 0 },
{ "psize", listing_psize, 0 }, /* set paper size */
#ifdef NO_LISTING
{ "psize", s_ignore, 0 }, /* set paper size */
#else
{ "psize", listing_psize, 0 }, /* set paper size */
#endif /* NO_LISTING */
/* print */
{ "quad", big_cons, 8 },
#ifdef NO_LISTING
{ "sbttl", s_ignore, 1 }, /* Subtitle of listing */
#else
{ "sbttl", listing_title, 1 }, /* Subtitle of listing */
#endif /* NO_LISTING */
/* scl */
/* sect */
{ "set", s_set, 0 },
@ -243,7 +251,11 @@ static const pseudo_typeS
{ "space", s_space, 0 },
/* tag */
{ "text", s_text, 0 },
#ifdef NO_LISTING
{ "title", s_ignore, 0 }, /* Listing title */
#else
{ "title", listing_title, 0 }, /* Listing title */
#endif /* NO_LISTING */
/* type */
/* use */
/* val */
@ -321,12 +333,6 @@ char *name;
register int temp;
/* 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();
#endif
buffer = input_scrub_new_file(name);
@ -504,7 +510,7 @@ char *name;
guarentee it. . . */
tmp_len=buffer_limit-s;
tmp_buf=xmalloc(tmp_len);
bcopy(s,tmp_buf,tmp_len);
memcpy(tmp_buf, s, tmp_len);
do {
new_tmp = input_scrub_next_buffer(&buffer);
if (!new_tmp)
@ -519,7 +525,7 @@ char *name;
num=buffer_limit-buffer;
tmp_buf = xrealloc(tmp_buf, tmp_len + num);
bcopy(buffer,tmp_buf+tmp_len,num);
memcpy(tmp_buf + tmp_len, buffer, num);
tmp_len+=num;
} while(!ends);
@ -773,7 +779,7 @@ void s_fill() {
temp_fill = get_absolute_expression ();
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);
memset(p, '\0', (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.
@ -791,118 +797,6 @@ void s_fill() {
demand_empty_rest_of_line();
}
#ifdef DONTDEF
void
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 ();
}
void
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 ();
}
void
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 ();
}
void
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 ();
}
void
s_gdbline()
{
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();
}
void
s_gdblinetab()
{
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();
}
#endif
void s_globl() {
register char *name;
register int c;
@ -1645,13 +1539,13 @@ register unsigned int nbytes; /* 1=.byte, 2=.word, 4=.long */
default:
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);
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);
#else
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);
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);
#endif /* TC_NS32K */
break;
} /* switch(segment) */
@ -1784,11 +1678,11 @@ register int nbytes;
if (! need_pass_2)
{
p = frag_more (nbytes);
bcopy (bignum_low, p, (int)nbytes);
memcpy(p, bignum_low, (int) nbytes);
}
/* C contains character after number. */
SKIP_WHITESPACE();
c = * input_line_pointer;
c = *input_line_pointer;
/* C contains 1st non-blank character after number. */
}
demand_empty_rest_of_line();
@ -1854,45 +1748,40 @@ register int float_type; /* 'f':.ffloat ... 'F':.float ... */
{
c = ','; /* Do loop. */
}
while (c == ',')
{
/* input_line_pointer->1st char of a flonum (we hope!). */
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;
err = md_atof (float_type, temp, &length);
know(length <= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT);
know(length > 0);
if (* err)
{
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. */
while (c == ',') {
/* input_line_pointer->1st char of a flonum (we hope!). */
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;
err = md_atof (float_type, temp, &length);
know(length <= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT);
know(length > 0);
if (* err) {
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) {
p = frag_more (length);
memcpy(p, temp, length);
}
else
{
if (! need_pass_2)
{
p = frag_more (length);
bcopy (temp, p, length);
}
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 ','). */
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();
} /* float_cons() */
} /* float_cons() */
/*
* stringer()

61
gas/strerror.c Normal file
View File

@ -0,0 +1,61 @@
/* Version of strerror() for systems that need it.
Copyright (C) 1991, 1992 Free Software Foundation, Inc.
This program 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 of the License, or
(at your option) any later version.
This program 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 this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
/*
NAME
strerror -- map an error number to an error message string
SYNOPSIS
#include <string.h>
char *strerror (int errnum)
DESCRIPTION
Returns a pointer to a string containing an error message, the
contents of which are implementation defined. The implementation
shall behave as if no library function calls strerror. The string
pointed to shall not be modified by the caller and is only guaranteed
to be valid until a subsequent call to strerror.
BUGS
Requires that the system have sys_errlist and sys_nerr.
*/
#ifndef HAVE_STRERROR
extern int sys_nerr;
extern char *sys_errlist[];
char *
strerror (code)
int code;
{
return (((code < 0) || (code >= sys_nerr))
? "(unknown error)"
: sys_errlist [code]);
}
#endif /* HAVE_STRERROR */
/* end of strerror.c */

View File

@ -86,9 +86,9 @@ long offset; /* X_add_number. */
int pcrel; /* TRUE if PC-relative relocation. */
enum reloc_type r_type; /* Relocation type */
{
register fixS * fixP;
fixS *fixP;
fixP = (fixS *)obstack_alloc(&notes,sizeof(fixS));
fixP = (fixS *) obstack_alloc(&notes, sizeof(fixS));
fixP->fx_frag = frag;
fixP->fx_where = where;
@ -100,10 +100,10 @@ enum reloc_type r_type; /* Relocation type */
fixP->fx_r_type = r_type;
/* JF these 'cuz of the NS32K stuff */
fixP->fx_im_disp = 0;
fixP->fx_im_disp = 0;
fixP->fx_pcrel_adjust = 0;
fixP->fx_bsr = 0;
fixP->fx_bit_fixP = 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
@ -128,8 +128,9 @@ enum reloc_type r_type; /* Relocation type */
#endif /* REVERSE_SORT_RELOCS */
fixP->fx_callj = 0;
return fixP;
}
return(fixP);
} /* fix_new() */
#ifndef BFD
void write_object_file()
{
@ -143,10 +144,6 @@ void write_object_file()
/* register fixS * fixP; JF unused */
unsigned int data_siz;
#ifdef DONTDEF
void gdb_emit();
void gdb_end();
#endif
long object_file_size;
#ifdef VMS
@ -566,14 +563,6 @@ void write_object_file()
output_file_append(the_object_file,object_file_size,out_file_name);
#endif
#ifdef DONTDEF
if (flagseen['G']) /* GDB symbol file to be appended? */
{
gdb_emit (out_file_name);
gdb_end ();
}
#endif /* DONTDEF */
output_file_close(out_file_name);
} /* non vms output */
#else /* VMS */
@ -1138,8 +1127,8 @@ char **charPP;
char *fromP;
unsigned long length;
{
if (length) { /* Don't trust bcopy() of 0 chars. */
bcopy(fromP, *charPP, (int) length);
if (length) { /* Don't trust memcpy() of 0 chars. */
memcpy(*charPP, fromP, (int) length);
*charPP += length;
}
}