1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2014, 2015 Mark H Weaver <mhw@netris.org>
4 ;;; Copyright © 2015 Andreas Enge <andreas@enge.fr>
5 ;;; Copyright © 2017, 2018, 2019 Efraim Flashner <efraim@flashner.co.il>
6 ;;; Copyright © 2017 Leo Famulari <leo@famulari.name>
7 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
8 ;;; Copyright © 2018 Marius Bakke <mbakke@fastmail.com>
10 ;;; This file is part of GNU Guix.
12 ;;; GNU Guix is free software; you can redistribute it and/or modify it
13 ;;; under the terms of the GNU General Public License as published by
14 ;;; the Free Software Foundation; either version 3 of the License, or (at
15 ;;; your option) any later version.
17 ;;; GNU Guix is distributed in the hope that it will be useful, but
18 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;;; GNU General Public License for more details.
22 ;;; You should have received a copy of the GNU General Public License
23 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
25 (define-module (gnu packages elf)
26 #:use-module (guix utils)
27 #:use-module (guix packages)
28 #:use-module (guix download)
29 #:use-module (guix build-system gnu)
30 #:use-module ((guix licenses) #:select (gpl3+ lgpl3+ lgpl2.0+))
31 #:use-module (gnu packages)
32 #:use-module (gnu packages compression)
33 #:use-module (gnu packages documentation)
34 #:use-module (gnu packages gcc)
35 #:use-module (gnu packages m4)
36 #:use-module (gnu packages pkg-config)
37 #:use-module (gnu packages python)
38 #:use-module (gnu packages sphinx)
39 #:use-module (gnu packages texinfo)
40 #:use-module (gnu packages xml))
42 (define-public elfutils
48 (uri (string-append "https://sourceware.org/elfutils/ftp/"
49 version "/elfutils-" version ".tar.bz2"))
52 "08qhrl4g6qqr4ga46jhh78y56a47p3msa5b2x1qhzbxhf71lfmzb"))
53 (patches (search-patches "elfutils-tests-ptrace.patch"))))
54 (build-system gnu-build-system)
56 ;; Separate programs because that's usually not what elfutils users want,
57 ;; and because they duplicate what Binutils provides.
58 (outputs '("out" ; libelf.so, elfutils/*.h, etc.
59 "bin")) ; ld, nm, objdump, etc.
62 ;; Programs don't have libelf.so in their RUNPATH and libraries don't
63 ;; know where to find each other.
64 `(#:configure-flags (list (string-append "LDFLAGS=-Wl,-rpath="
65 (assoc-ref %outputs "out")
68 ;; Disable tests on MIPS (without changing
69 ;; the arguments list on other systems).
70 ,@(if (string-prefix? "mips" (or (%current-target-system)
76 (modify-phases %standard-phases
77 ;; No reason has been found for this test to reliably fail on aarch64-linux.
78 (add-after 'unpack 'disable-failing-aarch64-tests
80 (substitute* "tests/Makefile.in"
81 (("run-backtrace-native.sh") ""))
84 (native-inputs `(("m4" ,m4)))
85 (inputs `(("zlib" ,zlib)))
86 (home-page "https://sourceware.org/elfutils/")
87 (synopsis "Linker and ELF manipulation tools")
89 "This package provides command-line tools to manipulate binaries in the
90 Executable and Linkable Format (@dfn{ELF}). This includes @command{ld},
91 @command{ar}, @command{objdump}, @command{addr2line}, and more.")
93 ;; Libraries are dual-licensed LGPLv3.0+ | GPLv2, and programs are GPLv3+.
96 (define-public libabigail
99 (home-page "https://sourceware.org/libabigail/")
103 (uri (string-append "https://sourceware.org/pub/libabigail/"
104 "libabigail-" version ".tar.gz"))
107 "04j07lhvwbp6qp8pdwbf7iqnr7kgpabmqylsw4invpmzwnyp6g6g"))))
108 (build-system gnu-build-system)
110 `(#:configure-flags '("--disable-static"
111 "--enable-bash-completion"
113 #:make-flags '("V=1")
114 #:phases (modify-phases %standard-phases
115 (add-after 'unpack 'patch-source
117 (substitute* "build-aux/ltmain.sh"
118 ;; Don't add -specs=/usr/lib/rpm/redhat/redhat-hardened-ld
119 ;; to the GCC command line.
120 (("compiler_flags=\"-specs=.*")
121 "compiler_flags=\n"))
123 (add-after 'build 'build-documentation
125 (invoke "make" "-C" "doc/manuals" "html-doc" "man" "info")))
126 (add-before 'check 'set-test-environment
128 (setenv "XDG_CACHE_HOME" "/tmp")
130 (add-after 'install 'install-documentation
132 (invoke "make" "-C" "doc/manuals"
133 "install-man-and-info-doc")))
134 (add-after 'install-documentation 'install-bash-completion
135 (lambda* (#:key outputs #:allow-other-keys)
136 (for-each (lambda (file)
138 file (string-append (assoc-ref outputs "out")
139 "/share/bash-completion"
141 (find-files "bash-completion" ".*abi.*"))
144 `(("pkg-config" ,pkg-config)
145 ("makeinfo" ,texinfo)
146 ("python-sphinx" ,python-sphinx)
147 ("python" ,python))) ;for tests
149 `(("elfutils" ,elfutils) ;libabigail.la says -lelf
150 ("libxml2" ,libxml2))) ;in Requires.private of libabigail.pc
151 (synopsis "Analyze application binary interfaces (ABIs)")
153 "@dfn{ABIGAIL} stands for the Application Binary Interface Generic
154 Analysis and Instrumentation Library. It is a framework which aims at
155 helping developers and software distributors to spot ABI-related issues
156 like interface incompatibility in ELF shared libraries by performing a
157 static analysis of the ELF binaries at hand.")
160 (define-public libelf
168 ;; As of May 2019, the original URL at mr511.de redirects to a
169 ;; domain that doesn't resolve. Use these two mirrors instead.
170 (string-append "https://fossies.org/linux/misc/old/"
171 "libelf-" version ".tar.gz")
172 (string-append "https://ftp.osuosl.org/pub/blfs/conglomeration/"
173 "libelf/libelf-" version ".tar.gz")))
176 "0vf7s9dwk2xkmhb79aigqm0x0yfbw1j0b9ksm51207qwr179n6jr"))))
177 (build-system gnu-build-system)
180 (modify-phases %standard-phases
182 (lambda* (#:key outputs #:allow-other-keys)
183 ;; This old `configure' script doesn't support
184 ;; variables passed as arguments.
185 (let ((out (assoc-ref outputs "out")))
186 (setenv "CONFIG_SHELL" (which "bash"))
187 (invoke "./configure"
188 (string-append "--prefix=" out)
189 ,@(if (string=? "aarch64-linux"
191 '("--host=aarch64-unknown-linux-gnu")
193 (home-page (string-append "https://web.archive.org/web/20181111033959/"
194 "http://www.mr511.de/software/english.html"))
195 (synopsis "ELF object file access library")
196 (description "Libelf is a C library to access ELF object files.")
199 (define-public patchelf
206 "https://nixos.org/releases/patchelf/patchelf-"
208 "/patchelf-" version ".tar.bz2"))
211 "1wzwvnlyf853hw9zgqq5522bvf8gqadk8icgqa41a5n7593csw7n"))))
212 (build-system gnu-build-system)
215 (modify-phases %standard-phases
216 (add-after 'unpack 'fix-tests
217 ;; Our GCC code ensures that RUNPATH is never empty, it includes
218 ;; at least glibc/lib and gcc:lib/lib.
219 (lambda* (#:key inputs #:allow-other-keys)
220 (substitute* "tests/no-rpath.sh"
221 ;; Disable checking for an empty runpath:
223 ;; Find libgcc_s.so, which is necessary for the test:
224 (("/xxxxxxxxxxxxxxx") (string-append (assoc-ref inputs "gcc:lib")
228 `(("gcc:lib" ,gcc "lib")))
229 (home-page "https://nixos.org/patchelf.html")
230 (synopsis "Modify the dynamic linker and RPATH of ELF executables")
232 "PatchELF allows the ELF \"interpreter\" and RPATH of an ELF binary to be