The supposedly-sim-independent sim/common/callback.c and syscall.c
(from sim/common/syscall.c:
/* This interface isn't intended to be specific to any particular kind
of remote (hardware, simulator, whatever). As such, support for it
(e.g. sim/common/callback.c) should *not* live in the simulator source
tree, nor should it live in the gdb source tree. K&R C must be
supported. */
)
have no idea what the endian of the target is, and still are
supposed to store multi-byte values correctly without access to
proper multibyte-value-store functions. Currently,
little-endian is assumed when storing struct stat members, which
of course is just broken. This patch introduces a member of
host_callback to hold the endianness of the target. Because of
sim-independentness those files must not include sim-config.h to
access CURRENT_TARGET_BYTE_ORDER. Oh well. I blissfully ignore
the possibility of different endian types (16-bit within 32-bit
different to 8-bit within 16-bit) but so does the rest of sim/.
Tested together with other dependent stuff using the CRIS sim.
Test-built on m32r-sim, arm-sim and frv-sim with this patch
only.
include/gdb:
* callback.h (struct host_callback_struct): New member
target_big_endian.
(cb_store_target_endian): Prototype.
sim/common:
* callback.c (default_callback): Initialize target_big_endian.
(cb_store_target_endian): Renamed from store, new first parameter
host_callback *cb, drop last parameter big_p. Take endianness
from cb.
(cb_host_to_target_stat): Change to use cb_store_target_endian.
Remove variable big_p.
* nrun.c (main): Initialize default_callback.target_big_endian.