elf2nro: add support for aligned header flag

This commit is contained in:
Michael Scire 2024-10-14 12:00:11 -07:00 committed by Dave Murphy
parent e36a8251cd
commit 28bd095683

View File

@ -21,9 +21,9 @@ typedef struct {
typedef struct {
u8 Magic[4];
u32 Unk1;
u32 version;
u32 size;
u32 Unk2;
u32 flags;
NsoSegment Segments[3];
u32 bssSize;
u32 Unk3;
@ -78,6 +78,7 @@ int main(int argc, char* argv[]) {
fprintf(stderr, "--nacp=<control.nacp> Embeds control.nacp into the output file.\n");
fprintf(stderr, "--romfs=<image> Embeds RomFS into the output file.\n");
fprintf(stderr, "--romfsdir=<directory> Builds and embeds RomFS into the output file.\n");
fprintf(stderr, "--alignedheader Sets the \"AlignedHeader\" flag in the output file.\n");
return EXIT_FAILURE;
}
@ -102,11 +103,13 @@ int main(int argc, char* argv[]) {
int argi;
char* icon_path = NULL, *nacp_path = NULL, *romfs_path = NULL, *romfs_dir_path = NULL;
u32 aligned_header = 0;
for (argi=3; argi<argc; argi++) {
if (strncmp(argv[argi], "--icon=", 7)==0) icon_path = &argv[argi][7];
if (strncmp(argv[argi], "--nacp=", 7)==0) nacp_path = &argv[argi][7];
if (strncmp(argv[argi], "--romfs=", 8)==0) romfs_path = &argv[argi][8];
if (strncmp(argv[argi], "--romfsdir=", 11)==0) romfs_dir_path = &argv[argi][11];
if (strncmp(argv[argi], "--alignedheader", 15)==0) aligned_header = 1;
}
if (romfs_dir_path != NULL && romfs_path != NULL) {
@ -209,6 +212,9 @@ int main(int argc, char* argv[]) {
nro_hdr.size = file_off;
nro_hdr.version = 0;
nro_hdr.flags = (aligned_header << 0);
// TODO check retvals
for (i=0; i<3; i++)