I think it's because "Hello world!\n" has 13 characters. The source
specifies main as having an "int" return type, but it doesn't actually have
a return statement in it. If you disassemble the binary and look at main,
the function just pops the stack frame off and returns immediately after
the printf, leaving whatever value laying around that printf returned.
printf is defined to return the number of characters printed, hence main
looks like it's returning 13 by accident.

Gabe

On Thu, Sep 21, 2017 at 3:26 PM, Jason Lowe-Power <[email protected]>
wrote:

> Hi all,
>
> I'm working on getting the new testing infrastructure out and ran into an
> "interesting" problem. Right now, gem5's return code is the same as the
> return code of the application it is executing (in SE mode). Strangely, the
> 'hello' binary for ARM has a return code of 13. I verified this with a
> fresh binary on qemu as well. Any idea why the return code isn't 0?
>
> Also, does anyone have an objection to changing the default behavior to
> *print* the return code if it is not 0 and always have gem5 exit with 0
> regardless of the return code of the simulated binary?
>
> Thanks,
> Jason
> _______________________________________________
> gem5-dev mailing list
> [email protected]
> http://m5sim.org/mailman/listinfo/gem5-dev
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to