Subject: Re: ELF
To: Bill Studenmund <wrstuden@zembu.com>
From: Frederick Bruckman <fredb@immanent.net>
List: port-mac68k
Date: 07/16/2001 17:39:59
On Mon, 9 Jul 2001, Bill Studenmund wrote:

> On Sun, 13 May 2001, Frederick Bruckman wrote:
>
> > What about adding a post-linker step to convert the kernel to aout?
> > Something along the lines of "objcopy -I elf32-m68k -O
> > a.out-m68k-netbsd netbsd.ELF netbsd". It might even be possible to
> > specify "-oformat a.out-m68k-netbsd" as an argument to "ld". If
> > neither works, see what other magic "elf2aout" on i386 accomplishes.
>
> Having worked in making ofwboot.xcf using an ELF toolchain, you might have
> problems. But then again, the problems might just have been binutils/XCOFF
> specific.
>
> One problem is that ELF files have a lot more sections than a.out and
> XCOFF ones do. So you have to do something to compact or remove
> sections. The file sys/arch/macppc/stand/fixcoff/elf32_powerpc_merge.x is
> a linker script which munges ELF files into a set of sections which work
> for converting to XCOFF. It might even work for converting to a.out.

That's the ticket! I modified the script slightly to specify
OUTPUT_FORMAT(a.out-m68k-netbsd) and added

  /DISCARD/     :
  {
    *(.ident)
    *(.note)
  }

to the beginning of the SECTIONS.

I don't actually have an m68k/ELF toolchain on the mac, so I tested
the idea of building an i386/a.out kernel on 1.5.1/i386. When I go to
cross-compile an m68k kernel (with the package m68k/ELF 1.3.0
compiler), I run into more problems...

Everything mostly compiles with the addition of
"-Wa,--register-prefix-optional" to ${CFLAGS}, and
--register-prefix-options to ${NORMAL_S}.

The compiler doesn't like the bit in mrg_aline_super() about being
told to preserve "a6". I wonder how it can -- maybe that's just a
no-op with the old compiler.

Finally, there's the business of ELF adding underscores to symbol
names, causing many of the assembly defined entry points to give
"undefined symbol" at linktime (even without the ldscript). How are
you supposed to deal with that?


Frederick