OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [services/] [loader/] [v2_0/] [docs/] [notes.txt] - Blame information for rev 174

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
 
2
These notes were written to record the current state of this code.
3
Much of it was written during the investigation work.
4
 
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.
8
 
9
 
10
Initial Investigations
11
======================
12
 
13
Attempts to build a simple shared library using the existing
14
tools. Command line is something like:
15
 
16
xxx-gcc -shared -o libfoo.so foo.so
17
 
18
 
19
arm-elf                 no - includes crt0 which fails to find main() etc.
20
thumb-elf               no - includes crt0 which fails to find main() etc.
21
i686-pc-linux-gnu       yes
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
29
 
30
 
31
Building new Toolchains
32
=======================
33
 
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
36
necessary support.
37
 
38
These builds all use bindutils-2.1.1, gcc-2.95.2 and gdb-5.0.
39
 
40
arm-unknown-linux-gnu   build of libgcc fails looking for asm/unistd.h
41
 
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
46
fixing.
47
 
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.
51
 
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.
55
 
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
58
we know that works.
59
 
60
 
61
Synthetic Target
62
================
63
 
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.
70
 
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.
74
 
75
 
76
Generation of usable libraries and executables is very sensitive to
77
the exact form of the linker scripts used.
78
 
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
81
 
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
86
SIGSEGV in ld.so.
87
 
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.
91
 
92
 
93
Retesting toolchains
94
====================
95
 
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
98
loader.
99
 
100
arm-elf         - build of shared library with external references
101
                  result in "undefined reference to `fee'".
102
 
103
mips-tx39-elf   - mangles DYNAMIC section as before.
104
 
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.

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.