This is the mail archive of the mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Output ecoff binary using alpha cross compiler

Tao Zhang <> wrote:

> I cross-compiled an alpha gcc toolchain using Dan's script. I am using
> gcc3.2.3 + glibc2.2.5. Later, I found the compiler outputs binary in
> elf64-alpha format. But I want the binary in ecoff format. I checked the
> cross compiler, it seems it supports ecoff-littlealpha format too. I tried
> to pass option "--oformat ecoff-littlealpha" to the compiler, and got
> enumorous errors, something like "relocation truncated to fit ...". I
> think the cross compiler can only work for the default target, which is
> elf64-alpha. I tried other elf targets, there will be a segmentation fault
> in ld.

 If you need ecoff as default from your Linux/Alpha toolchain, the old

          tm_file="${tm_file} alpha/linux-ecoff.h alpha/linux.h"
          tmake_file="alpha/t-alpha alpha/t-ieee"
          gas=yes gnu_ld=yes

still present in gcc-3.2.3, is available... This has been dropped
from gcc-3.3.1 ("not supported any more").
> I guess the problem is that when compiling glibc, the compiler has
> elf64-alpha in its mind? That means the objects files are dependent
> on the targets?

 Yes, the current Linux/Alpha object format is ELF but sometimes in
the short history of Linux (12 years, compared to the 34 years of
Unix), the Alpha format seems to have been ECOFF. Linux/Alpha was
the 2nd Linux port AFAIK, so the ECOFF-using Linuces must be quite
old, RedHat5/Alpha I had in "RedHat PowerTools" CD from 1997 seemed
to use ELF already.

 The original Linux/x86 used the 'aout' format and when using that
the C library wasn't the FSF glibc release at all, but something
'custom'. Even when moving to ELF the C library was not yet glibc,
but the 'libc5'... RedHat 5.x and SuSE 5.x still used the 'libc5'
which wasn't the FSF's 'glibc-2.x'. So this 'alpha*-*-linux*ecoff*'
is not expected to use any glibc-2.x, but something 'custom' C
library like 'libc5'...

> So when the linker tries to mix elf object files and ecoff
> object files, it fails.

 Some systems like the old 'SCO Unix 3.2v[2-5]' had both COFF and
ELF in use during its history, so the current 'OSR5.0.x' has the
startups in COFF and libs in ELF:

mt586kr:/home2/usr/local/i486-sco3.2v5/lib # ../bin/objdump -p crt1.o

crt1.o:     file format coff-i386

mt586kr:/home2/usr/local/i486-sco3.2v5/lib # ../bin/objdump -p     file format elf32-i386

 Linking these mixed together for an ELF executable however should work...

 Also the SGI Irix'es could have old ECOFF stuff from Irix4 and
linking this with the Irix5 ELF stuff could work...

 In the Linux/x86 world mixing the 'aout' stuff with 'elf' stuff could
have worked too in some time when it was needed but maybe not any more.

 Ok, the linker for 'alpha-linux-gnu' should accept the 'ecoff' format

  /home2/usr/local/alpha-linux-gnu/bin > ./ld -V
  GNU ld version 20021126
    Supported emulations:

and the supported formats are:

  /home2/usr/local/alpha-linux-gnu/bin > ./objdump --help


  ./objdump: supported targets: elf64-alpha ecoff-littlealpha
   elf64-little elf64-big elf32-little elf32-big
   srec symbolsrec tekhex binary ihex
  ./objdump: supported architectures: alpha alpha:ev4 alpha:ev5 alpha:ev6

so in theory at least producing ecoff executables from pure ecoff objects
and producing elf executables from pure elf objects should work. But
mixing formats maybe not... (I put those outputs as hints about suitable
commands for newbies reading messages here...) 

> C source file is obviously independent on whether it will be an ecoff
> binary or an elf binary. I am curious about from which phase the
> intermediate file begins to depend on the target...

 The C/C++/ObjC/F77/Java etc. backends should generate '.s' files suitable
for either an 'ecoff' or 'elf' assembler. GCC seemingly can produce only
one format, either ELF or ECOFF. So already GCC must be made for the right
output format...

> Any advice on how to ask the alpha cross compiler to produce correct ecoff
> binary?

 Producing separate toolchains for the 'alpha-linux-ecoff' and 'alpha-linux-gnu'
cases could be the easy way. It is up to you what you want to achieve, but
generally trying to produce a "Swiss Army Knife" with 10 or so different tools
in one is always harder than producing the 10 separate tools...

 You could try to elaborate what is your target and why you need to produce
the ecoff format executables...

 I tried also your issue using:

   -static -Wl,--oformat,ecoff-littlealpha

on the compile command. While the linker accepted all the input stuff
(ELF), producing an ECOFF-format executable from them wasn't possible
giving the errors you mentioned...

 Trying this with some possible ELF/COFF combinations told that x86 had
problems but the embedded m68k and SH toolchains seemed to work:

/home1/kai/test/hello > gcc-m68k-elf -Os -Wl,--oformat,coff-m68k -o hi_m68k-coff
/home1/kai/test/hello > file hi_m68k-coff
hi_m68k-coff: mc68k COFF object not stripped (demand paged)
/home1/kai/test/hello > gcc-sh-elf -Os -Wl,--oformat,coff-sh -o hi_sh-coff hello
/home1/kai/test/hello > file hi_sh-coff
hi_sh-coff: data
/home1/kai/test/hello > /usr/local/sh-elf/bin/objdump -p hi_sh-coff

hi_sh-coff:     file format coff-sh

 So expecting a ELF-based toolchain to be capable to produce COFF-format
executables may be sane sometimes...

Cheers, Kai

Want more information?  See the CrossGCC FAQ,
Want to unsubscribe? Send a note to

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]