680xx Apollo support kit for gas-2.3 for use with gcc-2.x
under the SR10.x OS.

     This patch kit requires a virgin copy of gas-2.3.  It may be built
with GNU or Apollo CC.  The GNU debugger GDB is supported using .stabs
directives.  The native Apollo debugging format is NOT supported.  COFF
debugging directives have not been tested.

     This code has been tested on an Apollo DN4500 running SR10.3.5 with the
ANSI header files and a BSD environment using the version 6.8 C compiler.
It should work on any SR10 system.  New files are provided separately from
the patch file since some versions of patch will not make new files.

This patch kit contains the following files:

README:       this document
DIFFS:        context diffs
apollo.mt:    new makefile stub
te-apollo.h:  new source code



Installation:

Unpack gas-2.3 and this patch kit.  This gives directories gas-2.3 and
apolgas-2.3 at the same level.  Apply the patches and copy over
the new source files with the following UNIX shell commands.
(Running from the directory containing gas-2.3 and apolgas.2.3.)

/usr/new/patch -p0 < apolgas-2.3/DIFFS
cp apolgas-2.3/te-apollo.h gas-2.3/gas/config/te-apollo.h
cp apolgas-2.3/apollo.mt gas-2.3/gas/config/apollo.mt

Now configure and build the assembler using m68k-apollo-bsd for the
BSD environment or m68k-apollo-sysv for the sys5 environment.
This builds using the Apollo compiler with debugging enabled.

cd gas-2.3
configure m68k-apollo-bsd
make

The finished assembler is in gas/as.new.  This should be installed
as "as" for GCC to find it.

Compiler flags may be changed by editing the config files such as
gas-2.3/config/mh-a68bsd, then running configure again.  A temporary
change may be made by editing each Makefile, searching for "systype"
to find the CC definition.  Makefiles without "systype" do not need
to be changed.  Such changes vanish the next time "configure" is run.



Notes:

     The /com/obty command is invoked to make the object files have
type "coff".  If object files are being made on an NFS-mounted volume
then obty may print messages like this:
"?(obty) Can't change the type of an extended object"
These are harmless.

     The BFD COFF support code is used.  Debugging information is stored
in COFF sections names ".stab" and ".stabstr".  An object file with no
".text" section relocations will be marked as position-independent.  This
allows building shared libraries.  The Apollo loader and run-time system
do not support PC-relative relocations.  The ".section" directive may
be used to create the other commonly-used apollo sections, with the
correct flags used automatically.  For example, ".section .aptv"
creates an ".aptv" section, already marked as a data section.

     The COFF code uses the BFD_ASSEMBLER code.  If a cross-assembler
is attempted, BFD_ASSEMBLER and all of the definitions in te-apollo.h
should be set.

     Apollo does not use an underscore prefix, so '%' register prefixes
and ".L*" local labels are used.  Dollar signs may be used in names.
The .section directive can be used to make text or data sections with
any desired name.  To make a text section with name SECNAME, use
.section SECNAME,"x"
To make a data section, use "w" or "d" instead of "x".
A new directive ".int24" has been added.  It makes a 24-bit byte-aligned
integer using the same syntax as the ".long" directive.  The values given
should be constants or differences between two labels.  Anything requiring
relocation will fail.  It is provided for GCC to use to generate function
lengths for the .unwind section.

Source files changed by the patch kit:

bfd/coff-apollo.c:  changed tables, added some new code
bfd/coffcode.h:
  sec_to_styp_flags, styp_to_sec_flags, coff_set_flags:
    added Apollo-specific flags and section names.
  coff_add_missing_symbols:  remake section symbols
bfd/coffswap.h:  coff_swap_aouthdr_out:  added missing Apollo fields.
bfd/section.c:  BUGFIX corrected misplaced cast in STD_SECTION macro.
gas:  BUGFIX fixed prototypes and used DEFUN macro to fix stack alignment
  problem on machines that do not word-align function arguments.
  This makes the K&R and ANSI declarations equivalent.  This affects
  expr.c, expr.h, frags.c, frags.h, write.c, and write.h

gas/config/atof_ieee.c:  BUGFIX change atof_ieee () second parameter
  from char to int.
gas/config/obj-coff.c:  coff_frob_section () added SECTION_REQUIRES_SYMBOL
  code to make selected section symbols.  coff_frob_symbols () added
  SET_COFF_EXTERN () to set COFF the symbol type to "int" for weak
  externals, matching the Apollo convention.
gas/config/tc-m68k.c:  Work around absence of PC-relative relocations
  on Apollo.  This affects md_convert_frag_1 and
  md_estimate_size_before_relax.  Added int24 directive.
  Potential BUGFIX code:  added #ifdef'd code on NO_PCREL_RELOCS,
  NO_SUBSEG_CHANGES, DISP_INCLUDES_ADDRESS, all keyed from TE_APOLLO.
  BUGFIX changed definition of md_atof to match the prototype in tc.h.
gas/config/apollo.mt:  New file
gas/config/te-apollo.h:  New file
include/coff/apollo.h:  Added Apollo-specific F_PIC filehdr flag and
  some Apollo-specific section names.

The configuration files were changed to add Apollo configurations and make
all the Apollo makefile stubs consistent with each other.



Known bugs and limitations:

The "section" directive only knows about a fixed set of names.  No general
mechanism is provided to set Apollo-specific section flags.  Additional
fixed names could be added to bfd/coffcode.h around line 340 in
sec_to_styp_flags ().  All of the normal Apollo section names
are already provided.

No method is provided for changing the section flags of the .data section
appropriately if a .rwdi section is used.

No method is provided to allow arbitrary strings in .mir section
records.  Strings may be entered by making them symbols at known places
in the string table, then coding the offsets as numbers.  This is the
method used by the gcc-2.5.8 port.

The native Apollo debugging format is not supported.  Code to read the
Apollo format is present in the gdb-4.12 distribution.  Once you have
GDB, you probably won't want that DDE stuff anyway!  :-)

The Apollo "strip" command can not remove the debugging sections.

The Apollo DN10000 is not supported.

All COFF sections start from 0 rather than the normal Apollo addresses.
This seems unimportant since the loader relocates them as needed.
Changing this would require examining all the code to make sure that a
changed BFD section base gets properly applied in relocations and symbols.

Various function declaration inconsistencies may remain, especially on
other platforms.  Example:  md_atof () is declared as
"char *md_atof PARAMS ((int what_statement_type, char *literalP, int *sizeP));"
in tc.h.  Some tc-* files have it defined in K&R format with the first
parameter being "char" not int.  This is mostly a problem for the Apollo
C compiler.

General note on function prototypes:  The Apollo C compiler does *NOT*
word-align stack arguments, and if both K&R and ANSI declarations are
present, the K&R form usually gets used.  This causes problems with char
and short arguments unless all declarations and definitions match.
Parameter alignment is to the nearest halfword boundary.



Questions about this patch kit may be addressed to

William J. Eaton
Email wje@hoffman.rstnu.bcm.tmc.edu
Phone (USA) (713) 798-5161
