Hi,
I got quite far with adding decompression to lar (lzma'd data runs fine, nrv2b decompression seems to hang), but ran into issues that need discussion.
Currently, two files in the lar archive are parsed directly out of rom (using the find_file function which returns a pointer to there). One of them is "option_table", a 900 byte file (which compresses to 350 or so), where I could live with it staying uncompressed in image.
The other one is the payload.
My current work around, is to just define a place in memory where to decode it to and then load the ELF image from there.
This complicates ELF loading as now there is a risk that the raw ELF file and the ELF image overlap. (Right now, I just use an address that I know is beyond the ELF's range)
I propose a new API for the ELF loader that hides this issue and ensures that decompression works fine. It would be used like this: copy_elf(&archive, "normal/payload", &entrypoint, &last_address)
This function looks up "normal/payload" in the archive starting at archive, and returns success in the return value. entrypoint could then be used to jump into the image. last_address contains the last byte used by the ELF image.
The rationale for returning the entrypoint and last_address is to allow further loads, so multipart payloads can be used, which provides a cleaner and simpler way to allow modular payloads. Specifically, I'd like to see this for the grub2 support I work on, as it's very trivial to just push the modules as "payload.data" into the lar archive, load it right behind the ELF image and have grub2 find its modules at _end.
Regards, Patrick Georgi