So... we got one application to load. Does it work on other applications?
No, it does not. Very well then, we have some more work to do.
But first, I want to go over some code, criticize it, and then improve it.
Let's look at our segment loading code, for example. It's in elk/src/process.rs
,
in the load_object
function:
We've seen earlier that each segment of the executable that's mapped in memory
has a .filesz
and a .memsz
.
Every segment has equal file size and mem size, except for the R+W segment,
where the mem size is larger (by 0x28 bytes).
And yet, the mapping we're creating is for the entire mem size. So what's in
the extra bytes??