summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn-Mark Bell <jmb@netsurf-browser.org>2023-03-14 19:10:44 +0000
committerJohn-Mark Bell <jmb@netsurf-browser.org>2023-03-14 19:10:44 +0000
commitfe55b6bfda74b0398eaa141faec44df4af8f8f16 (patch)
tree43a45f51285063b268517b0905e8e206ee3c7950
parentdc839346e8a2032d0fe318b5c098af8e6e0cd76e (diff)
downloadmakerun-fe55b6bfda74b0398eaa141faec44df4af8f8f16.tar.gz
makerun-fe55b6bfda74b0398eaa141faec44df4af8f8f16.tar.bz2
Fix squeezed relocateable image support
-rw-r--r--makerun.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/makerun.c b/makerun.c
index 48b1d1e..435e63a 100644
--- a/makerun.c
+++ b/makerun.c
@@ -113,9 +113,17 @@ int main(int argc, char **argv)
return 1;
}
+ /* Squeeze always processes pairs of words at a time,
+ * so the declared decompressed size will always be
+ * rounded up to an 8-byte boundary. We will need to
+ * adjust expected_size to account for this but, if
+ * the image is also relocateable, the file size will
+ * be modified instead as a result of discarding the
+ * relocation code and tables from the end of the
+ * image. Therefore, we'll defer the expected_size
+ * adjustment until later.
+ */
file_size = sizeof(header) + (size_t) sqzhdr.decsize;
- /* Round expected size up to an even number of words */
- expected_size = (expected_size + 7) & ~7;
}
fclose(f);
@@ -144,6 +152,11 @@ int main(int argc, char **argv)
file_size -= reloc_size;
/* Add relocation workspace on to reloc size */
reloc_size += header.wkspace;
+ } else if ((header.decompress >> 24) == 0xEB) {
+ /* Image is compressed, but not relocateable */
+ /* Round expected size up to an even number of words
+ * (see above for details) */
+ expected_size = (expected_size + 7) & ~7;
}
if (file_size != expected_size) {