On 3/20/10, Mark Cave-Ayland mark.cave-ayland@siriusit.co.uk wrote:
Hi all,
I've spent some time today looking at the ELF loader code for each different architecture, and with a bit of work I believe that I can modify arch/sparc64/elfload.c so that it can be used across all architectures.
Looking closer at the source, it can be seen that are actually two sets of ELF routines: one in arch/*/elfload.c, and another set in libopenbios/elfload.c which only appears to be used by the PPC code. I've already manage to refactor the SPARC64 code so it reuses (and also exposes) the same API for use with the PPC code, except with one exception: file handles.
In arch/*/elfload.c, the preferred method for using handles is to make use of the included loadfs.c methods which works with an implicit file handle (i.e. the file handle isn't passed into any of the functions). In contrast, the PPC code directly calls the *_io() API (see find_elf()/elf_readhdrs()) and so requires an explicit file handle to be passed into each function.
I'm currently leaning towards the PPC method, since loadfs.c seems to be such a lightweight wrapper that it hardly seems worth keeping. Can anyone see a reason to keep this before I go and rip it out?
I think ideally the internal APIs should be identical to POSIX ones (open, lseek, read/write, close). So this would be a step into right direction.