Skip to content

Commit 983e0a2

Browse files
committed
contrib: use LIEF 0.12.0 for symbol and security checks
1 parent 3297f5c commit 983e0a2

File tree

3 files changed

+9
-21
lines changed

3 files changed

+9
-21
lines changed

contrib/devtools/security-check.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@
1212

1313
import lief #type:ignore
1414

15-
# temporary constant, to be replaced with lief.ELF.ARCH.RISCV
16-
# https://github.com/lief-project/LIEF/pull/562
17-
LIEF_ELF_ARCH_RISCV = lief.ELF.ARCH(243)
18-
1915
def check_ELF_RELRO(binary) -> bool:
2016
'''
2117
Check for read-only relocations.
@@ -101,7 +97,6 @@ def check_ELF_separate_code(binary):
10197
for segment in binary.segments:
10298
if segment.type == lief.ELF.SEGMENT_TYPES.LOAD:
10399
for section in segment.sections:
104-
assert(section.name not in flags_per_section)
105100
flags_per_section[section.name] = segment.flags
106101
# Spot-check ELF LOAD program header flags per section
107102
# If these sections exist, check them against the expected R/W/E flags
@@ -222,7 +217,7 @@ def check_MACHO_control_flow(binary) -> bool:
222217
lief.ARCHITECTURES.ARM: BASE_ELF,
223218
lief.ARCHITECTURES.ARM64: BASE_ELF,
224219
lief.ARCHITECTURES.PPC: BASE_ELF,
225-
LIEF_ELF_ARCH_RISCV: BASE_ELF,
220+
lief.ARCHITECTURES.RISCV: BASE_ELF,
226221
},
227222
lief.EXE_FORMATS.PE: {
228223
lief.ARCHITECTURES.X86: BASE_PE,
@@ -250,12 +245,9 @@ def check_MACHO_control_flow(binary) -> bool:
250245
continue
251246

252247
if arch == lief.ARCHITECTURES.NONE:
253-
if binary.header.machine_type == LIEF_ELF_ARCH_RISCV:
254-
arch = LIEF_ELF_ARCH_RISCV
255-
else:
256-
print(f'{filename}: unknown architecture')
257-
retval = 1
258-
continue
248+
print(f'{filename}: unknown architecture')
249+
retval = 1
250+
continue
259251

260252
failed: List[str] = []
261253
for (name, func) in CHECKS[etype][arch]:

contrib/devtools/symbol-check.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@
1515

1616
import lief #type:ignore
1717

18-
# temporary constant, to be replaced with lief.ELF.ARCH.RISCV
19-
# https://github.com/lief-project/LIEF/pull/562
20-
LIEF_ELF_ARCH_RISCV = lief.ELF.ARCH(243)
21-
2218
# Debian 9 (Stretch) EOL: 2022. https://wiki.debian.org/DebianReleases#Production_Releases
2319
#
2420
# - g++ version 6.3.0 (https://packages.debian.org/search?suite=stretch&arch=any&searchon=names&keywords=g%2B%2B)
@@ -44,7 +40,7 @@
4440
lief.ELF.ARCH.ARM: (2,18),
4541
lief.ELF.ARCH.AARCH64:(2,18),
4642
lief.ELF.ARCH.PPC64: (2,18),
47-
LIEF_ELF_ARCH_RISCV: (2,27),
43+
lief.ELF.ARCH.RISCV: (2,27),
4844
},
4945
'LIBATOMIC': (1,0),
5046
'V': (0,5,0), # xkb (bitcoin-qt only)
@@ -78,7 +74,7 @@
7874
lief.ENDIANNESS.BIG: "/lib64/ld64.so.1",
7975
lief.ENDIANNESS.LITTLE: "/lib64/ld64.so.2",
8076
},
81-
LIEF_ELF_ARCH_RISCV: {
77+
lief.ELF.ARCH.RISCV: {
8278
lief.ENDIANNESS.LITTLE: "/lib/ld-linux-riscv64-lp64d.so.1",
8379
},
8480
}
@@ -200,7 +196,7 @@ def check_exported_symbols(binary) -> bool:
200196
if not symbol.exported:
201197
continue
202198
name = symbol.name
203-
if binary.header.machine_type == LIEF_ELF_ARCH_RISCV or name in IGNORE_EXPORTS:
199+
if binary.header.machine_type == lief.ELF.ARCH.RISCV or name in IGNORE_EXPORTS:
204200
continue
205201
print(f'{binary.name}: export of symbol {name} not allowed!')
206202
ok = False

contrib/guix/manifest.scm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ chain for " target " development."))
197197
(define-public lief
198198
(package
199199
(name "python-lief")
200-
(version "0.11.5")
200+
(version "0.12.0")
201201
(source
202202
(origin
203203
(method git-fetch)
@@ -207,7 +207,7 @@ chain for " target " development."))
207207
(file-name (git-file-name name version))
208208
(sha256
209209
(base32
210-
"0qahjfg1n0x76ps2mbyljvws1l3qhkqvmxqbahps4qgywl2hbdkj"))))
210+
"026jchj56q25v6gc0754dj9cj5hz5zaza8ij93y5ga94w20kzm9q"))))
211211
(build-system python-build-system)
212212
(native-inputs
213213
`(("cmake" ,cmake)))

0 commit comments

Comments
 (0)