I need to write loader for statically linked ELF file. Program should load and execute one ELF file, then another ELF, etc. ELF file have predefined loading address. How to free space on that address if it is allocated by another program? How to transfer control to loading program and how to get it back when program finishes? Which parts should be relocated? What about GOT, PLT, symbols, interp?
Well by this questions, you can see that i'm not very experienced in this. I'm learning, this project is for school.
Loader for statically linked ELF file
Loader for statically linked ELF file
Last edited by papillon on Wed Jun 19, 2013 4:44 pm, edited 1 time in total.
Re: Loader for statically linked ELF file
I'm not sure that answering school homework is a very profitable use for this site. You might find that you learn more if you actually researched this for yourself. If you find that difficult you should probably discuss your problems with your teacher.
Re: Loader for statically linked ELF file
Well, you can direct me to some things that i should read. I already have lots of material for reading but maybe you'll show me something that i don't have.
Re: Loader for statically linked ELF file
Then read it.papillon wrote:I already have lots of material for reading
Programming is 80% Math, 20% Grammar, and 10% Creativity <--- Do not make fun of my joke!
If you're new, check this out.
If you're new, check this out.
Re: Loader for statically linked ELF file
I'm sure that you will appreciate that it is a bit difficult for me to show you something that you don't have when I don't know what you have.I already have lots of material for reading but maybe you'll show me something that i don't have.
To my mind, the main point of education is to teach you how to find out answers by yourself. Reading the Wiki here will help for starters.
Re: Loader for statically linked ELF file
You are right for learning.
And for ELF file, i'm gonna read segments it using Elf32_Ehdr and Elf32_Phdr, mmap it to memory or to image and then to memory(?).
My problem is "ELF file have predefined loading address. How to free space on that address if it is allocated by another program? How to transfer control to loading program and how to get it back when program finishes?"
And for ELF file, i'm gonna read segments it using Elf32_Ehdr and Elf32_Phdr, mmap it to memory or to image and then to memory(?).
My problem is "ELF file have predefined loading address. How to free space on that address if it is allocated by another program? How to transfer control to loading program and how to get it back when program finishes?"
Re: Loader for statically linked ELF file
One way to solve the load address issue is to use the same address for all user programs. This is accomplished by using the paging mechanism built in to the processor. This has the added advantage that a program cannot access another program's memory.
Re: Loader for statically linked ELF file
Go learn about paging and how fully endlessly wonderful it is. If you are writing an operating system, be sure to implement paging before implementing a program loader.
Re: Loader for statically linked ELF file
I just checked the Wikipedia article about paging. I think it emphasizes perhaps too much secondary storage extension of main memory. However, perhaps the article concentrates on that. It is true that it is an important aspect but I would not considered it the most important thing nowadays. The main thing is the virtual memory so that you can have unique memory space for different programs (with user/system privileges). Also, you are not so dependent on whether physical memory is contiguous or not.
Why I said this? I think there might be some beliefs among beginners that paging is only needed when starting to implement secondary storage extension of main memory. Besides, I strongly believe that this feature is not necessary anymore.
Why I said this? I think there might be some beliefs among beginners that paging is only needed when starting to implement secondary storage extension of main memory. Besides, I strongly believe that this feature is not necessary anymore.