On remote targets, we don't always start at the entry point. Thus,
it is safer to get to main and do the tests from that point onwards.
Can you elaborate more? Your patch looks reasonable at first sight,
but then at the same time now introduces a new requirement that it
needs to be run on the target, whereas that was not the case before.
The testcase only prints global variables. I don't suppose there
is much of a guaranty that you could print global variables without
starting the program first, but it's been generally working. So
I am curious as to why it isn't working in your case.