Linux ELF 32bits loading

Programming, for all ages and all languages.
Locked
johntortugo
Posts: 6
Joined: Wed Jun 01, 2011 1:35 pm

Linux ELF 32bits loading

Post by johntortugo »

I'm writing an x86 binary interpreter.

At the moment I'm dealing with loading the executable file and shared objects. However I'm stuck with some doubts:

1) Does the dynamic linker/loader concatenate .ini sections of the main executable and shared libraries to generate just one .ini section for the process image? And for the .fini section?

2) Does it concatenate the many symbol and string table?

3) I'm lost about relocations. They happen should be made at the moment the binary is loaded or just when a procedure is called? I guess I didn't understand how the dynamic linker/loader manages the relocations.

4) Why there exist .hash and .gnu.hash sections? Why do I need 'hash' a symbol?

Can someone comment on this?
User avatar
Nessphoro
Member
Member
Posts: 308
Joined: Sat Apr 30, 2011 12:50 am

Re: Linux ELF 32bits loading

Post by Nessphoro »

RTFM and search before you ask.
johntortugo
Posts: 6
Joined: Wed Jun 01, 2011 1:35 pm

Re: Linux ELF 32bits loading

Post by johntortugo »

If you have something that contribute to an answer say it.

If not, just doesn't waste your time and mine with quite obvious things.
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

Re: Linux ELF 32bits loading

Post by bluemoon »

Indeed RTFM (Read the full! manual) is an answer.

(1) The expected behavior of program loader, including dynamic linking, is documented on the manual.
(2) String table are usually used only during loading, it's up to the program loader to handle them, however I do not see it necessary to concatenate it but just drop them after loading.
(3) It's up to the loader for how and when to resolve them. And it's possible to do lazy loading that only pull in shared object upon its used.
(4) Check the manual.
johntortugo
Posts: 6
Joined: Wed Jun 01, 2011 1:35 pm

Re: Linux ELF 32bits loading

Post by johntortugo »

User avatar
Nessphoro
Member
Member
Posts: 308
Joined: Sat Apr 30, 2011 12:50 am

Re: Linux ELF 32bits loading

Post by Nessphoro »

This forum is not a Q/A site.
We show you the door, it is up to you to go through it.
johntortugo
Posts: 6
Joined: Wed Jun 01, 2011 1:35 pm

Re: Linux ELF 32bits loading

Post by johntortugo »

Indeed it isn't a Q/A site, and this is the main reason that I was expecting a comment to start a discussion not a one line 'answer'.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Linux ELF 32bits loading

Post by Combuster »

Then you obviously asked the wrong question.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Locked