Skip to content

Commit

Permalink
Merge pull request #257 from Princess-of-Sleeping/master
Browse files Browse the repository at this point in the history
Fixed module entry problem via default or config
  • Loading branch information
Princess-of-Sleeping authored Nov 14, 2023
2 parents 9f8d1c6 + 77bdad9 commit ba02af8
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 11 deletions.
19 changes: 13 additions & 6 deletions src/vita-elf-create/sce-elf.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,10 @@ static int set_main_module_export(vita_elf_t *ve, sce_module_exports_t *export,
export->num_syms_vars = 1; // module_info for default

if (export_spec->is_image_module == 0) {
if (export_spec->start)
/*
* non export.yml module shoule be have main function.
*/
if (export_spec->start || export_spec->is_default != 0)
++export->num_syms_funcs;

if (export_spec->bootstart)
Expand Down Expand Up @@ -230,13 +233,17 @@ static int set_main_module_export(vita_elf_t *ve, sce_module_exports_t *export,
}

module_info->module_start = vita_elf_vaddr_to_host(ve, vaddr);
} else {

export->nid_table[cur_nid] = NID_MODULE_START;
export->entry_table[cur_nid] = module_info->module_start;
++cur_nid;
} else if(export_spec->is_default != 0) {
module_info->module_start = vita_elf_vaddr_to_host(ve, elf32_getehdr(ve->elf)->e_entry);
}

export->nid_table[cur_nid] = NID_MODULE_START;
export->entry_table[cur_nid] = module_info->module_start;
++cur_nid;
export->nid_table[cur_nid] = NID_MODULE_START;
export->entry_table[cur_nid] = module_info->module_start;
++cur_nid;
}

if (export_spec->bootstart) {
Elf32_Addr vaddr = 0;
Expand Down
17 changes: 13 additions & 4 deletions src/vita-elf-create/vita-elf-create.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,15 @@ void print_stubs(vita_elf_stub_t *stubs, int num_stubs)
int i;

for (i = 0; i < num_stubs; i++) {
TRACEF(VERBOSE, " 0x%06x (%s):\n", stubs[i].addr, stubs[i].symbol ? stubs[i].symbol->name : "unreferenced stub");
TRACEF(VERBOSE, " Flags : %u\n", stubs[i].library ? stubs[i].library->flags : 0);
TRACEF(VERBOSE, " Library: %u (%s)\n", stubs[i].library_nid, stubs[i].library ? stubs[i].library->name : "not found");
TRACEF(VERBOSE, " NID : %u (%s)\n", stubs[i].target_nid, stubs[i].target ? stubs[i].target->name : "not found");
// TRACEF(VERBOSE, " 0x%08X (%s):\n", stubs[i].addr, stubs[i].symbol ? stubs[i].symbol->name : "unreferenced stub");
// TRACEF(VERBOSE, " Flags : 0x%04X\n", stubs[i].library ? stubs[i].library->flags : 0);
TRACEF(
VERBOSE,
" stub=0x%08X library_nid=0x%08X (%s) target_nid=0x%08X (%s)\n",
stubs[i].addr,
stubs[i].library_nid, stubs[i].library ? stubs[i].library->name : "not found",
stubs[i].target_nid, stubs[i].target ? stubs[i].target->name : "not found"
);
}
}

Expand Down Expand Up @@ -501,6 +506,8 @@ int main(int argc, char *argv[])
exports = vita_exports_load(args.exports, args.input, 0);
if (!exports)
return EXIT_FAILURE;

TRACEF(VERBOSE, "export config loaded from file\n");
}

if ((ve = vita_elf_load(args.input, args.check_stub_count, exports)) == NULL)
Expand All @@ -523,6 +530,8 @@ int main(int argc, char *argv[])
exports->exit = args.entrypoint_funcs[2];
if (args.exports_output)
vita_elf_generate_exports(ve, exports);

TRACEF(VERBOSE, "export config loaded from default\n");
}

if (ve->fstubs_va.count) {
Expand Down
5 changes: 4 additions & 1 deletion src/vita-export-parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,7 @@ vita_export_t *read_module_exports(yaml_document *doc, uint32_t default_nid) {

vita_export_t *export = malloc(sizeof(vita_export_t));
memset(export, 0, sizeof(vita_export_t));
export->is_default = 0;

// check lhs is a scalar
if (!is_scalar(root->pairs[0]->lhs)) {
Expand Down Expand Up @@ -644,7 +645,9 @@ vita_export_t *vita_exports_loads(FILE *text, const char *elf, int verbose)
vita_export_t *vita_export_generate_default(const char *elf)
{
vita_export_t *exports = calloc(1, sizeof(vita_export_t));


exports->is_default = 1;

// set module name to elf output name
const char *fs = strrchr(elf, '/');
const char *bs = strrchr(elf, '\\');
Expand Down
1 change: 1 addition & 0 deletions src/vita-export.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ typedef struct {
} vita_library_export;

typedef struct {
int is_default;
char name[27];
uint8_t ver_major;
uint8_t ver_minor;
Expand Down

0 comments on commit ba02af8

Please sign in to comment.