guix_mirror_bot pushed a commit to branch master
in repository guix.
commit 9df7a844de34dcbea682487e59de510adef641ae
Author: Maxim Cournoyer <[email protected]>
AuthorDate: Thu Sep 17 08:50:45 2026 +0900
gnu: Add lief.
* gnu/packages/elf.scm (lief): New variable.
* gnu/packages/patches/lief-utfcpp-4.2.patch: New file.
* gnu/local.mk (dist_patch_DATA): Register it.
---
gnu/local.mk | 1 +
gnu/packages/elf.scm | 73 +++++++++++++++++++++++++++++-
gnu/packages/patches/lief-utfcpp-4.2.patch | 35 ++++++++++++++
3 files changed, 108 insertions(+), 1 deletion(-)
diff --git a/gnu/local.mk b/gnu/local.mk
index bf9b80a355c..7ac7872fdc5 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1766,6 +1766,7 @@ dist_patch_DATA =
\
%D%/packages/patches/libvirt-respect-modules-path.patch \
%D%/packages/patches/libzmf-doxygen-1.14.patch \
%D%/packages/patches/libziparchive-add-includes.patch \
+ %D%/packages/patches/lief-utfcpp-4.2.patch \
%D%/packages/patches/linphone-desktop-cmake-belcard.patch \
%D%/packages/patches/linphone-desktop-cmake-find-modules.patch \
%D%/packages/patches/localed-xorg-keyboard.patch \
diff --git a/gnu/packages/elf.scm b/gnu/packages/elf.scm
index 3ed2cde0428..83a11245834 100644
--- a/gnu/packages/elf.scm
+++ b/gnu/packages/elf.scm
@@ -15,7 +15,7 @@
;;; Copyright © 2024 Zheng Junjie <[email protected]>
;;; Copyright © 2025 John Kehayias <[email protected]>
;;; Copyright © 2025 Nicolas Graves <[email protected]>
-;;; Copyright © 2025 Maxim Cournoyer <[email protected]>
+;;; Copyright © 2025, 2026 Maxim Cournoyer <[email protected]>
;;; Copyright © 2025 Artyom V. Poptsov <[email protected]>
;;;
;;; This file is part of GNU Guix.
@@ -39,6 +39,7 @@
#:use-module (guix packages)
#:use-module (guix download)
#:use-module (guix git-download)
+ #:use-module (guix build-system cmake)
#:use-module (guix build-system meson)
#:use-module (guix build-system gnu)
#:use-module ((guix licenses) #:prefix license:)
@@ -47,16 +48,20 @@
#:use-module (gnu packages compression)
#:use-module (gnu packages base)
#:use-module (gnu packages bash)
+ #:use-module (gnu packages cpp)
#:use-module (gnu packages digest)
#:use-module (gnu packages docbook)
#:use-module (gnu packages documentation)
#:use-module (gnu packages gawk)
#:use-module (gnu packages gcc)
+ #:use-module (gnu packages logging)
#:use-module (gnu packages m4)
#:use-module (gnu packages pkg-config)
#:use-module (gnu packages python)
#:use-module (gnu packages sphinx)
#:use-module (gnu packages texinfo)
+ #:use-module (gnu packages textutils)
+ #:use-module (gnu packages tls)
#:use-module (gnu packages xml)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-26))
@@ -324,6 +329,72 @@ static analysis of the ELF binaries at hand.")
#~(append #$flags '("CFLAGS=-fPIC")))))
(properties `((hidden? . #t) ,@(package-properties libelf)))))
+(define-public lief
+ (package
+ (name "lief")
+ (version "1.0.0")
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/lief-project/LIEF")
+ (commit version)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "0yhs1x8nli5lhwiq383nnfv8ajgbdidcjckdls1j0zrmyf9kbfa2"))
+ (modules '((guix build utils)))
+ (snippet '(delete-file-recursively "third-party"))
+ (patches (search-patches "lief-utfcpp-4.2.patch"))))
+ (build-system cmake-build-system)
+ (arguments
+ (list #:configure-flags
+ #~(list "-DLIEF_OPT_EXTERNAL_EXPECTED=ON"
+ "-DLIEF_OPT_EXTERNAL_SPAN=ON"
+ "-DLIEF_EXTERNAL_SPDLOG=ON"
+ "-DLIEF_OPT_FROZEN_EXTERNAL=ON"
+ "-DLIEF_OPT_MBEDTLS_EXTERNAL=ON"
+ "-DLIEF_OPT_NLOHMANN_JSON_EXTERNAL=ON"
+ "-DLIEF_OPT_UTFCPP_EXTERNAL=ON"
+ "-DBUILD_SHARED_LIBS=ON")
+ ;; The test suite is disabled by default, and requires to
+ ;; download/extract a 350 MiB compressed archive of test data.
+ #:tests? #f))
+ (inputs
+ (list frozen
+ mbedtls-4.0 ;<https://github.com/lief-project/LIEF/issues/1381>
+ nlohmann-json
+ spdlog
+ utfcpp)) ;<https://github.com/lief-project/LIEF/issues/1382>
+ (propagated-inputs
+ ;; Included in the include/LIEF/third-party headers.
+ (list libexpected
+ tcbrindle-span))
+ (home-page "https://lief.re/")
+ (synopsis "Library to instrument executable formats")
+ (description "The @acronym{LIEF, Library to Instrument Executable Formats}
+library can parse, modify and abstract ELF, PE, MachO and other formats. It
+provides an abstraction over common features like sections, symbols and entry
+points. This package provides the C/C++ API. The table below lists its main
+features in more details:
+@table @asis
+@item Parsing
+LIEF can parse ELF, PE, MachO, COFF, OAT, DEX, VDEX, ART and provides a
+user-friendly API to access their internals.
+
+@item Modify
+LIEF can be used to modify some parts of these formats (adding a section,
+changing a symbol's name, etc.)
+
+@item Abstract
+Three formats have common features like sections, symbols, entry point, etc.
LIEF
+factors them.
+
+@item API
+The LIEF API is available for C/C++ (this package), Python
(@code{python-lief}),
+and other languages.
+@end table")
+ (license license:asl2.0)))
+
(define-public patchelf
(package
(name "patchelf")
diff --git a/gnu/packages/patches/lief-utfcpp-4.2.patch
b/gnu/packages/patches/lief-utfcpp-4.2.patch
new file mode 100644
index 00000000000..a0767774e93
--- /dev/null
+++ b/gnu/packages/patches/lief-utfcpp-4.2.patch
@@ -0,0 +1,35 @@
+Upstream-status: <https://github.com/lief-project/LIEF/pull/1380>
+
+From 029bba8595a6747805e11fde8ed1443eee2349f6 Mon Sep 17 00:00:00 2001
+From: Daeho Ro <[email protected]>
+Date: Wed, 16 Sep 2026 22:12:02 +0900
+Subject: [PATCH] core: support utfcpp 4.2
+
+---
+ src/utils.cpp | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/src/utils.cpp b/src/utils.cpp
+index c5246b6fc6..2df012ff6f 100644
+--- a/src/utils.cpp
++++ b/src/utils.cpp
+@@ -38,8 +38,8 @@ template<typename octet_iterator>
+ result<uint32_t> next(octet_iterator& it, octet_iterator end) {
+ using namespace utf8;
+ using namespace utf8::internal;
+- utfchar32_t cp = 0;
+- internal::utf_error err_code = validate_next(it, end, cp);
++ octet_iterator start = it;
++ internal::utf_error err_code = validate_next(it, end);
+ switch (err_code) {
+ case UTF8_OK: break;
+ case NOT_ENOUGH_ROOM: return make_error_code(lief_errors::data_too_large);
+@@ -48,7 +48,7 @@ result<uint32_t> next(octet_iterator& it, octet_iterator
end) {
+ case OVERLONG_SEQUENCE:
+ case INVALID_CODE_POINT: return make_error_code(lief_errors::read_error);
+ }
+- return cp;
++ return utf8::unchecked::next(start);
+ }
+
+ std::string u16tou8(const char16_t* buffer, size_t size, bool
remove_null_char) {