Subject: Making an aout shared object on an ELF system
To: None <tech-toolchain@netbsd.org>
From: Bill Studenmund <wrstuden@nas.nasa.gov>
List: tech-toolchain
Date: 12/29/1999 15:00:57
This message is in MIME format. The first part should be readable text,
while the remaining parts are likely unreadable without MIME-aware tools.
Send mail to mime@docserver.cac.washington.edu for more info.
---559023410-824023566-946508457=:22340
Content-Type: TEXT/PLAIN; charset=US-ASCII
One of the ideas for helping the elf transition is to make a modified
ld.so for a.out. Well, to do that, we need to be able to make a.out
objects on an elf system.
I've got something which links, but doesn't work. And some strange things
are going on in the resulting binary which I don't understand.
From what I can tell, a whole lot of the symbols which get put into the
a.out file are at 0x1000 less than they were in the ELF version, even
though the disassembled code hasn't moved.
Here's what I'm doing now, I make all of the .o's using gcc. Then:
ld -o ld_aout.so.mrg -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 ld_aout.so.mrg
objcopy -R .note -R .ident ld_aout.so.mrg ld_aout.so.mrg1
ld -o ld_aout.so --oformat a.out-i386-netbsd -T \
/usr/src/libexec/ld.aout_so/elf_aout_merge.x -Bshareable \
-Bsymbolic -assert nosymbolic ld_aout.so.mrg1
First, I use ld to make one object file, which hopefully contains all of
the code needed. Then I run a modified version of crunchide which prepends
"_" to all of the variable names. Third I use objcopy to get rid of the
.note and .ident sections. Lastly, I use ld to make an a.out file, merging
a bunch of the sections together, and doing the final linking.
I'm attaching the merge file to this note.
When I diff the results of objdump -dx for ld_aout.so.mrg1 and ld_aout.so,
I see a bunch of:
1023: 53 pushl %ebx
- 1024: e8 00 00 00 00 call 1029 <__rtl+0x9>
+ 1024: e8 00 00 00 00 call 1029 <_rtld+0xfa1>
1029: 5b popl %ebx
in the disassembly. When I look at the symbols, I see:
Name old value new value
__tcgetattr 0x00007e24 0x00006e24
_printf 0x000054f4 0x000044f4
_remove_search_dir 0x00003624 0x00002624
This list was done by had. Doing an automatic compare, I find that a few
symbols have the same value (___bss_start), and a few are off by other
than 0x1000.
I noticed that some symbols disapeared. I guess that the linker is
throwing away unused routines. That's fine. But the error in symbol values
don't correspond to just that. For instance, _binder (one of the early
routines) is 26b4 in the Elf, and 16b4 in the a.out. ??
Thoughts?
Take care,
Bill
---559023410-824023566-946508457=:22340
Content-Type: TEXT/PLAIN; charset=US-ASCII; name="elf_aout_merge.x"
Content-Transfer-Encoding: BASE64
Content-ID: <Pine.SOL.3.96.991229150057.22340C@marcy.nas.nasa.gov>
Content-Description: elf section merge-up file
U0VDVElPTlMNCnsNCiAgLyogUmVhZC1vbmx5IHNlY3Rpb25zLCBtZXJnZWQg
aW50byB0ZXh0IHNlZ21lbnQ6ICovDQogIC4gPSArIFNJWkVPRl9IRUFERVJT
Ow0KICAuaW50ZXJwIDogeyAqKC5pbnRlcnApIH0NCiAgLmhhc2ggICAgICAg
ICAgOiB7ICooLmhhc2gpCQl9DQogIC5keW5zeW0gICAgICAgIDogeyAqKC5k
eW5zeW0pCQl9DQogIC5keW5zdHIgICAgICAgIDogeyAqKC5keW5zdHIpCQl9
DQogIC5yZWwudGV4dCAgICAgIDogeyAqKC5yZWwudGV4dCkJCX0NCiAgLnJl
bGEudGV4dCAgICAgOiB7ICooLnJlbGEudGV4dCkgCX0NCiAgLnJlbC5kYXRh
ICAgICAgOiB7ICooLnJlbC5kYXRhKQkJfQ0KICAucmVsYS5kYXRhICAgICA6
IHsgKigucmVsYS5kYXRhKSAJfQ0KICAucmVsLnJvZGF0YSAgICA6IHsgKigu
cmVsLnJvZGF0YSkgCX0NCiAgLnJlbGEucm9kYXRhICAgOiB7ICooLnJlbGEu
cm9kYXRhKSAJfQ0KICAucmVsLmdvdCAgICAgICA6IHsgKigucmVsLmdvdCkJ
CX0NCiAgLnJlbGEuZ290ICAgICAgOiB7ICooLnJlbGEuZ290KQkJfQ0KICAu
cmVsLmN0b3JzICAgICA6IHsgKigucmVsLmN0b3JzKQl9DQogIC5yZWxhLmN0
b3JzICAgIDogeyAqKC5y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IC5ic3MgICAgICAgOg0KICB7DQog
ICAqKC5zYnNzKSAqKC5zY29tbW9uKQ0KICAgKiguZHluYnNzKQ0KICAgKigu
YnNzKQ0KICAgKihDT01NT04pDQogIH0NCiAgX2VuZCA9IC4gOw0KICBQUk9W
SURFIChlbmQgPSAuKTsNCn0NCg==
---559023410-824023566-946508457=:22340--