diff options
author | ian <ian@FreeBSD.org> | 2013-03-09 23:05:19 +0000 |
---|---|---|
committer | ian <ian@FreeBSD.org> | 2013-03-09 23:05:19 +0000 |
commit | 7323532fa2b36e007878775246560b54ff5ddeca (patch) | |
tree | 26e3994542e0ed3cf8f45affe17174427c082458 /sys/boot | |
parent | 854d4fd5e6dfa9d19ae720ae7b80c35e6f03dce7 (diff) | |
download | FreeBSD-src-7323532fa2b36e007878775246560b54ff5ddeca.zip FreeBSD-src-7323532fa2b36e007878775246560b54ff5ddeca.tar.gz |
Since ubldr doesn't necessarily load a kernel at the physical address in the
elf headers, mask out the high nibble of that address. This effectly makes
the entry point the offset from the load address, and it gets adjusted for
the actual load address before jumping to it.
Masking the high nibble makes assumptions about memory layout that are true
for all the arm platforms we support right now, but it makes me uneasy.
This needs to be revisited.
Diffstat (limited to 'sys/boot')
-rw-r--r-- | sys/boot/common/load_elf.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/sys/boot/common/load_elf.c b/sys/boot/common/load_elf.c index 3a4152e..4a1896e 100644 --- a/sys/boot/common/load_elf.c +++ b/sys/boot/common/load_elf.c @@ -297,15 +297,16 @@ __elfN(loadimage)(struct preloaded_file *fp, elf_file_t ef, u_int64_t off) * the MI code below uses the p_vaddr fields with an offset added for * loading (doing so is arguably wrong). To make loading work, we need * an offset that represents the difference between physical and virtual - * addressing. ARM kernels are always linked at 0xC0000000. Depending + * addressing. ARM kernels are always linked at 0xCnnnnnnn. Depending * on the headers, the offset value passed in may be physical or virtual * (because it typically comes from e_entry), but we always replace * whatever is passed in with the va<->pa offset. On the other hand, we - * only adjust the entry point if it's a virtual address to begin with. + * always remove the high-order part of the entry address whether it's + * physical or virtual, because it will be adjusted later for the actual + * physical entry point based on where the image gets loaded. */ - off = -0xc0000000u; - if ((ehdr->e_entry & 0xc0000000u) == 0xc0000000u) - ehdr->e_entry += off; + off = -0xc0000000; + ehdr->e_entry &= ~0xf0000000; #ifdef ELF_VERBOSE printf("ehdr->e_entry 0x%08x, va<->pa off %llx\n", ehdr->e_entry, off); #endif |