On 27 Dec 2022 20:35, Dragan Mladjenovic wrote: > On 25-Dec-22 01:26, Mike Frysinger wrote: > > On 02 Feb 2022 11:17, Dragan Mladjenovic wrote: > >> --- a/sim/mips/configure.ac > >> +++ b/sim/mips/configure.ac > >> @@ -216,6 +227,7 @@ if test ${sim_gen} = MULTI; then > >> #include "sim-main.h" > >> #include "multi-include.h" > >> #include "elf-bfd.h" > >> +#include "elfxx-mips.h" > >> #include "elf/mips.h" > >> > >> #define SD sd > >> @@ -235,7 +247,11 @@ sim_engine_run (SIM_DESC sd, > >> & EF_MIPS_ARCH_ASE_MICROMIPS) > >> mach = bfd_mach_mips_micromips; > >> else > >> - mach = STATE_ARCHITECTURE (SD)->mach; > >> + { > >> + mach = _bfd_elf_mips_mach (elf_elfheader (STATE_PROG_BFD (sd))->e_flags); > >> + if (!mach) > >> + mach = STATE_ARCHITECTURE (SD)->mach; > >> + } > > > > why do you need this logic in the main engine run routine ? why isn't the > > STATE_ARCHITECTURE value already set to the correct value ? if it isn't set > > correctly all the time, this can lead to incorrect behavior elsewhere when > > code checks it. > > > > when the sim is opened, the bfd_mach is either explicitly passed in (which > > gdb does), or initialized with a call to the bfd library APIs. see the > > sim/common/sim-utils.c:sim_analyze_program code. > > Sorry but the exact reason for doing so eludes me. It is done on > internal jump for gdb 8 to gdb 10, permissibly to allow running > binary even whet set arch forces older mips isa, but I see little > use of that outside of testsuite maybe. i'd argue that if you load a binary for one ISA, then force the runtime to use a different one, and the result crashes, then the sim is WAI. it should behave as real hardware does, and if you load a binary that needs a newer ISA than a CPU provides, it won't work. do you know if there's a testsuite, sim or gdb, that exercises this ? -mike