Skip to content

Commit a4e429c

Browse files
fanquakePastaPastaPasta
authored andcommitted
Merge bitcoin#26953: contrib: add ELF OS ABI check to symbol-check.py
65ba8a7 contrib: add ELF ABI check to symbol-check.py (fanquake) Pull request description: Check that the operating system ABI version embedded into the release binaries, is the version we expect it to be. ACKs for top commit: laanwj: Code review ACK 65ba8a7 TheCharlatan: ACK 65ba8a7 Tree-SHA512: 798d7c3b05183becf113a2ea13d889e18f1cec01d3cc279e64dbddede4d57f87444978f3f52c44bc5fdf0ba93d77c7c0be37aa815f93f348c35da45dc3d30ac2
1 parent deb7de2 commit a4e429c

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

contrib/devtools/symbol-check.py

+26
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,25 @@
7575
},
7676
}
7777

78+
ELF_ABIS: Dict[lief.ELF.ARCH, Dict[lief.ENDIANNESS, List[int]]] = {
79+
lief.ELF.ARCH.x86_64: {
80+
lief.ENDIANNESS.LITTLE: [3,2,0],
81+
},
82+
lief.ELF.ARCH.ARM: {
83+
lief.ENDIANNESS.LITTLE: [3,2,0],
84+
},
85+
lief.ELF.ARCH.AARCH64: {
86+
lief.ENDIANNESS.LITTLE: [3,7,0],
87+
},
88+
lief.ELF.ARCH.PPC64: {
89+
lief.ENDIANNESS.LITTLE: [3,10,0],
90+
lief.ENDIANNESS.BIG: [3,2,0],
91+
},
92+
lief.ELF.ARCH.RISCV: {
93+
lief.ENDIANNESS.LITTLE: [4,15,0],
94+
},
95+
}
96+
7897
# Allowed NEEDED libraries
7998
ELF_ALLOWED_LIBRARIES = {
8099
# dashd and dash-qt
@@ -248,12 +267,19 @@ def check_ELF_interpreter(binary) -> bool:
248267

249268
return binary.concrete.interpreter == expected_interpreter
250269

270+
def check_ELF_ABI(binary) -> bool:
271+
expected_abi = ELF_ABIS[binary.header.machine_type][binary.abstract.header.endianness]
272+
note = binary.concrete.get(lief.ELF.NOTE_TYPES.ABI_TAG)
273+
assert note.details.abi == lief.ELF.NOTE_ABIS.LINUX
274+
return note.details.version == expected_abi
275+
251276
CHECKS = {
252277
lief.EXE_FORMATS.ELF: [
253278
('IMPORTED_SYMBOLS', check_imported_symbols),
254279
('EXPORTED_SYMBOLS', check_exported_symbols),
255280
('LIBRARY_DEPENDENCIES', check_ELF_libraries),
256281
('INTERPRETER_NAME', check_ELF_interpreter),
282+
('ABI', check_ELF_ABI),
257283
],
258284
lief.EXE_FORMATS.MACHO: [
259285
('DYNAMIC_LIBRARIES', check_MACHO_libraries),

0 commit comments

Comments
 (0)