🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #50782

Cross compiling on Sparc to 386 Linux

#50782
From: Clarence Wilkerson
Date: Mon, 23 Aug 1993 04:14
205 lines
8065 bytes
I'm trying to build a cross GCC to run on a SparcStation 1+,which
will produce Linux binaries.
I did the following on the Sparc:
1) created directory /usr/local/i386-ibm-linux
   with subdirectories bin, include, and lib.
   I moved the linux include files and library files into include and 
   lib.
2) compiled the binutils-2.2.1 package with
   ./configure --target=i386-ibm-linux 
   make all

   and moved the binaries produced into /usr/local/i386-ibm-linux/bin
   I had some patches to ld  for linux provided by Risto Kankkunen. 
   I append
   these patches at end of this file.

 3) I made a gas that speaks i386 and installed it in 
error messages about that also. I used the /usr/local/i386-ibm-linux/bin/ranlib to ranlib these libs.
/usr/local/i386-ibm-linux/bin.
4) I went to gcc-2.4.5 directory and did
  ./configure --target=i386-ibm-linux --with-gnu-as --with-gnu-ld
  then
  make LANGUAGES="c c++"
  all went well until the test:
./xgcc -B./ -DCROSS_COMPILE -DIN_GCC       -c ./cross-test.c
./xgcc -B./ -DCROSS_COMPILE -DIN_GCC    cross-test.o -o cross-test
/usr/local/i386-ibm-linux/bin/ld internal error ldsym.c 537
make: *** [cross-test] Error 1

Before I ranlibed the linux libraries libgcc.a and libg.a, I got
error messages about that also. I used the 
/usr/local/i386-ibm-linux/bin/ranlib to ranlib these libs.

Testing with helle.c produced a hello.o that could be linked and
executed on my linux box. So gcc itself seems to be working.
But the linking and possibly ar/ranlib  seemed to be screwed up.

Help, Clarence


>>>>>>> from Risto Kankkunen <<<<<<<
( without his permission )
From: cs.helsinki.fi!kankkune@hopf.math.purdue.edu (Risto Kankkunen)
Message-Id: <9301231404.AA24495@hydra.Helsinki.FI>
In-Reply-To: Clarence Wilkerson's message as of Jan 21, 22:44
X-Mailer: Mail User's Shell (7.2.0 10/31/90)
To: wilker (Clarence Wilkerson)
Subject: Re: patches for cross compile?
Status: R

OK. I'll append them to the end of this message. I have not verified
very closely if that contains all my changes and what of them are
actually needed. I hope they'll do the job.

I don't remember, if you had other problems to cross compile. Just in
case, you need binutils-2.0, gcc 2.3.1 or newer (the plain distribution
works, no need for linux specific changes) and gas 1.38.1 (make as
a386). Just follow the intructions with them closely and use a bit
imagination. THe required directory structure may be a bit hard to grasp
at first and you may need to make some lymlinks, too.

Here's the patch:

*** ./ld/config/i386-linux.mt.orig	Fri Dec 11 19:46:20 1992
--- ./ld/config/i386-linux.mt	Fri Dec 11 21:09:28 1992
***************
*** 0 ****
--- 1 ----
+ EMUL=i386linux
*** ./ld/configure.in.orig	Wed Dec  2 20:22:27 1992
--- ./ld/configure.in	Fri Dec 11 19:48:13 1992
***************
*** 117,122 ****
--- 117,124 ----
  			;;
    i386-go32-*)		my_target=go32
  			;;
+   i386-*-linux)		my_target=i386-linux
+ 			;;
    m88k-*-*)		my_target=m88k-bcs
  			;;
    a29k-*-udi)		my_target=sa29200
*** ./ld/i386linux.sh.orig	Fri Dec 11 21:00:26 1992
--- ./ld/i386linux.sh	Thu Dec 17 17:21:10 1992
***************
*** 0 ****
--- 1,6 ----
+ EMULATION_NAME=i386linux
+ SCRIPT_NAME=aout
+ OUTPUT_FORMAT="a.out-i386(linux)"
+ PAGE_SIZE=4096
+ TEXT_START_ADDR=0
+ ARCH=i386
*** ./ld/Makefile.in.orig	Fri Dec 11 21:03:05 1992
--- ./ld/Makefile.in	Fri Dec 11 21:09:28 1992
***************
*** 118,124 ****
  ALL_EMULATIONS=em_lnk960.o em_sun3.o em_i386aout.o em_go32.o \
  	em_m88kbcs.o em_a29k.o em_news.o em_hp300bsd.o \
  	em_h8300hms.o em_ebmon29k.o em_sun4.o em_gld960.o \
! 	em_vanilla.o em_h8300xray.o em_st2000.o em_sa29200.o
  
  EMULATION_OFILES=${ALL_EMULATIONS}
  #EMULATION_OFILES=em_${EMUL}.o ${OTHER_EMULATIONS}
--- 118,125 ----
  ALL_EMULATIONS=em_lnk960.o em_sun3.o em_i386aout.o em_go32.o \
  	em_m88kbcs.o em_a29k.o em_news.o em_hp300bsd.o \
  	em_h8300hms.o em_ebmon29k.o em_sun4.o em_gld960.o \
! 	em_vanilla.o em_h8300xray.o em_st2000.o em_sa29200.o \
! 	em_i386linux.o
  
  EMULATION_OFILES=${ALL_EMULATIONS}
  #EMULATION_OFILES=em_${EMUL}.o ${OTHER_EMULATIONS}
***************
*** 206,211 ****
--- 207,215 ----
  em_i386aout.c: $(srcdir)/i386aout.sh \
    $(srcdir)/generic.em $(srcdir)/aout.sc-sh ${GEN_DEPENDS}
  	${GENSCRIPTS} i386aout.sh
+ em_i386linux.c: $(srcdir)/i386linux.sh \
+   $(srcdir)/generic.em $(srcdir)/aout.sc-sh ${GEN_DEPENDS}
+ 	${GENSCRIPTS} i386linux.sh
  em_ebmon29k.c: $(srcdir)/ebmon29k.sh \
    $(srcdir)/generic.em $(srcdir)/ebmon29k.sc-sh ${GEN_DEPENDS}
  	${GENSCRIPTS} ebmon29k.sh
*** ./bfd/i386linux.c.orig	Fri Dec 11 21:44:44 1992
--- ./bfd/i386linux.c	Wed Dec 16 21:37:45 1992
***************
*** 18,28 ****
     is offset by 1024, while the true page size is 4096.  The former
     is the one we care about here.
  */
! #define	PAGE_SIZE	1024
  #define	SEGMENT_SIZE	4096
  #define TEXT_START_ADDR	0x0
  #define ARCH 32
  #define BYTES_IN_WORD 4
  #include "bfd.h"
  #include "sysdep.h"
  #include "libbfd.h"
--- 18,38 ----
     is offset by 1024, while the true page size is 4096.  The former
     is the one we care about here.
  */
! #define	PAGE_SIZE	4096
  #define	SEGMENT_SIZE	4096
  #define TEXT_START_ADDR	0x0
  #define ARCH 32
  #define BYTES_IN_WORD 4
+ 
+ #define N_TXTOFF(x)	\
+     (N_MAGIC(x) != ZMAGIC ? EXEC_BYTES_SIZE : /* object file or NMAGIC */\
+      N_SHARED_LIB(x) ? 0 : \
+      N_HEADER_IN_TEXT(x) ?	\
+ 	    EXEC_BYTES_SIZE :			/* no padding */\
+ 	    1024				/* a page of padding */\
+     )
+ 
+ 
  #include "bfd.h"
  #include "sysdep.h"
  #include "libbfd.h"
***************
*** 33,36 ****
--- 43,58 ----
  #define DEFAULT_ARCH bfd_arch_i386
  #define MY(OP) CAT(i386linux_,OP)
  #define TARGETNAME "a.out-i386(linux)"
+ 
+ static boolean
+ EXFUN(MY(set_sizes), bfd *abfd);
+ 
+ static CONST struct aout_backend_data MY(backend_data) = {
+   1,				/* zmagic contiguous */
+   0,				/* text incl header */
+   0,				/* text vma? */
+   MY(set_sizes),
+ };
+ #define MY_backend_data &MY(backend_data)
+ 
  #include "aout-target.h"
*** ./bfd/aoutx.h.orig	Thu Dec 17 19:47:25 1992
--- ./bfd/aoutx.h	Thu Dec 17 19:46:33 1992
***************
*** 708,714 ****
  	ztih = abdp && abdp->text_includes_header;
  	obj_textsec(abfd)->filepos = (ztih
  				      ? adata(abfd).exec_bytes_size
! 				      : adata(abfd).page_size);
  	if (! obj_textsec(abfd)->user_set_vma)
  	  /* ?? Do we really need to check for relocs here?  */
  	  obj_textsec(abfd)->vma = ((abfd->flags & HAS_RELOC)
--- 708,715 ----
  	ztih = abdp && abdp->text_includes_header;
  	obj_textsec(abfd)->filepos = (ztih
  				      ? adata(abfd).exec_bytes_size
! /*				      : adata(abfd).page_size);
! */				      : 1024);
  	if (! obj_textsec(abfd)->user_set_vma)
  	  /* ?? Do we really need to check for relocs here?  */
  	  obj_textsec(abfd)->vma = ((abfd->flags & HAS_RELOC)


-- 
                  dos, windows, nt... are you a victim of the MS disease?
Technical Details
Message-ID: <gnusenetCC72Gn.277@mentor.cc.purdue.edu>
Path: arc1-ca.pugleaf.net!gmd.de!newsserver.jvnc.net!howland.reston.ans.net!spool.mu.edu!bloom-beacon.mit.edu!ai-lab!prep.ai.mit.edu!gnulists

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11318c,520c45e6a8b44a71,start
X-Google-Attributes: gid11318c,public
X-Google-Thread: 10f1ff,520c45e6a8b44a71,start
X-Google-Attributes: gid10f1ff,public
X-Google-Thread: 100b1f,520c45e6a8b44a71,start
X-Google-Attributes: gid100b1f,public
X-Google-ArrivalTime: 1993-08-23 16:32:12 PST
To: gnu-utils-bug@gatech.edu
Distribution: world
Approved: info-gnu@prep.ai.mit.edu
Path: arc1-ca.pugleaf.net!gmd.de!newsserver.jvnc.net!howland.reston.ans.net!spool.mu.edu!bloom-beacon.mit.edu!ai-lab!prep.ai.mit.edu!gnulists
Followup-To: gnu.gcc.help,gnu.utils.bug,comp.os.linux.help
Newsgroups: gnu.gcc.help,gnu.utils.bug,comp.os.linux.help
From: wilker@cantor.math.purdue.edu (Clarence Wilkerson)
Subject: Cross compiling on Sparc to 386 Linux
Message-ID: <gnusenetCC72Gn.277@mentor.cc.purdue.edu>
Organization: Purdue University, West Lafayette, Ind.
Date: Mon, 23 Aug 1993 04:14:47 GMT
Lines: 207