From 477adee7b707587fa04a0ad09effd23675e3e2ef Mon Sep 17 00:00:00 2001 From: Matthias Bernt Date: Fri, 21 Feb 2025 10:35:40 +0100 Subject: [PATCH 1/2] more fixes for lief 0.15 followup on https://github.com/conda/conda-build/pull/5595/ fixes https://github.com/conda/conda-build/issues/5626 in lief 0.15 not only the classes were renamed but also enum members: https://github.com/lief-project/LIEF/commit/cddd8dd0768334f341242c8f61e0819e8fc4f885#diff-88d5303887e96766711bd8ff242b652c29bc0ee0fa3ef8004bfc797c9a23040b latest version here: https://github.com/lief-project/LIEF/blob/0e5db4ea906b3252653dd90c627f8462d7e39ba4/api/python/lief/ELF/__init__.pyi#L2037 --- conda_build/os_utils/liefldd.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/conda_build/os_utils/liefldd.py b/conda_build/os_utils/liefldd.py index c1938590e3..b036df5012 100644 --- a/conda_build/os_utils/liefldd.py +++ b/conda_build/os_utils/liefldd.py @@ -50,10 +50,14 @@ # Fallback for lief<0.15. LOAD_COMMAND_TYPES = lief.MachO.LOAD_COMMAND_TYPES try: - ELF_CLASS = lief.ELF.Header.CLASS + ELF64 = lief.ELF.Header.CLASS.ELF64 + ELF32 = lief.ELF.Header.CLASS.ELF32 except AttributeError: # Fallback for lief<0.15. - ELF_CLASS = lief.ELF.ELF_CLASS + ELF64 = lief.ELF.ELF64 + ELF32 = lief.ELF.ELF_CLASS.CLASS32 + + except ImportError: have_lief = False @@ -203,7 +207,7 @@ def get_rpathy_thing_raw_partial(file, elf_attribute, elf_dyn_tag): binary_format = binary.format if binary_format == EXE_FORMATS.ELF: binary_type = binary.type - if binary_type == ELF_CLASS.CLASS32 or binary_type == ELF_CLASS.CLASS64: + if binary_type == ELF32 or binary_type == ELF64: rpaths = _get_elf_rpathy_thing(binary, elf_attribute, elf_dyn_tag) elif ( binary_format == EXE_FORMATS.MACHO @@ -257,7 +261,7 @@ def set_rpath(old_matching, new_rpath, file): if not binary: return if binary.format == EXE_FORMATS.ELF and ( - binary.type == ELF_CLASS.CLASS32 or binary.type == ELF_CLASS.CLASS64 + binary.type == ELF32 or binary.type == ELF64 ): if _set_elf_rpathy_thing( binary, old_matching, new_rpath, set_rpath=True, set_runpath=False @@ -345,7 +349,7 @@ def from_os_varnames(binary_format, binary_type, input_): .replace("@rpath", "$RPATH") ) elif binary_format == EXE_FORMATS.ELF: - if binary_type == ELF_CLASS.CLASS64: + if binary_type == ELF64: libdir = "/lib64" else: libdir = "/lib" @@ -371,7 +375,7 @@ def get_uniqueness_key(filename, file): elif binary.format == EXE_FORMATS.MACHO: return filename elif binary.format == EXE_FORMATS.ELF and ( # noqa - binary.type == ELF_CLASS.CLASS32 or binary.type == ELF_CLASS.CLASS64 + binary.type == ELF32 or binary.type == ELF64 ): dynamic_entries = binary.dynamic_entries result = [e.name for e in dynamic_entries if e.tag == ELF_DYNAMIC_TAGS.SONAME] @@ -488,7 +492,7 @@ def inspect_linkages_lief( if not binary: default_paths = [] elif binary.format == EXE_FORMATS.ELF: - if binary.type == ELF_CLASS.CLASS64: + if binary.type == ELF64: default_paths = [ "$SYSROOT/lib64", "$SYSROOT/usr/lib64", From 455aee43b97e6f0f848a180c897f618f07e28f0d Mon Sep 17 00:00:00 2001 From: M Bernt Date: Fri, 21 Feb 2025 11:24:58 +0100 Subject: [PATCH 2/2] Fix copy paste error --- conda_build/os_utils/liefldd.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conda_build/os_utils/liefldd.py b/conda_build/os_utils/liefldd.py index b036df5012..fc17a270ef 100644 --- a/conda_build/os_utils/liefldd.py +++ b/conda_build/os_utils/liefldd.py @@ -54,7 +54,7 @@ ELF32 = lief.ELF.Header.CLASS.ELF32 except AttributeError: # Fallback for lief<0.15. - ELF64 = lief.ELF.ELF64 + ELF64 = lief.ELF.ELF_CLASS.CLASS64 ELF32 = lief.ELF.ELF_CLASS.CLASS32