Febin Sunny
Febin Sunny

Reputation: 311

How does Gem5 accept and decode executables from user?

Eg:

/home/gem5/build/X86/gem5.opt --debug-flags=TLB,Cache /home/gem5/configs/example/se.py --cpu-type=DerivO3CPU --caches --mem-type=SimpleMemory -I 10000 -c out --options="1 in_16.txt out.txt" >> test2.txt

The bold part in the SE CLI for Gem5 shows my input to it. How exactly does Gem5 process this and obtain the instructions to be simulated? Which files should I be looking into for this? As far as I know, no tutorials mention this.

Upvotes: 3

Views: 431

Answers (1)

Ciro Santilli
Ciro Santilli

Reputation: 4073

out is a regular ELF userland executable, e.g. a C hello world, just like the ones you would run on your Linux host.

Usage of dynamically linked executable is described at: How to run a dynamically linked executable syscall emulation mode se.py in gem5? so generally statically linking is easier.

gem5 parses the ELF format, places memory into the right locations, puts the PC in the right location, and kicks off simulation, just like the exec syscall of the Linux kernel would.

Several runnable examples are available here.

Upvotes: 1

Related Questions