I know it’s probably been a while since you look into the elfboot code.

 

In the elfboot.c

When it tries to build the ELF segment list, it checks if the segment address is valid by walking through the table of valid memory ranges. What is the reason to do this?  Below is the code, the “if ” statement seems only guarantee that the new addresses INTERSECT with the valid memory range, not fully contained.  

 

 

 

for(i = 0; i < mem_entries; i++) {

                uint64_t mstart, mend;

                uint32_t mtype;

                mtype = mem->map[i].type;

                mstart = mem->map[i].start;

                mend = mstart + mem->map[i].size;

                if ((mtype == LB_MEM_RAM) && (start < mend) && (end > mstart)) {

                        break;

                }

        }