Article View: gnu.gcc.help
Article #52381Re: big-endian loader for little-endian machine
From: Peter Dufault
Date: Thu, 22 Oct 1992 16:20
Date: Thu, 22 Oct 1992 16:20
133 lines
3942 bytes
3942 bytes
In article <1992Oct14.184802.19669@engage.pko.dec.com> ewanco@kalvin.enet.dec.com writes:
>
>I am trying to use GNU to produce executable files for an embedded system
>(which reads a.out files). The host is a little-endian MIPS (DS3100). The
>target is 68030.
Check the new binutils. They may support it directly using the new
GNU binary file access mechanism (I forget the name). If not,
or if you don't want to update to "beta" code, here are the
diffs for the ld.c from binutils-1.9
and for gas-1.38. This was a quick hack and it can obviously be
done better, but this works for i860 -> 68020.
diff binutils/ld.c ../gnu-dist/gnu/binutils-1.9/ld.c
90,136d89
< #define PETER
<
< /* Peter Dufault's hacks for cross development.
< */
< #define CROSS_LINKER
< #ifdef CROSS_LINKER
< #ifdef PETER
< void
< cross_copy(buf,val,n)
< char *buf;
< long val;
< int n;
< {
< switch(n) {
< case 1:
< *buf++=val;
< break;
< case 2:
< *buf++=(val>>8);
< *buf++=val;
< break;
< case 4:
< *buf++=(val>>24);
< *buf++=(val>>16);
< *buf++=(val>>8);
< *buf++=val;
< break;
< default:
< abort();
< }
< }
< #endif /* peter */
< #endif /* CROSS_LINKER */
<
< #ifdef PETER
<
< void short_target_swap(short *s)
< {
< *s = ntohs(*s);
< }
<
< void long_target_swap(long *l)
< {
< *l = ntohl(*l);
< }
< #endif
<
187c140
< #if defined(alliant) || defined(vax) || defined(sony_news) || defined(hp300) || defined(pyr)
---
> #if defined(vax) || defined(sony_news) || defined(hp300) || defined(pyr)
205c158
< #if defined(alliant) || defined(vax) || defined(sony_news) || defined(hp300) || defined(pyr)
---
> #if defined(vax) || defined(sony_news) || defined(hp300) || defined(pyr)
5137d5089
<
5149,5152d5100
< #ifdef PETER
< short_target_swap((short *)(data + addr));
< #endif
<
5169,5171c5117
< #ifdef PETER
< cross_copy (data + addr, thing, sizeof (thing));
< #endif
---
> bcopy (&thing, data + addr, sizeof (thing));
5180,5182d5125
< #ifdef PETER
< long_target_swap((long *)(data + addr));
< #endif
diff gas/write.c ../gnu-dist/gnu/gas-1.38/write.c
1d0
<
150,155d148
<
< /* routine to get numbers out in little endian order */
<
< #define md_number_to_chars host_number_to_chars
< #define md_number_to_imm host_number_to_chars
<
157,181d149
< host_number_to_chars(buf,val,n)
< char *buf;
< long val;
< int n;
< {
< switch(n) {
< case 1:
< *buf++=val;
< break;
< case 2:
< *buf++=val;
< *buf++=(val>>8);
< break;
< case 4:
< *buf++=val;
< *buf++=(val>>8);
< *buf++=(val>>16);
< *buf++=(val>>24);
< break;
< default:
< abort();
< }
< }
<
< void
579c547
< md_number_to_chars(untruth->word_goes_here,to_addr,2);
---
> md_number_to_chars(untruth->word_goes_here,to_addr,2);
1272d1239
< #if 0 /* emit relocations in native order for cross assembly */
1274d1240
< #endif
Technical Details
Message-ID:
<1992Oct22.162015.28584@alliant.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!think.com!ames!agate!linus!alliant!dufaultReferences:
<1992Oct14.184802.19669@engage.pko.dec.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 11318c,a3def8c5d5ba923a X-Google-Attributes: gid11318c,public X-Google-ArrivalTime: 1992-10-22 05:23:28 PST Newsgroups: gnu.gcc.help Path: arc1-ca.pugleaf.net!sparky!uunet!think.com!ames!agate!linus!alliant!dufault From: dufault@alliant.com (Peter Dufault) Subject: Re: big-endian loader for little-endian machine Message-ID: <1992Oct22.162015.28584@alliant.com> Sender: dufault@alliant.com Organization: Alliant Computer Systems Corp. References: <1992Oct14.184802.19669@engage.pko.dec.com> Date: Thu, 22 Oct 1992 16:20:15 GMT Lines: 134