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>
9 ;;; Copyright © 2020 Mark Wielaard <mark@klomp.org>
11 ;;; This file is part of GNU Guix.
13 ;;; GNU Guix is free software; you can redistribute it and/or modify it
14 ;;; under the terms of the GNU General Public License as published by
15 ;;; the Free Software Foundation; either version 3 of the License, or (at
16 ;;; your option) any later version.
18 ;;; GNU Guix is distributed in the hope that it will be useful, but
19 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ;;; GNU General Public License for more details.
23 ;;; You should have received a copy of the GNU General Public License
24 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
26 (define-module (gnu packages elf)
27 #:use-module (guix utils)
28 #:use-module (guix packages)
29 #:use-module (guix download)
30 #:use-module (guix build-system gnu)
31 #:use-module ((guix licenses) #:select (gpl3+ lgpl3+ lgpl2.0+))
32 #:use-module (gnu packages)
33 #:use-module (gnu packages compression)
34 #:use-module (gnu packages documentation)
35 #:use-module (gnu packages gcc)
36 #:use-module (gnu packages m4)
37 #:use-module (gnu packages pkg-config)
38 #:use-module (gnu packages python)
39 #:use-module (gnu packages sphinx)
40 #:use-module (gnu packages texinfo)
41 #:use-module (gnu packages xml))
43 (define-public elfutils
49 (uri (string-append "https://sourceware.org/elfutils/ftp/"
50 version "/elfutils-" version ".tar.bz2"))
53 "08qhrl4g6qqr4ga46jhh78y56a47p3msa5b2x1qhzbxhf71lfmzb"))
54 (patches (search-patches "elfutils-tests-ptrace.patch"))))
55 (build-system gnu-build-system)
57 ;; Separate programs because that's usually not what elfutils users want,
58 ;; and because they duplicate what Binutils provides (but are named
59 ;; differently, using the eu- prefix and can be installed in parallel).
60 (outputs '("out" ; libelf.so, elfutils/*.h, etc.
61 "bin")) ; eu-nm, eu-objdump, etc.
64 ;; Programs don't have libelf.so in their RUNPATH and libraries don't
65 ;; know where to find each other.
66 `(#:configure-flags (list (string-append "LDFLAGS=-Wl,-rpath="
67 (assoc-ref %outputs "out")
70 ;; Disable tests on MIPS (without changing
71 ;; the arguments list on other systems).
72 ,@(if (string-prefix? "mips" (or (%current-target-system)
78 (modify-phases %standard-phases
79 ;; No reason has been found for this test to reliably fail on aarch64-linux.
80 (add-after 'unpack 'disable-failing-aarch64-tests
82 (substitute* "tests/Makefile.in"
83 (("run-backtrace-native.sh") ""))
86 (native-inputs `(("m4" ,m4)))
87 (inputs `(("zlib" ,zlib)))
88 (home-page "https://sourceware.org/elfutils/")
89 (synopsis "Collection of utilities and libraries to handle ELF files and
92 "Elfutils is a collection of utilities and libraries to read, create and
93 modify Executable and Linkable Format (@dfn{ELF}) binary files, find and
94 handle Debugging With Arbitrary Record Formats (@dfn{DWARF}) debug data,
95 symbols, thread state and stacktraces for processes and core files on
96 GNU/Linux. Elfutils includes @file{libelf} for manipulating ELF files,
97 @file{libdw} for inspecting DWARF data and process state and utilities like
98 @command{eu-stack} (to show backtraces), @command{eu-nm} (for listing symbols
99 from object files), @command{eu-size} (for listing the section sizes of an
100 object or archive file), @command{eu-strip} (for discarding symbols),
101 @command{eu-readelf} (to see the raw ELF file structures),
102 @command{eu-elflint} (to check for well-formed ELF files),
103 @command{eu-elfcompress} (to compress or decompress ELF sections), and more.")
105 ;; Libraries are dual-licensed LGPLv3.0+ | GPLv2, and programs are GPLv3+.
108 (define-public libabigail
111 (home-page "https://sourceware.org/libabigail/")
115 (uri (string-append "https://sourceware.org/pub/libabigail/"
116 "libabigail-" version ".tar.gz"))
119 "04j07lhvwbp6qp8pdwbf7iqnr7kgpabmqylsw4invpmzwnyp6g6g"))))
120 (build-system gnu-build-system)
122 `(#:configure-flags '("--disable-static"
123 "--enable-bash-completion"
125 #:make-flags '("V=1")
126 #:phases (modify-phases %standard-phases
127 (add-after 'unpack 'patch-source
129 (substitute* "build-aux/ltmain.sh"
130 ;; Don't add -specs=/usr/lib/rpm/redhat/redhat-hardened-ld
131 ;; to the GCC command line.
132 (("compiler_flags=\"-specs=.*")
133 "compiler_flags=\n"))
135 (add-after 'build 'build-documentation
137 (invoke "make" "-C" "doc/manuals" "html-doc" "man" "info")))
138 (add-before 'check 'set-test-environment
140 (setenv "XDG_CACHE_HOME" "/tmp")
142 (add-after 'install 'install-documentation
144 (invoke "make" "-C" "doc/manuals"
145 "install-man-and-info-doc")))
146 (add-after 'install-documentation 'install-bash-completion
147 (lambda* (#:key outputs #:allow-other-keys)
148 (for-each (lambda (file)
150 file (string-append (assoc-ref outputs "out")
151 "/share/bash-completion"
153 (find-files "bash-completion" ".*abi.*"))
156 `(("pkg-config" ,pkg-config)
157 ("makeinfo" ,texinfo)
158 ("python-sphinx" ,python-sphinx)
159 ("python" ,python))) ;for tests
161 `(("elfutils" ,elfutils) ;libabigail.la says -lelf
162 ("libxml2" ,libxml2))) ;in Requires.private of libabigail.pc
163 (synopsis "Analyze application binary interfaces (ABIs)")
165 "@dfn{ABIGAIL} stands for the Application Binary Interface Generic
166 Analysis and Instrumentation Library. It is a framework which aims at
167 helping developers and software distributors to spot ABI-related issues
168 like interface incompatibility in ELF shared libraries by performing a
169 static analysis of the ELF binaries at hand.")
172 (define-public libelf
180 ;; As of May 2019, the original URL at mr511.de redirects to a
181 ;; domain that doesn't resolve. Use these two mirrors instead.
182 (string-append "https://fossies.org/linux/misc/old/"
183 "libelf-" version ".tar.gz")
184 (string-append "https://ftp.osuosl.org/pub/blfs/conglomeration/"
185 "libelf/libelf-" version ".tar.gz")))
188 "0vf7s9dwk2xkmhb79aigqm0x0yfbw1j0b9ksm51207qwr179n6jr"))))
189 (build-system gnu-build-system)
192 (modify-phases %standard-phases
194 (lambda* (#:key outputs #:allow-other-keys)
195 ;; This old `configure' script doesn't support
196 ;; variables passed as arguments.
197 (let ((out (assoc-ref outputs "out")))
198 (setenv "CONFIG_SHELL" (which "bash"))
199 (invoke "./configure"
200 (string-append "--prefix=" out)
201 ,@(if (string=? "aarch64-linux"
203 '("--host=aarch64-unknown-linux-gnu")
205 (home-page (string-append "https://web.archive.org/web/20181111033959/"
206 "http://www.mr511.de/software/english.html"))
207 (synopsis "ELF object file access library")
208 (description "Libelf is a C library to access ELF object files.")
211 (define-public patchelf
218 "https://nixos.org/releases/patchelf/patchelf-"
220 "/patchelf-" version ".tar.bz2"))
223 "1wzwvnlyf853hw9zgqq5522bvf8gqadk8icgqa41a5n7593csw7n"))))
224 (build-system gnu-build-system)
227 (modify-phases %standard-phases
228 (add-after 'unpack 'fix-tests
229 ;; Our GCC code ensures that RUNPATH is never empty, it includes
230 ;; at least glibc/lib and gcc:lib/lib.
231 (lambda* (#:key inputs #:allow-other-keys)
232 (substitute* "tests/no-rpath.sh"
233 ;; Disable checking for an empty runpath:
235 ;; Find libgcc_s.so, which is necessary for the test:
236 (("/xxxxxxxxxxxxxxx") (string-append (assoc-ref inputs "gcc:lib")
240 `(("gcc:lib" ,gcc "lib")))
241 (home-page "https://nixos.org/patchelf.html")
242 (synopsis "Modify the dynamic linker and RPATH of ELF executables")
244 "PatchELF allows the ELF \"interpreter\" and RPATH of an ELF binary to be