Inside Bitcoin
Opening the selected file…
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 bash2#3# Copyright (c) The Bitcoin Core developers4# Distributed under the MIT software license, see the accompanying5# file COPYING or http://www.opensource.org/licenses/mit-license.php.7export LC_ALL=C.UTF-88set -o errexit -o xtrace -o pipefail10GCC=/opt/riscv-ilp32/bin/riscv32-unknown-elf-gcc11GXX=/opt/riscv-ilp32/bin/riscv32-unknown-elf-g++12CRTBEGIN=$("${GCC}" -print-file-name=crtbegin.o)13LIBGCC=$("${GCC}" -print-libgcc-file-name)14LIBSTDCXX=$("${GXX}" -print-file-name=libstdc++.a)15LIBC=$("${GCC}" -print-file-name=libc.a)16LIBM=$("${GCC}" -print-file-name=libm.a)18echo -e "#include <script/script_error.h>\n int main() { return ScriptErrorString(ScriptError_t::SCRIPT_ERR_UNKNOWN_ERROR).size() > 0; }" > test.cpp20"${GXX}" -I "${BASE_ROOT_DIR}"/src -g -std=c++20 -c test.cpp -o test.o22# Make the binary executable on linux for testing purposes23echo -e ".section .text24.global _start25.type _start, @function27_start:28.option push29.option norelax30la gp, __global_pointer$31.option pop33call main35# Put Exit2 system call number into the a7 register36li a7, 9337ecall" > start.s39"${GCC}" -c start.s -o start.o41echo -e "#include <sys/stat.h>42void _exit(int code) { while(1); }43int _sbrk(int incr) { return 0; }44int _write(int file, char *ptr, int len) { return 0; }45int _close(int file) { return -1; }46int _fstat(int file, struct stat *st) { st->st_mode = S_IFCHR; return 0; }47int _isatty(int file) { return 1; }48int _lseek(int file, int ptr, int dir) { return 0; }49int _read(int file, char *ptr, int len) { return 0; }50int _kill(int pid, int sig) { return -1; }51int _getpid(void) { return -1; }" > syscalls.c53"${GCC}" -g -c syscalls.c -o syscalls.o55"${GXX}" -g -std=c++20 \56-nostdlib \57"${CRTBEGIN}" \58test.o \59start.o \60syscalls.o \61-Wl,--whole-archive \62"${BASE_BUILD_DIR}"/lib/libbitcoin_consensus.a \63"${BASE_BUILD_DIR}"/lib/libbitcoin_crypto.a \64"${BASE_BUILD_DIR}"/src/secp256k1/lib/libsecp256k1.a \65-Wl,--no-whole-archive \66"${LIBSTDCXX}" \67"${LIBC}" \68"${LIBM}" \69"${LIBGCC}" \70-o test.elf72file test.elf
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.