With load_elf() API, if input parameter translate_fn is set, loading
address is converted to physical address. It should be the same for entry
address, since MMU is disabled when system power on, the first instruction
of PC should be physical address.

Signed-off-by: Bibo Mao <maob...@loongson.cn>
---
 include/hw/elf_ops.h.inc | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/include/hw/elf_ops.h.inc b/include/hw/elf_ops.h.inc
index 9c35d1b9da..37ce7845a9 100644
--- a/include/hw/elf_ops.h.inc
+++ b/include/hw/elf_ops.h.inc
@@ -388,7 +388,11 @@ static ssize_t glue(load_elf, SZ)(const char *name, int fd,
         *pflags = ehdr.e_flags;
     }
     if (pentry) {
-        *pentry = ehdr.e_entry;
+        if (translate_fn) {
+            *pentry = translate_fn(translate_opaque, ehdr.e_entry);
+        } else {
+            *pentry = ehdr.e_entry;
+        }
     }
 
     glue(load_symbols, SZ)(&ehdr, fd, must_swab, clear_lsb, sym_cb);

base-commit: db7aa99ef894e88fc5eedf02ca2579b8c344b2ec
-- 
2.39.3


Reply via email to