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>
Sun, 31 Mar 2013 19:42:37 +0000 (12:42 -0700)
commitdb01557ce493c435db177fda78653697ba2afa51
tree8015caaa9b16140317f390a2b4b2aeb2c76db6e8
parent144b44e13ce3361ff59cbb555e84d542455a4e17
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