Essentially, this is what I would like to do:
1. Produce a library called libsys.a
2. Link init with it statically, so the program headers in init read roughly like this:
Code: Select all
Elf file type is EXEC (Executable file)
Entry point 0x8049100
There are 3 program headers, starting at offset 52
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
LOAD 0x000000 0x08048000 0x08048000 0x01334 0x01334 R E 0x1000
LOAD 0x001334 0x0804a334 0x0804a334 0x00088 0x00100 RW 0x1000
LOAD 0x?????? 0xfe000000 0xfe000000 0x????? 0x????? R E 0x1000
4. Link some program (foo) with it, without adding the library's code *and* without listing it as something to be loaded by the ELF loader (or even adding a DYNAMIC segment).
Here are my problems:
1. I can't get the library to be loaded at a fixed address without defining new .text and .data equivalent sections for it.
2. If I do define those sections, I would need a special linker script for each program, which wouldn't be good.
3. I can't get a library to be set to be dynamically linked at a fixed address for all programs.
4. I can't dynamically link a shared library without adding a DYNAMIC segment, which should be unneeded because of the fixed address.
Is it even possible to solve this? Is there a better approach that would load a library into memory only once like this?