diff options
author | YunQiang Su <syq@debian.org> | 2018-02-20 18:33:05 +0100 |
---|---|---|
committer | Laurent Vivier <laurent@vivier.eu> | 2018-02-25 17:28:49 +0100 |
commit | 768fe76e92477870ab14399dbc6bb8d801621c5c (patch) | |
tree | befe6ca9718d06ae9b1e03256ea43f555a864c01 /linux-user/main.c | |
parent | 542ca4349878a2ea3818aea5c448a6db567da3ae (diff) |
linux-user: introduce functions to detect CPU type
Add a function to return ELF e_flags and use it
to select the CPU model.
Signed-off-by: YunQiang Su <syq@debian.org>
[lv: split the patch and some cleanup in get_elf_eflags()]
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20180220173307.25125-3-laurent@vivier.eu>
Diffstat (limited to 'linux-user/main.c')
-rw-r--r-- | linux-user/main.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/linux-user/main.c b/linux-user/main.c index 079b98235b..bbeb78fb89 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -4344,8 +4344,17 @@ int main(int argc, char **argv, char **envp) init_qemu_uname_release(); + execfd = qemu_getauxval(AT_EXECFD); + if (execfd == 0) { + execfd = open(filename, O_RDONLY); + if (execfd < 0) { + printf("Error while loading %s: %s\n", filename, strerror(errno)); + _exit(EXIT_FAILURE); + } + } + if (cpu_model == NULL) { - cpu_model = cpu_get_model(0); + cpu_model = cpu_get_model(get_elf_eflags(execfd)); } tcg_exec_init(0); /* NOTE: we need to init the CPU at this stage to get @@ -4438,15 +4447,6 @@ int main(int argc, char **argv, char **envp) cpu->opaque = ts; task_settid(ts); - execfd = qemu_getauxval(AT_EXECFD); - if (execfd == 0) { - execfd = open(filename, O_RDONLY); - if (execfd < 0) { - printf("Error while loading %s: %s\n", filename, strerror(errno)); - _exit(EXIT_FAILURE); - } - } - ret = loader_exec(execfd, filename, target_argv, target_environ, regs, info, &bprm); if (ret != 0) { |