How dynamic linker works?
michael_quinlivan_at_hotmail.com
Date: 09/22/05
- Previous message: B. Weerts (The Force - IT Professionals): "Looking for Linux application developer / System SW developer (freelance)"
- Next in thread: John Reiser: "Re: How dynamic linker works?"
- Reply: John Reiser: "Re: How dynamic linker works?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 22 Sep 2005 06:08:12 -0700
Hi all
I am trying to get an understanding of the loading and dynamic linking
process to create my own loader and linker for an OS that I'm writing,
so that it can run Linux binaries.
I have read the ELF spec, and have a fairly good understanding of each
component of an executable and shared object image, except for the
processes involved in relocation, and how the PLT and GOT work. The
following is my knowledge on the subject and the questions I have. Any
info you may have on this or pointers to documentation would be
helpful.
1. Linux creates a new process address space and maps the executable
into memory, according to the segments describes in the program header
table
2. It reads the PT-INTERP section, and determines that the dynamic
linker is required. This is ld-linux.so.* or whatever...
3. Linux loads ld-linux.so into the processes address space.
4. Linker is initialised by calling its INIT section (???)
5. Linkers entry point is called. I assume the entry point is found in
the ELF header like executables are?? The code will now
perform the other .so file loads and relocations associated with the
process. I assum ld-linux initialised itself and performed its own
relocations during init.
How does ld-linux know where the executable is mapped? Does Linux pass
a pointer with this information on the stack to ld-linux???
Anyway, my biggest question is how are relocations performed? I think
I understand the PLT and how it acts as a table of jumps staright into
the linkers fixup routine, which will then modify the PLt so that it
points to the correct instruction the second time. It is mostly the
variety of different relocation types that gets me confused, especially
in regards to the GOT. What do they mean and how are they fixed up.
Also, not too sure how the hash table works
Diagrams, examples, algorithms would be helpful as well, or even
pointers to the most important source code in the glibc library. I
have looked in the /elf subdir but there are so many files I dont know
where to start.
thanks all
MQ
- Previous message: B. Weerts (The Force - IT Professionals): "Looking for Linux application developer / System SW developer (freelance)"
- Next in thread: John Reiser: "Re: How dynamic linker works?"
- Reply: John Reiser: "Re: How dynamic linker works?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|