delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1994/04/22/06:25:45

Organization: Eurotherm Controls Limited.
Address: Faraday Close, Durrington, Worthing, W.Sussex, BN13 3PL, England.
Phone: +44 903 268500
Fax: +44 903 265982
From: Martin Tomes <mt00 AT controls DOT eurotherm DOT co DOT uk>
Date: Fri, 22 Apr 94 08:44:00 GMT
To: leonardr AT eeng DOT dcu DOT ie
Cc: djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: Re: Cross compiler in Dos to target 680x0

> Date: Thu Apr 21 14:47:08 1994
> From: leonardr AT eeng DOT dcu DOT ie (Roy Leonard)
> Mime-Version: 1.0
> Content-Type: text/plain; charset=us-ascii
> X-Mailer: <WinQVT/Net v3.9>
> 
> 
> Can anyone tell me where I can find the necessary files to modify
> GCC to cross compile 680x0 code on a PC.  
> 
> Is there a port of GCC to cross compile code for a M6809 target system?
> If this is not possible, is there an comparable shareware compiler
> available?
> 
> Any help would be much appreciated.  Please E-mail me @
> 
> leonardr AT eeng DOT dcu DOT ie

I have just built such a thing.  It has hardly been used yet but this
is what I did so you can try too!

First I made sure I could build gcc 2.5.8 (sources from prep) gas 2.11
and binutils 2.2 for DOS using the configur.bat files etc.  You need
makes and seds and various other ods and ends to do it but they are
around on the net and you should be able to find them.

Next I changed the config so that it built for a m68k-unknown-coff
target.  This is easy for gas and binutils, but harder for gcc because
it does not have such a thing.  The UNIX configure can configure for
m68k-local though so I set it up like that and hacked the makefile.

You need a local.h in config/m68k, mine looks like this but treat this
carefully as I am not sure about what I did:

--config/m68k.local.h-------------------------------------------------
/* Definitions of target machine for GNU compiler.  Sun 68000/68020 version.
   Copyright (C) 1987, 1988, 1993 Free Software Foundation, Inc.

This is for building a PC4000 cross compiler using gcc.

This file is part of GNU CC.

GNU CC 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.

GNU CC 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 GNU CC; see the file COPYING.  If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */

/* This comment is here to see if it will keep Sun's cpp from dying.  */


#include "m68k/m68k.h"

/* See m68k.h.  7 means 68020 with 68881.  */
/* See m68k.h.  5 means 68020 with no 68881.  */

#ifndef TARGET_DEFAULT
#define TARGET_DEFAULT 5
#endif

/* Define __HAVE_FPA__ or __HAVE_68881__ in preprocessor,
   according to the -m flags.
   This will control the use of inline 68881 insns in certain macros.
   Also inform the program which CPU this is for.  */

/* -msoft-float is the default */
#define CPP_SPEC \
"%{m68000:-D__mc68010__}%{mc68000:-D__mc68010__}%{!mc68000:%{!m68000:-D__mc68020__}} \
%{!ansi:%{m68000:-Dmc68010}%{mc68000:-Dmc68010}%{!mc68000:%{!m68000:-Dmc68020}}}"


/* Prevent error on `-pc4k' and `-target pc4k' options.  */

#define CC1_SPEC "%{pc4k:} %{target:}"

#define PTRDIFF_TYPE "int"

#ifdef MDTNOTSURE
/* We must override m68k.h.  */
#undef WCHAR_TYPE
#undef WCHAR_TYPE_SIZE
#define WCHAR_TYPE "short unsigned int"
#define WCHAR_TYPE_SIZE 16
#endif

/* These compiler options take an argument.  We ignore -target for now.  */

#define WORD_SWITCH_TAKES_ARG(STR)				\
 (DEFAULT_WORD_SWITCH_TAKES_ARG (STR)				\
  || !strcmp (STR, "target") || !strcmp (STR, "assert"))

/* -m68000 requires special flags to the assembler.  */

#define ASM_SPEC \
 "%{m68000:-mc68010}%{mc68000:-mc68010}%{!mc68000:%{!m68000:-mc68020}} \
  %{fpic:-k} %{fPIC:-k}"

/* Names to predefine in the preprocessor for this target machine.  */
/* For a while,  -D_CROSS_TARGET_ARCH=SUN3 was included here,
   but it doesn't work, partly because SUN3 etc. aren't defined
   (and shouldn't be).  It seems that on a native compiler _CROSS_TARGET_ARCH
   should not be defined.  For cross compilers, let's do things as we
   normally do in GCC.  -- rms.  */

#define CPP_PREDEFINES "-Dmc68000 -Dpc4k -Acpu(m68k) -Amachine(m68k)"

/* Every structure or union's size must be a multiple of 2 bytes.  */

#define STRUCTURE_SIZE_BOUNDARY 16

/* This is pc4k so lets go with DBX format.  */

#define DBX_DEBUGGING_INFO

/* Allow folding division by zero.  */
#define REAL_INFINITY

#ifdef MDTNOTSURE
/* Generate calls to memcpy, memcmp and memset.  */
#define TARGET_MEM_FUNCTIONS
#endif

/* Use a register prefix to avoid clashes with external symbols (classic
   example: `extern char PC;' in termcap).  */

#undef REGISTER_PREFIX
#define REGISTER_PREFIX "%"

/* In the machine description we can't use %R, because it will not be seen
   by ASM_FPRINTF.  (Isn't that a design bug?).  */

#undef REGISTER_PREFIX_MD
#define REGISTER_PREFIX_MD "%%"

/* The prefix to add to user-visible assembler symbols.  */

#undef USER_LABEL_PREFIX
#define USER_LABEL_PREFIX ""

/* config/m68k.md has an explicit reference to the program counter,
   prefix this by the register prefix.  */

#define ASM_RETURN_CASE_JUMP    return "jmp %%pc@(2,%0:w)"


/* Here are the new register names.  */

#undef REGISTER_NAMES
#ifndef SUPPORT_SUN_FPA
#define REGISTER_NAMES \
{"%d0", "%d1", "%d2", "%d3", "%d4", "%d5", "%d6", "%d7",	\
 "%a0", "%a1", "%a2", "%a3", "%a4", "%a5", "%a6", "%sp",	\
 "%fp0", "%fp1", "%fp2", "%fp3", "%fp4", "%fp5", "%fp6", "%fp7" }
#else /* SUPPORTED_SUN_FPA */
#define REGISTER_NAMES \
{"%d0", "%d1", "%d2", "%d3", "%d4", "%d5", "%d6", "%d7",	\
 "%a0", "%a1", "%a2", "%a3", "%a4", "%a5", "%a6", "%sp",	\
 "%fp0", "%fp1", "%fp2", "%fp3", "%fp4", "%fp5", "%fp6", "%fp7", \
 "%fpa0", "%fpa1", "%fpa2", "%fpa3", "%fpa4", "%fpa5", "%fpa6", "%fpa7", \
 "%fpa8", "%fpa9", "%fpa10", "%fpa11", "%fpa12", "%fpa13", "%fpa14", "%fpa15", \
 "%fpa16", "%fpa17", "%fpa18", "%fpa19", "%fpa20", "%fpa21", "%fpa22", "%fpa23", \
 "%fpa24", "%fpa25", "%fpa26", "%fpa27", "%fpa28", "%fpa29", "%fpa30", "%fpa31" }
#endif /* defined SUPPORT_SUN_FPA */
----------------------------------------------------------------------

Note the use of a % prefix on the registers.  I found you need this,
although having the compiler add an _ to all symbols is a viable
alternative.

You then need to change md to be config/m68k/m68k.md and aux-output.c
to be config/m68k/m68k.c.  Change the makefile so that
target=m68k-unknown-coff and use the GNU make which comes with djgpp 1.11
I cannot remember if I did any more than that.  When the compiler has
built coff2exe it and install it somewhere and you should be able to
generate 680x0 assembler.

Gas and binutils have some common bits.  libiberty and opcodes are
target independent so leave them as you build them for the 386
compiler.

In bfd change the makefile to look like this:

targets.o : targets.c
        gcc $(CFLAGS) -I. -I../include -DSELECT_VECS=&m68kcoff_vec -c $*.c

archures.o : archures.c
        gcc $(CFLAGS) -I. -I../include -DSELECT_ARCHITECTURES=bfd_m68k_arch -c $*.c

And remake bfd.

In gas you need to change these files:

-rwxrwxr-x   1 mt00     eng        15153 Apr 20 08:46 makefile*
-rwxrwxr-x   1 mt00     eng           13 Apr 13 16:15 config-s*
drwxrwxr-x   5 mt00     eng          128 Apr 13 16:05 testsuit/
drwxrwxr-x   2 mt00     eng           64 Apr 13 16:04 doc/
drwxrwxr-x   2 mt00     eng         1760 Apr 13 16:04 config/
-rwxrwxr-x   1 mt00     eng         1807 Nov 28 01:21 configur.bat*
-rwxrwxr-x   1 mt00     eng          398 Jun 28  1993 gas.rf*

----config.h--------------------------------------------------------------
#define TARGET_CPU "m68k"
#define TARGET_ALIAS "m68k-unknown-coff"
#define TARGET_CANONICAL "m68k-unknown-coff"
#define GAS_VERSION "2.1"
--------------------------------------------------------------------------

obj-form.h is config/objcoffb.h
obj-form.c is config/objcoffb.c

I don't think I changed the makefile.  I really ought to record what I
do as I go along :-(

Try making that.

The binutils were where I had trouble.  libiberty, bfd and opcodes are
the same as for gas.

If you have trouble generating undersco.c use this:

----undersco.c------------------------------------------------------------
/*WARNING: This file is automatically generated!*/
int prepends_underscore = 0;
--------------------------------------------------------------------------
Again I don't think I made any changes to the makefile so this should
get you the utilities.

Now for ld...

I never did get genscsipts.sh to work.  And I never managed to get
satisfactory versions of these file despite having the UNIX build
counterparts:

  m68kcoff.xr  m68kcoff.xbn  m68kcoff.xn  m68kcoff.xu  m68kcoff.x

You don't need them though.  When using the linker specify your own
link command file using the -T option and all will be well.

I commented out the call to genscsipts.sh in the makefile.  The
supplied e_m68kco.c is OK so you don't need to rebuild that.

You need these files:

--ldemul-l.h--------------------------------------------------------------
extern ld_emulation_xfer_type ld_m68kcoff_emulation; 
#define EMULATION_LIST \
  &ld_m68kcoff_emulation,\
0
--------------------------------------------------------------------------

--ldemul-l.dj-------------------------------------------------------------
sun4
sun3
go32
news
vax
hp300bsd
hp3hpux
hppaosf
i386aout
ebmon29k
sa29200
a29k
m88kbcs
h8300hms
h8500hms
sh
st2000
z8ksim
vanilla
lnk960
gld960
m68kcoff
i386coff
mipslit
i386bsd
mipsbig
mipsbsd
mipsidt
--------------------------------------------------------------------------

Again, I don't think I changed the makefile.  make that and you should
get an ld.



Hope that does the job for you, at least it made me try to record how
I did it!  Let me know how you get on.

-- 
Martin Tomes
Janet:    Martin DOT Tomes AT uk DOT co DOT eurotherm DOT controls
Internet: Martin DOT Tomes AT controls DOT eurotherm DOT co DOT uk
UUCP:     {uknet,uunet}!etherm!Martin.Tomes

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019