ELF Questions
Posted: Sat May 08, 2021 6:55 am
I am working on the program loading mechanics for my OS and moving from a custom header to an ELF header. Currently the OS handles static executables only and so I am implementing ELF with a program Header but no sections and no Section Header Table (which is only really needed for dynamic linking). Though this allows me to load an executable image and works successfully there are some other things I am wanting to achieve and wonder if others can advise me how (for example) these sorts of things are achieved in Linux
However, without sections it seems difficult to identify the specific functions of particular segments. At present I am planning to use the operating system specific range of values for p_type to identify segment type to enable the program loader to do these tasks (which are done in my existing loader):
(1) Load code and some read-only data relative to the cs selector and other data (including a heap and stack null initialised area) relative to the other (identical) selectors. This enables further instances of the program to share the same code area but with different (write) data areas.
(2) Preset the stack pointer before entering the program. Maybe that should be a program responsibility but it seems a useful service to provide and would also enable debuggers to alert on detecting some stack problems (ie overflow).
(3) Enable my debugger to independently load the symbol data from the file image and orientate itself to the program structure (eg matching symbolic names relative to cs or ds/ss as appropriate)
I think my flag method will work quite satisfactorily but I feel uneasy in using custom flags for what looks like a common need. Can anyone advise me how (for example) Linux tackles these questions (or indeed other operating systems)? .
However, without sections it seems difficult to identify the specific functions of particular segments. At present I am planning to use the operating system specific range of values for p_type to identify segment type to enable the program loader to do these tasks (which are done in my existing loader):
(1) Load code and some read-only data relative to the cs selector and other data (including a heap and stack null initialised area) relative to the other (identical) selectors. This enables further instances of the program to share the same code area but with different (write) data areas.
(2) Preset the stack pointer before entering the program. Maybe that should be a program responsibility but it seems a useful service to provide and would also enable debuggers to alert on detecting some stack problems (ie overflow).
(3) Enable my debugger to independently load the symbol data from the file image and orientate itself to the program structure (eg matching symbolic names relative to cs or ds/ss as appropriate)
I think my flag method will work quite satisfactorily but I feel uneasy in using custom flags for what looks like a common need. Can anyone advise me how (for example) Linux tackles these questions (or indeed other operating systems)? .