2 These notes were written to record the current state of this code.
3 Much of it was written during the investigation work.
5 At present this stuff is only partially functional. Do not assume
6 anything works. In particular things like constructor/destructors and
7 init/fini sections have not been fully implemented.
10 Initial Investigations
11 ======================
13 Attempts to build a simple shared library using the existing
14 tools. Command line is something like:
16 xxx-gcc -shared -o libfoo.so foo.so
19 arm-elf no - includes crt0 which fails to find main() etc.
20 thumb-elf no - includes crt0 which fails to find main() etc.
22 i386-elf no - tries to build program
23 mn10300 no - tries to build program
24 powerpc-eabi no - implicit ref to libc.so
25 sh-elf no - tries to build program
26 sparclite no - fails to find crtn.o
27 mips-tx39-elf yes - but seriously mangles PHDR DYNAMIC section
28 mips66vr4300-elf yes - but seriously mangles PHDR DYNAMIC section
31 Building new Toolchains
32 =======================
34 Given the poor results from our standard toolchains, it was decided to
35 try and use Linux-targeted toolchains, which are guranteed to have the
38 These builds all use bindutils-2.1.1, gcc-2.95.2 and gdb-5.0.
40 arm-unknown-linux-gnu build of libgcc fails looking for asm/unistd.h
42 All MIPS Linux toolchains use collect2 constructors, so no priorities.
43 MIPS support also requires PIC code support, which needs HAL
44 changes. In this case it is fairly easy since the assembler does a lot
45 of the conversion for us but there are still some things that need
48 MIPS BSD toolchains fail building libgcc, but adding files from
49 openbsd sources allows these to build. However, these then fail to
50 build proper PIC code and omit some features.
52 PowerPC toolchains need to use the full ABI, not the ebedded one, with
53 TOCs and all the trimmings. This requires major changes to the
54 HAL. Or maybe not - not too sure about this one.
56 Since we are having so much difficulty getting any of these to work,
57 try to get it running on the i686-pc-linux-gnu synthetic target, since
64 To enable a progam to be capable of loading a shared library it must
65 include a DYNAMIC section. This includes the symbol, string and hash
66 tables needed to satisfy any references from the loaded library back
67 to the executable. The only way I have so far worked out to make this
68 happen is to link the executable against a dynamic library. This needs
69 the -Wl,-static flag to be removed.
71 A simple library, libdlforce.so has been created to make this
72 happen. It is not even necessary for the progam to call into the
73 library, just having it on the command line is enough.
76 Generation of usable libraries and executables is very sensitive to
77 the exact form of the linker scripts used.
79 src/dynamic.ld has been replaced by a very lightly edited copy of
80 i686-pc-linux-gnu/H-i686-pc-linux-gnu/i686-pc-linux-gnu/lib/ldscripts/elf_i386.xs
82 To make the main executable work correctly the i386.dynamic.ld script
83 in this directory must be copied over target.ld before building any
84 programs. I have not yet worked out what the problems are, but the
85 original target.ld causes programs built for dynamic loading to
88 If we try to use the POSIX package, we get spurious calls to
89 pthread_mutex_unlock() from somewhere in the Linux runtime. This may
90 be a result of using a different linker script, however.
96 Having got the synthetic target sort-of working, now go back and see
97 what happens when configuring each of our standard toolchains for the
100 arm-elf - build of shared library with external references
101 result in "undefined reference to `fee'".
103 mips-tx39-elf - mangles DYNAMIC section as before.
105 powerpc-eabi - Compiler selects a libgcc.a that contains references
106 to "abort" and "strcmp". With these defined we get
107 sensible looking libraries.