Subject: Re: Linking a.out on elf machines
To: Krister Walfridsson <>
From: Bill Studenmund <>
List: tech-toolchain
Date: 05/22/2000 10:21:06
On Sun, 21 May 2000, Krister Walfridsson wrote:

> I haven't really followed the discussions about a.out to elf transission,
> but as I understand, the idea is to compile an a.out on elf machines
> too, to make it possible to use old binaries. Anyway, I have promised to
> teach to make a.out shared libs.
> I have a (nearly) working version now, but I don't really understand how
> this will help us... But my knowledge is in the inner working of libbfd,
> not in the binutils, so I may have misunderstood something.
> Bill Studenmund tried some with this in december, and did:
>    ld -o -Ttext 0x1020   -L/usr/src/lib/libc/obj.i386
>    mdprologue.o rtld.o malloc.o shlib.o md.o vfprintf.o -lc_pic
>    crunchide -v -u
>    objcopy -R .note -R .ident
>    ld -o --oformat a.out-i386-netbsd  -T \
>    /usr/src/libexec/ld.aout_so/elf_aout_merge.x -Bshareable \
>    -Bsymbolic -assert nosymbolic
> But the first link creates an executable. Is it obvious that it
> can be converted to an a.out shared lib? It doesn't work for me
> anyway...
> I tried to convert the .o files to a.out and then link normally,
> but I cannot use objcopy to convert the files. It complains that
> it cannot represent .rodata in a.out object file format...
> So, does anyone have any suggestions on how this should be solved?

I talked to Ian about it, and I think the above procedure is
wrong. Whatever we do, we need to call ld once, not twice.

I found out that is statically linked on most other systems he's
familiar with. ;-)

The reason for the two ld's was to use the first to make one object which
the following steps could operate on, rather than itterating on alot of
files. I now thing we need to jsut bite the bullet and itterate.

The things we need to do are:

1) have an ld script which throws away/merges things right. I think I have
one, but I need to have it throw away .note and .ident sections.

2) somehow make it so that the common sections in elf get handled right.
The thing is that (as I understand it) the GOT (Global Offset Table) is
made special by the linker rather than being another section as it is in
elf. The trick is that the elf labels pointing to the GOT need to line up
right with what the linker will make. I'm not sure how to do that. I was
trying to use elven->a.out renaming (add "_"'s), but that would now mean
making renamed .o's for each part of -lc_pic.


Take care,