elf2kip: allow specifying whether to use secure memory or not

This commit is contained in:
Michael Scire 2019-12-10 04:06:56 -08:00
parent 026ed556df
commit 1e870f7d55

View File

@ -132,10 +132,11 @@ int cJSON_GetBooleanOptional(const cJSON *obj, const char *field, int *out) {
fprintf(stderr, "Unknown boolean value in %s.\n", field);
return 0;
}
return 1;
} else {
*out = 0;
return 0;
}
return 1;
}
int cJSON_GetU64(const cJSON *obj, const char *field, u64 *out) {
@ -219,6 +220,17 @@ int ParseKipConfiguration(const char *json, KipHeader *kip_hdr) {
goto PARSE_CAPS_END;
}
/* Parse use secure memory. */
/* This field is optional, and defaults to true (set before this function is called). */
int use_secure_memory = 1;
if (cJSON_GetBooleanOptional(npdm_json, "use_secure_memory", &use_secure_memory)) {
if (use_secure_memory) {
kip_hdr->Flags |= 0x20;
} else {
kip_hdr->Flags &= ~0x20;
}
}
/* Parse main_thread_stack_size. */
u64 stack_size = 0;
if (!cJSON_GetU64(npdm_json, "main_thread_stack_size", &stack_size)) {