From: Hongxu Jia Date: Fri, 7 Feb 2025 05:27:47 +0000 (+0800) Subject: script/relocate_sdk.py: check dynamic loader arch before relocating interpreter X-Git-Tag: yocto-5.2~517 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0c1f2bf3d8e31e66d28aaa81a7c1658f160bb79e;p=thirdparty%2Fopenembedded%2Fopenembedded-core-contrib.git script/relocate_sdk.py: check dynamic loader arch before relocating interpreter While multiple dynamic loader existed, in order to make executable file is interpreted by the expected dynamic loader, relocating interpreter only if the new dynamic loader and executable file have the same arch [ YOCTO #15722 ] Signed-off-by: Hongxu Jia Signed-off-by: Mathieu Dubois-Briand Signed-off-by: Richard Purdie --- diff --git a/scripts/relocate_sdk.py b/scripts/relocate_sdk.py index 8a728720bae..9e01c09cb0e 100755 --- a/scripts/relocate_sdk.py +++ b/scripts/relocate_sdk.py @@ -49,6 +49,34 @@ def get_arch(): elif ei_class == 2: return 64 +def get_dl_arch(dl_path): + try: + with open(dl_path, "r+b") as f: + e_ident =f.read(16) + except IOError: + exctype, ioex = sys.exc_info()[:2] + if ioex.errno == errno.ETXTBSY: + print("Could not open %s. File used by another process.\nPlease "\ + "make sure you exit all processes that might use any SDK "\ + "binaries." % e) + else: + print("Could not open %s: %s(%d)" % (e, ioex.strerror, ioex.errno)) + sys.exit(-1) + + ei_mag0,ei_mag1_3,ei_class,ei_data,ei_version = struct.unpack("= 64: arch = get_arch() - if arch: + if arch and arch == dl_arch: parse_elf_header() if not change_interpreter(e): errors = True