📄 notes.txt
字号:
These notes were written to record the current state of this code.Much of it was written during the investigation work.At present this stuff is only partially functional. Do not assumeanything works. In particular things like constructor/destructors andinit/fini sections have not been fully implemented. Initial Investigations====================== Attempts to build a simple shared library using the existingtools. Command line is something like:xxx-gcc -shared -o libfoo.so foo.soarm-elf no - includes crt0 which fails to find main() etc.thumb-elf no - includes crt0 which fails to find main() etc.i686-pc-linux-gnu yesi386-elf no - tries to build programmn10300 no - tries to build programpowerpc-eabi no - implicit ref to libc.sosh-elf no - tries to build programsparclite no - fails to find crtn.omips-tx39-elf yes - but seriously mangles PHDR DYNAMIC sectionmips66vr4300-elf yes - but seriously mangles PHDR DYNAMIC sectionBuilding new Toolchains=======================Given the poor results from our standard toolchains, it was decided totry and use Linux-targeted toolchains, which are guranteed to have thenecessary support.These builds all use bindutils-2.1.1, gcc-2.95.2 and gdb-5.0.arm-unknown-linux-gnu build of libgcc fails looking for asm/unistd.hAll MIPS Linux toolchains use collect2 constructors, so no priorities.MIPS support also requires PIC code support, which needs HALchanges. In this case it is fairly easy since the assembler does a lotof the conversion for us but there are still some things that needfixing.MIPS BSD toolchains fail building libgcc, but adding files fromopenbsd sources allows these to build. However, these then fail tobuild proper PIC code and omit some features.PowerPC toolchains need to use the full ABI, not the ebedded one, withTOCs and all the trimmings. This requires major changes to theHAL. Or maybe not - not too sure about this one.Since we are having so much difficulty getting any of these to work,try to get it running on the i686-pc-linux-gnu synthetic target, sincewe know that works.Synthetic Target================To enable a progam to be capable of loading a shared library it mustinclude a DYNAMIC section. This includes the symbol, string and hashtables needed to satisfy any references from the loaded library backto the executable. The only way I have so far worked out to make thishappen is to link the executable against a dynamic library. This needsthe -Wl,-static flag to be removed.A simple library, libdlforce.so has been created to make thishappen. It is not even necessary for the progam to call into thelibrary, just having it on the command line is enough.Generation of usable libraries and executables is very sensitive tothe exact form of the linker scripts used.src/dynamic.ld has been replaced by a very lightly edited copy of i686-pc-linux-gnu/H-i686-pc-linux-gnu/i686-pc-linux-gnu/lib/ldscripts/elf_i386.xsTo make the main executable work correctly the i386.dynamic.ld scriptin this directory must be copied over target.ld before building anyprograms. I have not yet worked out what the problems are, but theoriginal target.ld causes programs built for dynamic loading toSIGSEGV in ld.so.If we try to use the POSIX package, we get spurious calls topthread_mutex_unlock() from somewhere in the Linux runtime. This maybe a result of using a different linker script, however.Retesting toolchains====================Having got the synthetic target sort-of working, now go back and seewhat happens when configuring each of our standard toolchains for theloader.arm-elf - build of shared library with external references result in "undefined reference to `fee'".mips-tx39-elf - mangles DYNAMIC section as before.powerpc-eabi - Compiler selects a libgcc.a that contains references to "abort" and "strcmp". With these defined we get sensible looking libraries.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -