MCPcopy Create free account
hub / github.com/BlitterStudio/amiberry / loadelffile

Function loadelffile

src/debugmem.cpp:2488–3030  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2486};
2487
2488static uae_u8 *loadelffile(uae_u8 *file, int filelen, uae_u8 *dbgfile, int debugfilelen, uae_u32 seglist, int segmentid, int *outsizep, uae_u32 *startp, uae_u32 *parentidp, int mode)
2489{
2490 uae_u8 *outp = NULL;
2491 uae_u8 *outptr = NULL;
2492 int outsize;
2493 bool relocate = false;
2494 uae_u32 relocate_base = 0;
2495
2496 struct elfheader *eh = (struct elfheader*)file;
2497 uae_u8 *p = file + sizeof(struct elfheader);
2498
2499 if (mode != ELFMODE_NORMAL)
2500 relocate = true;
2501
2502 wswp(&eh->type);
2503 wswp(&eh->machine);
2504 wswp(&eh->ehsize);
2505 wswp(&eh->phentsize);
2506 wswp(&eh->phnum);
2507 wswp(&eh->shentsize);
2508 wswp(&eh->shnum);
2509 wswp(&eh->shstrndx);
2510 lswp(&eh->version);
2511 lswp(&eh->flags);
2512 lswp(&eh->entry);
2513 lswp(&eh->phoff);
2514 lswp(&eh->shoff);
2515
2516 uae_u32 shnum = eh->shnum;
2517 if (shnum == 0) {
2518 if (eh->shoff == 0)
2519 return NULL;
2520 struct sheader *sh = (struct sheader*)p;
2521 shnum = sh->size;
2522 if (shnum == 0)
2523 return NULL;
2524 p += sizeof(struct sheader);
2525 }
2526
2527 uae_u8 *strtab = NULL, *strtabsym = NULL;
2528 struct sheader *symtab_shndx = NULL, *linesheader = NULL;
2529 struct debuglineheader lineheader;
2530 struct symbol *symtab = NULL;
2531 uae_u8 *debuginfo = NULL;
2532 uae_u8 *debugstr = NULL;
2533 uae_u8 *debugabbrev = NULL;
2534 int debuginfo_size;
2535 int debugstr_size;
2536 int debugabbrev_size;
2537 int symtab_num = 0;
2538 bool debuglink = false;
2539
2540 for (int i = 0; i < shnum; i++) {
2541 struct sheader *shp = (struct sheader*)(file + i * sizeof(sheader) + eh->shoff);
2542 struct sheader sh;
2543 swap_header(&sh, shp);
2544 if (sh.type == SHT_STRTAB) {
2545 if (!strtab && i != eh->shstrndx) {

Callers 3

debugmem_relocFunction · 0.85
debugmem_addsegsFunction · 0.85
read_executable_romFunction · 0.85

Calls 15

wswpFunction · 0.85
lswpFunction · 0.85
swap_headerFunction · 0.85
swap_lineheaderFunction · 0.85
auFunction · 0.85
debugmem_allocateFunction · 0.85
getrombaseFunction · 0.85
swap_symbolFunction · 0.85
addsimplesymbolFunction · 0.85
get_longFunction · 0.85
loadelfFunction · 0.85
swap_relFunction · 0.85

Tested by

no test coverage detected