Skip to content

Commit 07835aa

Browse files
SciresMfincs
authored andcommitted
elf2kip: add support for 12.0.0 immortal process flag
1 parent f85a558 commit 07835aa

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

src/elf2kip.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,17 @@ int ParseKipConfiguration(const char *json, KipHeader *kip_hdr) {
231231
}
232232
}
233233

234+
/* Parse immortality. */
235+
/* This field is optional, and defaults to true (set before this function is called). */
236+
int immortal = 1;
237+
if (cJSON_GetBooleanOptional(npdm_json, "immortal", &immortal)) {
238+
if (immortal) {
239+
kip_hdr->Flags |= 0x40;
240+
} else {
241+
kip_hdr->Flags &= ~0x40;
242+
}
243+
}
244+
234245
/* Parse main_thread_stack_size. */
235246
u64 stack_size = 0;
236247
if (!cJSON_GetU64(npdm_json, "main_thread_stack_size", &stack_size)) {
@@ -553,7 +564,7 @@ int main(int argc, char* argv[]) {
553564

554565
KipHeader kip_hdr = {0};
555566
memcpy(kip_hdr.Magic, "KIP1", 4);
556-
kip_hdr.Flags = 0x3F;
567+
kip_hdr.Flags = 0x7F;
557568

558569
if (sizeof(KipHeader) != 0x100) {
559570
fprintf(stderr, "Bad compile environment!\n");

0 commit comments

Comments
 (0)