Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1#!/usr/bin/env python32# Copyright (c) 2014 Wladimir J. van der Laan3# Distributed under the MIT software license, see the accompanying4# file COPYING or http://www.opensource.org/licenses/mit-license.php.5'''6A script to check that release executables only contain certain symbols7and are only linked against allowed libraries.9Example usage:11find ../path/to/guix/binaries -type f -executable | xargs python3 contrib/guix/symbol-check.py12'''13import sys15import lief17# Debian 11 (Bullseye) EOL: 2026. https://wiki.debian.org/LTS18#19# - libc version 2.31 (https://packages.debian.org/source/bullseye/glibc)20#21# Ubuntu 20.04 (Focal) EOL: 2030. https://wiki.ubuntu.com/ReleaseTeam22#23# - libc version 2.31 (https://packages.ubuntu.com/focal/libc6)24#25# CentOS Stream 9 EOL: 2027. https://www.centos.org/cl-vs-cs/#end-of-life26#27# - libc version 2.34 (https://mirror.stream.centos.org/9-stream/AppStream/x86_64/os/Packages/)28#29# bitcoin-qt30#31# Ubuntu 22.04 is currently the baseline for ELF_ALLOWED_LIBRARIES:32#33# libfontconfig version 2.13.1 (https://packages.ubuntu.com/jammy/libfontconfig1)34#35# libfreetype version 2.11.1 (https://packages.ubuntu.com/jammy/libfreetype6)37MAX_VERSIONS = {38'GLIBC': {39lief.ELF.ARCH.X86_64: (2,31),40lief.ELF.ARCH.ARM: (2,31),41lief.ELF.ARCH.AARCH64:(2,31),42lief.ELF.ARCH.PPC64: (2,31),43lief.ELF.ARCH.RISCV: (2,31),44}45}47# Ignore symbols that are exported as part of every executable48IGNORE_EXPORTS = {49'stdin', 'stdout', 'stderr',50}52# Expected linker-loader names can be found here:53# https://sourceware.org/glibc/wiki/ABIList?action=recall&rev=1654ELF_INTERPRETER_NAMES: dict[lief.ELF.ARCH, dict[lief.Header.ENDIANNESS, str]] = {55lief.ELF.ARCH.X86_64: {56lief.Header.ENDIANNESS.LITTLE: "/lib64/ld-linux-x86-64.so.2",57},58lief.ELF.ARCH.ARM: {59lief.Header.ENDIANNESS.LITTLE: "/lib/ld-linux-armhf.so.3",60},61lief.ELF.ARCH.AARCH64: {62lief.Header.ENDIANNESS.LITTLE: "/lib/ld-linux-aarch64.so.1",63},64lief.ELF.ARCH.PPC64: {65lief.Header.ENDIANNESS.BIG: "/lib64/ld64.so.1",66lief.Header.ENDIANNESS.LITTLE: "/lib64/ld64.so.2",67},68lief.ELF.ARCH.RISCV: {69lief.Header.ENDIANNESS.LITTLE: "/lib/ld-linux-riscv64-lp64d.so.1",70},71}73ELF_ABIS: dict[lief.ELF.ARCH, dict[lief.Header.ENDIANNESS, list[int]]] = {74lief.ELF.ARCH.X86_64: {75lief.Header.ENDIANNESS.LITTLE: [3,17,0],76},77lief.ELF.ARCH.ARM: {78lief.Header.ENDIANNESS.LITTLE: [3,17,0],79},80lief.ELF.ARCH.AARCH64: {81lief.Header.ENDIANNESS.LITTLE: [3,17,0],82},83lief.ELF.ARCH.PPC64: {84lief.Header.ENDIANNESS.LITTLE: [3,17,0],85lief.Header.ENDIANNESS.BIG: [3,17,0],86},87lief.ELF.ARCH.RISCV: {88lief.Header.ENDIANNESS.LITTLE: [4,15,0],89},90}92# Allowed NEEDED libraries93ELF_ALLOWED_LIBRARIES = {94# bitcoind and bitcoin-qt95'libc.so.6', # C library96'libpthread.so.0', # threading97'libm.so.6', # math library98'ld-linux-x86-64.so.2', # 64-bit dynamic linker99'ld-linux.so.2', # 32-bit dynamic linker100'ld-linux-aarch64.so.1', # 64-bit ARM dynamic linker101'ld-linux-armhf.so.3', # 32-bit ARM dynamic linker102'ld64.so.1', # POWER64 ABIv1 dynamic linker103'ld64.so.2', # POWER64 ABIv2 dynamic linker104'ld-linux-riscv64-lp64d.so.1', # 64-bit RISC-V dynamic linker105# bitcoin-qt only106'libfontconfig.so.1', # font support107'libfreetype.so.6', # font parsing108'libdl.so.2', # programming interface to dynamic linker109}111MACHO_ALLOWED_LIBRARIES = {112# bitcoind and bitcoin-qt113'libc++.1.dylib', # C++ Standard Library114'libSystem.B.dylib', # libc, libm, libpthread, libinfo115# bitcoin-qt only116'AppKit', # user interface117'ApplicationServices', # common application tasks.118'Carbon', # deprecated c back-compat API119'ColorSync',120'CoreFoundation', # low level func, data types121'CoreGraphics', # 2D rendering122'CoreServices', # operating system services123'CoreText', # interface for laying out text and handling fonts.124'CoreVideo', # video processing125'Foundation', # base layer functionality for apps/frameworks126'ImageIO', # read and write image file formats.127'IOKit', # user-space access to hardware devices and drivers.128'IOSurface', # cross process image/drawing buffers129'libobjc.A.dylib', # Objective-C runtime library130'Metal', # 3D graphics131'QuartzCore', # animation132'Security', # access control and authentication133'UniformTypeIdentifiers', # collection of types that map to MIME and file types134}136PE_ALLOWED_LIBRARIES = {137'ADVAPI32.dll', # legacy security & registry138'bcrypt.dll', # newer security and identity API139'IPHLPAPI.DLL', # IP helper API140'KERNEL32.dll', # win32 base APIs141'msvcrt.dll', # C standard library for MSVC142'SHELL32.dll', # shell API143'WS2_32.dll', # sockets144# bitcoin-qt only145'api-ms-win-core-synch-l1-2-0.dll', # Synchronization Primitives API146'api-ms-win-core-winrt-l1-1-0.dll', # Windows Runtime API147'api-ms-win-core-winrt-string-l1-1-0.dll', # WinRT String API148'AUTHZ.dll', # Windows Authorization Framework149'comdlg32.dll', # Common Dialog Box Library150'd3d11.dll', # Direct3D 11 API151'd3d12.dll', # Direct3D 12 API152'd3d9.dll', # Direct3D 9 API153'dwmapi.dll', # desktop window manager154'DWrite.dll', # DirectX Typography Services155'dxgi.dll', # DirectX Graphics Infrastructure156'GDI32.dll', # graphics device interface157'IMM32.dll', # input method editor158'NETAPI32.dll', # network management159'ole32.dll', # component object model160'OLEAUT32.dll', # OLE Automation API161'SHLWAPI.dll', # light weight shell API162'USER32.dll', # user interface163'USERENV.dll', # user management164'UxTheme.dll', # visual style165'VERSION.dll', # version checking166'WINMM.dll', # WinMM audio API167'WTSAPI32.dll', # Remote Desktop168'SETUPAPI.dll', # Windows Setup API169'SHCORE.dll', # Stream Handler Core170}172def check_version(max_versions, version, arch) -> bool:173(lib, _, ver) = version.rpartition('_')174ver = tuple([int(x) for x in ver.split('.')])175if lib not in max_versions:176return False177if isinstance(max_versions[lib], tuple):178return ver <= max_versions[lib]179else:180return ver <= max_versions[lib][arch]182def check_imported_symbols(binary) -> bool:183ok: bool = True185for symbol in binary.imported_symbols:186if not symbol.imported:187continue189version = symbol.symbol_version if symbol.has_version else None191if version:192aux_version = version.symbol_version_auxiliary.name if version.has_auxiliary_version else None193if aux_version and not check_version(MAX_VERSIONS, aux_version, binary.header.machine_type):194print(f'{filename}: symbol {symbol.name} from unsupported version {version}')195ok = False196return ok198def check_exported_symbols(binary) -> bool:199ok: bool = True201for symbol in binary.dynamic_symbols:202if not symbol.exported:203continue204name = symbol.name205if name in IGNORE_EXPORTS:206continue207print(f'{filename}: export of symbol {name} not allowed!')208ok = False209return ok211def check_RUNPATH(binary) -> bool:212assert binary.get(lief.ELF.DynamicEntry.TAG.RUNPATH) is None213assert binary.get(lief.ELF.DynamicEntry.TAG.RPATH) is None214return True216def check_ELF_libraries(binary) -> bool:217ok: bool = True218for library in binary.libraries:219if library not in ELF_ALLOWED_LIBRARIES:220print(f'{filename}: {library} is not in ALLOWED_LIBRARIES!')221ok = False222return ok224def check_MACHO_libraries(binary) -> bool:225ok: bool = True226for dylib in binary.libraries:227split = dylib.name.split('/')228if split[-1] not in MACHO_ALLOWED_LIBRARIES:229print(f'{split[-1]} is not in ALLOWED_LIBRARIES!')230ok = False231return ok233def check_MACHO_min_os(binary) -> bool:234if binary.build_version.minos == [14,0,0]:235return True236return False238def check_MACHO_sdk(binary) -> bool:239if binary.build_version.sdk == [14, 0, 0]:240return True241return False243def check_MACHO_lld(binary) -> bool:244if binary.build_version.tools[0].version == [19, 1, 7]:245return True246return False248def check_PE_libraries(binary) -> bool:249ok: bool = True250for dylib in binary.libraries:
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.