Skip to content
Snippets Groups Projects
Commit a93934fe authored by Jonas Maebe's avatar Jonas Maebe Committed by Riku Voipio
Browse files

elf: take phdr offset into account when calculating the program load address


The first program header does not necessarily start at offset 0. This change
corresponds to what the Linux kernel does in load_elf_binary().

Signed-off-by: default avatarJonas Maebe <jonas.maebe@elis.ugent.be>
Signed-off-by: default avatarRiku Voipio <riku.voipio@linaro.org>
parent 686581ad
No related branches found
No related tags found
No related merge requests found
......@@ -1820,7 +1820,7 @@ static void load_elf_image(const char *image_name, int image_fd,
loaddr = -1, hiaddr = 0;
for (i = 0; i < ehdr->e_phnum; ++i) {
if (phdr[i].p_type == PT_LOAD) {
abi_ulong a = phdr[i].p_vaddr;
abi_ulong a = phdr[i].p_vaddr - phdr[i].p_offset;
if (a < loaddr) {
loaddr = a;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment