aboutsummaryrefslogtreecommitdiff
path: root/sim/m4
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2021-06-15 19:51:52 -0400
committerMike Frysinger <vapier@gentoo.org>2021-06-17 23:20:13 -0400
commitf9a4d54332f9e1f75701ba43249a03cc631ec736 (patch)
tree2dd0b32c633005ac4378a2282d9726885e09a7b5 /sim/m4
parent4470708442cef1c818c4322f975d9017307f0243 (diff)
downloadgdb-f9a4d54332f9e1f75701ba43249a03cc631ec736.zip
gdb-f9a4d54332f9e1f75701ba43249a03cc631ec736.tar.gz
gdb-f9a4d54332f9e1f75701ba43249a03cc631ec736.tar.bz2
sim: overhaul & unify endian settings management
The m4 macro has 2 args: the "wire" settings (which represents the hardwired port behavior), and the default settings (which are used if nothing else is specified). If none are specified, the arch is expected to support both, and the value will be probed based on the user runtime options or the input program. Only two arches today set the default value (bpf & mips). We can probably let this go as it only shows up in one scenario: the sim is invoked, but with no inputs, and no user endian selection. This means bpf will not behave like the other arches: an error is shown and forces the user to make a choice. If an input program is used though, we'll still switch the default to that. This allows us to remove the WITH_DEFAULT_TARGET_BYTE_ORDER setting. For the ports that set a "wire" endian, move it to the runtime init of the respective sim_open calls. This allows us to change the WITH_TARGET_BYTE_ORDER to purely a user-selected configure setting if they want to force a specific endianness. With all the endian logic moved to runtime selection, we can move the configure call up to the common dir so we only process it once across all ports. The ppc arch was picking the wire endian based on the target used, but since we weren't doing that for other biendian arches, we can let this go too. We'll rely on the input selecting the endian, or make the user decide.
Diffstat (limited to 'sim/m4')
-rw-r--r--sim/m4/sim_ac_option_endian.m455
-rw-r--r--sim/m4/sim_ac_output.m42
2 files changed, 12 insertions, 45 deletions
diff --git a/sim/m4/sim_ac_option_endian.m4 b/sim/m4/sim_ac_option_endian.m4
index e5a5b61..01467a0 100644
--- a/sim/m4/sim_ac_option_endian.m4
+++ b/sim/m4/sim_ac_option_endian.m4
@@ -15,51 +15,20 @@ dnl along with this program. If not, see <http://www.gnu.org/licenses/>.
dnl
dnl --enable-sim-endian={yes,no,big,little} is for simulators
dnl that support both big and little endian targets.
-dnl arg[1] is hardwired target endianness.
-dnl arg[2] is default target endianness.
AC_DEFUN([SIM_AC_OPTION_ENDIAN],
-[
-wire_endian="[$1]"
-default_endian="[$2]"
+[dnl
+AC_MSG_CHECKING([whether to force sim endianness])
+sim_endian=
AC_ARG_ENABLE(sim-endian,
[AS_HELP_STRING([--enable-sim-endian=endian],
[Specify target byte endian orientation])],
[case "${enableval}" in
- b*|B*) sim_endian="-DWITH_TARGET_BYTE_ORDER=BFD_ENDIAN_BIG";;
- l*|L*) sim_endian="-DWITH_TARGET_BYTE_ORDER=BFD_ENDIAN_LITTLE";;
- yes) if test x"$wire_endian" != x; then
- sim_endian="-DWITH_TARGET_BYTE_ORDER=BFD_ENDIAN_${wire_endian}"
- else
- if test x"$default_endian" != x; then
- sim_endian="-DWITH_TARGET_BYTE_ORDER=BFD_ENDIAN_${default_endian}"
- else
- echo "No hard-wired endian for target $target" 1>&6
- sim_endian="-DWITH_TARGET_BYTE_ORDER=BFD_ENDIAN_UNKNOWN"
- fi
- fi;;
- no) if test x"$default_endian" != x; then
- sim_endian="-DWITH_DEFAULT_TARGET_BYTE_ORDER=BFD_ENDIAN_${default_endian}"
- else
- if test x"$wire_endian" != x; then
- sim_endian="-DWITH_DEFAULT_TARGET_BYTE_ORDER=BFD_ENDIAN_${wire_endian}"
- else
- echo "No default endian for target $target" 1>&6
- sim_endian="-DWITH_DEFAULT_TARGET_BYTE_ORDER=BFD_ENDIAN_UNKNOWN"
- fi
- fi;;
- *) AC_MSG_ERROR("Unknown value $enableval for --enable-sim-endian"); sim_endian="";;
-esac
-if test x"$silent" != x"yes" && test x"$sim_endian" != x""; then
- echo "Setting endian flags = $sim_endian" 6>&1
-fi],
-[if test x"$default_endian" != x; then
- sim_endian="-DWITH_DEFAULT_TARGET_BYTE_ORDER=BFD_ENDIAN_${default_endian}"
-else
- if test x"$wire_endian" != x; then
- sim_endian="-DWITH_TARGET_BYTE_ORDER=BFD_ENDIAN_${wire_endian}"
- else
- sim_endian=
- fi
-fi])dnl
-])
-AC_SUBST(sim_endian)
+ b*|B*) sim_endian="BFD_ENDIAN_BIG";;
+ l*|L*) sim_endian="BFD_ENDIAN_LITTLE";;
+ yes | no) ;;
+ *) AC_MSG_ERROR("Unknown value $enableval for --enable-sim-endian");;
+esac])dnl
+AC_DEFINE_UNQUOTED([WITH_TARGET_BYTE_ORDER],
+ [${sim_endian:-BFD_ENDIAN_UNKNOWN}], [Sim endian settings])
+AC_MSG_RESULT([${sim_alignment:-no}])
+])dnl
diff --git a/sim/m4/sim_ac_output.m4 b/sim/m4/sim_ac_output.m4
index b18f254..db6c3ff 100644
--- a/sim/m4/sim_ac_output.m4
+++ b/sim/m4/sim_ac_output.m4
@@ -48,9 +48,7 @@ AC_CONFIG_COMMANDS([stamp-h], [echo > stamp-h])
dnl These are unfortunate. They are conditionally called by other sim macros
dnl but always used by common/Make-common.in. So we have to subst here even
dnl when the rest of the code is in the respective macros.
-AC_SUBST(sim_alignment)
AC_SUBST(sim_bitsize)
-AC_SUBST(sim_endian)
AC_SUBST(sim_float)
AC_SUBST(sim_scache)
AC_SUBST(sim_default_model)