Loader for statically linked ELF file

Programming, for all ages and all languages.
Post Reply
papillon
Posts: 3
Joined: Tue Apr 30, 2013 12:39 pm

Loader for statically linked ELF file

Post by papillon »

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.
Last edited by papillon on Wed Jun 19, 2013 4:44 pm, edited 1 time in total.
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Loader for statically linked ELF file

Post by iansjack »

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.
papillon
Posts: 3
Joined: Tue Apr 30, 2013 12:39 pm

Re: Loader for statically linked ELF file

Post by papillon »

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.
Mikemk
Member
Member
Posts: 409
Joined: Sat Oct 22, 2011 12:27 pm

Re: Loader for statically linked ELF file

Post by Mikemk »

papillon wrote:I already have lots of material for reading
Then read it.
Programming is 80% Math, 20% Grammar, and 10% Creativity <--- Do not make fun of my joke!
If you're new, check this out.
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Loader for statically linked ELF file

Post by iansjack »

I already have lots of material for reading but maybe you'll show me something that i don't have.
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.

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.
papillon
Posts: 3
Joined: Tue Apr 30, 2013 12:39 pm

Re: Loader for statically linked ELF file

Post by papillon »

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?"
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Loader for statically linked ELF file

Post by iansjack »

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.
User avatar
sortie
Member
Member
Posts: 931
Joined: Wed Mar 21, 2012 3:01 pm
Libera.chat IRC: sortie

Re: Loader for statically linked ELF file

Post by sortie »

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.
Antti
Member
Member
Posts: 923
Joined: Thu Jul 05, 2012 5:12 am
Location: Finland

Re: Loader for statically linked ELF file

Post by Antti »

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.
Post Reply