Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/linux-sunxi/sunxi-tools.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernhard Nortmann <bernhard.nortmann@web.de>2016-11-10 15:12:34 +0300
committerBernhard Nortmann <bernhard.nortmann@web.de>2016-11-10 15:59:43 +0300
commit2a4af4f5f2e282849d49b4508456a4ede89b90b4 (patch)
tree69bafd705af5a463d9a8f4081fdee4f8bd20de87 /script_bin.c
parentbf735b2c47f225719f6b30630f3ab0b689fa705e (diff)
fexc: Convert version[0] header field to filesize
Vendor-provided .bin files have repeatedly demonstrated that our previous interpretation of this field as version[0] is likely wrong. Instead, it seems to represent the file size (in bytes) of the .bin file. This commit fixes both decompilation (and header checks) and generation of .bin files, where it will now store the size to this field. TODO: It's unclear whether the 'filesize' needs some specific alignment (and the .bin corresponding padding). A value of 34864 (0x8830) has already been observed, so any possible alignment is expected not to exceed 16 bytes (0x10). (Currently our .bin generator doesn't care about any specific alignment.) Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
Diffstat (limited to 'script_bin.c')
-rw-r--r--script_bin.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/script_bin.c b/script_bin.c
index 3315f67..29c2735 100644
--- a/script_bin.c
+++ b/script_bin.c
@@ -97,7 +97,7 @@ size_t script_bin_size(struct script *script,
return bin_size;
}
-int script_generate_bin(void *bin, size_t UNUSED(bin_size),
+int script_generate_bin(void *bin, size_t bin_size,
struct script *script,
size_t sections, size_t entries)
{
@@ -122,9 +122,9 @@ int script_generate_bin(void *bin, size_t UNUSED(bin_size),
(void*)data-bin);
head->sections = sections;
- head->version[0] = 0;
- head->version[1] = 1;
- head->version[2] = 2;
+ head->filesize = bin_size;
+ head->version[0] = 1;
+ head->version[1] = 2;
for (ls = list_first(&script->sections); ls;
ls = list_next(&script->sections, ls)) {
@@ -326,11 +326,10 @@ int script_decompile_bin(void *bin, size_t bin_size,
unsigned int i;
struct script_bin_head *head = bin;
- if (((head->version[0] & 0x3FFF) > SCRIPT_BIN_VERSION_LIMIT) ||
- (head->version[1] > SCRIPT_BIN_VERSION_LIMIT) ||
- (head->version[2] > SCRIPT_BIN_VERSION_LIMIT)) {
- pr_err("Malformed data: version %u.%u.%u.\n",
- head->version[0], head->version[1], head->version[2]);
+ if ((head->version[0] > SCRIPT_BIN_VERSION_LIMIT) ||
+ (head->version[1] > SCRIPT_BIN_VERSION_LIMIT)) {
+ pr_err("Malformed data: version %u.%u.\n",
+ head->version[0], head->version[1]);
return 0;
}
@@ -340,10 +339,10 @@ int script_decompile_bin(void *bin, size_t bin_size,
return 0;
}
- pr_info("%s: version: %u.%u.%u\n", filename,
- head->version[0] & 0x3FFF, head->version[1], head->version[2]);
- pr_info("%s: size: %zu (%u sections)\n", filename,
- bin_size, head->sections);
+ pr_info("%s: version: %u.%u\n", filename,
+ head->version[0], head->version[1]);
+ pr_info("%s: size: %zu (%u sections), header value: %u\n", filename,
+ bin_size, head->sections, head->filesize);
/* TODO: SANITY: compare head.sections with bin_size */
for (i=0; i < head->sections; i++) {