https://github.com/ptitSeb/box64/blob/main/src/elfs/elfparser.c#L125
elfheader_t *h = box_calloc(1, sizeof(elfheader_t));
// ...
h->numSHEntries = header.e_shnum;
// ...
if(header.e_shentsize && header.e_shnum) {
// special cases for nums
if(h->numSHEntries == 0) { // THIS BRANCH IS IMPOSSIBLE TO BE EXECUTED!!!
printf_dump(LOG_DEBUG, "Read number of Sections in 1st Section\n");
// read 1st section header and grab actual number from here
// ...
h->numSHEntries = section.sh_size;
}
}
h->numSHEntries has been stored with value of e_shnum, only when e_shnum is non-zero will the outter branch be executed, then the h->numSHEntries must be non-zero as well, then the inner branch will never be executed.
I know it
h->numSHEntries
has been stored with value ofe_shnum
, only whene_shnum
is non-zero will the outter branch be executed, then theh->numSHEntries
must be non-zero as well, then the inner branch will never be executed.