New targets to Binutils for H8 series

Nick Clifton nickc@redhat.com
Wed Jan 22 09:56:00 GMT 2003


Hi Venky,

> I was interested in implementing some extensions to the H8300
> simulator and was thinking of adding some code to crt0.S. I would
> like this code to be available when the code would be run under a
> simulator.

If the crt0.o file built from your crt0.S file is linked in with the
H8300 executable then it will be loaded into the simulator when it
starts up.

> I think it would be a good idea to add a target, say
> -msim, so that the code is generated for simulated target only.

Generally speaking this is a bad idea.  Simulators ought to be able to
simulate code compiled for real targets.  You should not have to
compile a program for a "simulator-only" target.


> In the context, I was actually trying to include commandline support
> to the simulator and so would have to setup the stack with the
> commandline arguments in crt0.S. I didn't think it would be a good
> idea to add the code to the default implementation, by adding the
> target, we could write any simulator specific code inside a #ifdef
> __SIMULATOR__ kind of structure, similar to the ARM implementation.

Are you saying that the default target execution environment for H8300
binaries does not have any way of obtaining its command line ?  So you
want to invent one that will work with the simulator ?  If so, then I
can understand your desire to have a "-msim" switch, but I still think
that it is a bad idea.  Instead I would suggest that you do something
similar to the mechanism used in newlib for the ARM.

In the file newlib/configure.host, for the h8300 entry, add an new
define, eg -DSIMULATOR_ARGV_SUPPORT and then test for this in crt0.S.
You still end up with a customised-for-the-simulator crt0.o file, but
these do tend to be execution environment specific, and normally a
user would use a spec file to select the correct crt0.o for their
execution environment.

Cheers
        Nick



More information about the Binutils mailing list