well, ive started my move away from flat binary executables to elf.
so far ive followed the specs and ive just finished.
however i realised do i have to write elf loading to a specific linker script or not.
so far i havent found the answer to this and thought id better ask before i start writing
more code.
Elf loading
Re: Elf loading
How do you mean?
For a linked program, follow program headers, relocate and zero as appropriate, then jump to the entry point.
For a shared object, do the same with section headers, but there's no entry point.
The process should be the same whether or not you compiled with a linker script. Just be careful that if you use aligned sections, the size in the file will be less that the size in memory - you need to relocate information by "filesz" and then zero any additional memory specified by "memsz - filesz" (these variables have prefixes in the ELF specification depending on whether they are from program or section headers). Also beware of any sections which take up 0 bytes in the final memory image (avoid these by checking the program header type - should be PT_LOAD IIRC).
Cheers,
Adam
For a linked program, follow program headers, relocate and zero as appropriate, then jump to the entry point.
For a shared object, do the same with section headers, but there's no entry point.
The process should be the same whether or not you compiled with a linker script. Just be careful that if you use aligned sections, the size in the file will be less that the size in memory - you need to relocate information by "filesz" and then zero any additional memory specified by "memsz - filesz" (these variables have prefixes in the ELF specification depending on whether they are from program or section headers). Also beware of any sections which take up 0 bytes in the final memory image (avoid these by checking the program header type - should be PT_LOAD IIRC).
Cheers,
Adam
Re: Elf loading
soz i was been a bit thick posting this question.
ive worked it out now.
cheers
ive worked it out now.
cheers