2017-06-27 16:01:03 +02:00
|
|
|
#!/usr/bin/env python
|
|
|
|
import os
|
2021-01-03 17:52:44 +01:00
|
|
|
import sys
|
|
|
|
import platform
|
2019-08-22 22:05:53 +01:00
|
|
|
import re
|
|
|
|
import subprocess
|
2017-06-27 16:01:03 +02:00
|
|
|
|
|
|
|
def get_sample(filename):
|
2017-07-18 13:43:20 +02:00
|
|
|
fullpath = os.path.join("@LIEF_SAMPLES_DIRECTORY@", filename)
|
2017-06-27 16:01:03 +02:00
|
|
|
|
|
|
|
assert os.path.exists(fullpath)
|
|
|
|
assert os.path.isfile(fullpath)
|
|
|
|
|
|
|
|
return fullpath
|
|
|
|
|
2019-08-22 22:05:53 +01:00
|
|
|
def get_compiler():
|
|
|
|
compiler = os.getenv("CC", "/usr/bin/cc")
|
|
|
|
if not os.path.exists(compiler):
|
|
|
|
raise RuntimeError("Unable to find a compiler")
|
|
|
|
return compiler
|
|
|
|
|
2021-01-03 17:52:44 +01:00
|
|
|
def is_linux():
|
|
|
|
return sys.platform.startswith("linux")
|
|
|
|
|
|
|
|
def is_x86_64():
|
|
|
|
machine = platform.machine().lower()
|
|
|
|
return machine in ("x86_64", "amd64")
|
|
|
|
|
|
|
|
def is_aarch64():
|
|
|
|
return platform.machine() == "aarch64"
|
2019-08-22 22:05:53 +01:00
|
|
|
|
|
|
|
def has_recent_glibc():
|
2020-11-04 15:42:14 +01:00
|
|
|
"""Check if we have at least GLIBC 2.17 (2012)"""
|
2019-08-22 22:05:53 +01:00
|
|
|
try:
|
|
|
|
out = subprocess.check_output(["ldd", "--version"]).decode("ascii")
|
|
|
|
version_str = re.search(" (\d\.\d+)\n", out).group(1)
|
|
|
|
major, minor = version_str.split(".")
|
|
|
|
except (OSError, AttributeError):
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
if int(major) == 2 and int(minor) >= 17:
|
|
|
|
return True
|
|
|
|
|
|
|
|
return False
|