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; } }
On Mon, 29 Nov 2004, Gin wrote:
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?
Because we don't relocate elf addresses. The addresses in the elf have to be backed by memory.
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)) {
Possibly I'm reading this wrong but ... this test looks somewhat broken.
take a simple case. memory start 0x1000 memory end 0x2000 elf start 0x1001 elf end 0x3000
Seems like this test will indicate, incorrectly, that the elf segment will fit in physical memory and that is not the case.
ron