ao-tools/ao-stmload: Be smarter about ELF parsing. Retry open on failure.
authorKeith Packard <keithp@keithp.com>
Sat, 23 Mar 2013 09:10:38 +0000 (02:10 -0700)
committerKeith Packard <keithp@keithp.com>
Sat, 23 Mar 2013 09:10:38 +0000 (02:10 -0700)
commitdedc331433bfd51e7a615087fc94dc0aa2eedfcd
tree2682de72484ba3723a1670860d3f046c3161fa59
parent340f57df8c16c1f4b98a5249779f7a9a35e69a75
ao-tools/ao-stmload: Be smarter about ELF parsing. Retry open on failure.

Figuring out what goes where is tricky; turns out we want to pull all
of the sections that map inside any program area that is supposed to
be loaded from the file.

So, we walk the program headers, then walk all of the section headers
looking for those that suck data from the same portion of the
file. Compute where in ROM each relevant section goes and build a full
ROM image in memory using that.

This patch also adds code to close and re-open the device if the first
open failed to do what we want. Much nicer to have the computer figure
out when the open succeeded rather than having people re-run the app.

Signed-off-by: Keith Packard <keithp@keithp.com>
ao-tools/ao-stmload/ao-stmload.c