diff options
Diffstat (limited to 'morphlib/util.py')
-rw-r--r-- | morphlib/util.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/morphlib/util.py b/morphlib/util.py index 9d90fdf3..904dc355 100644 --- a/morphlib/util.py +++ b/morphlib/util.py @@ -19,6 +19,7 @@ import pipes import re import subprocess import textwrap +import sys import fs.osfs @@ -450,6 +451,13 @@ def has_hardware_fp(): # pragma: no cover output = subprocess.check_output(['readelf', '-A', '/proc/self/exe']) return 'Tag_ABI_VFP_args: VFP registers' in output +def determine_endianness(): # pragma: no cover + ''' + This function returns whether the host is running + in big or little endian. This is needed for MIPS. + ''' + + return sys.byteorder def get_host_architecture(): # pragma: no cover '''Get the canonical Morph name for the host's architecture.''' @@ -468,6 +476,8 @@ def get_host_architecture(): # pragma: no cover 'armv8b': 'armv8b', 'aarch64': 'armv8l64', 'aarch64_be': 'armv8b64', + 'mips': 'mips32', + 'mips64': 'mips64', 'ppc64': 'ppc64' } @@ -476,6 +486,11 @@ def get_host_architecture(): # pragma: no cover if machine == 'armv7l' and has_hardware_fp(): return 'armv7lhf' + elif machine in ('mips', 'mips64'): + if determine_endianness() == 'big': + return table[machine]+'b' + else: + return table[machine]+'l' return table[machine] |